aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-03-16 15:02:13 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:22 +0800
commitac03172a8a9d8c217f405973bc096b06c5c5b4e0 (patch)
treee11a959aea4b4a03a49fd2be43035955adb6363d
parentc292584bf5c08031689f1fc080fde2c6b3b78218 (diff)
downloadgo-tangerine-ac03172a8a9d8c217f405973bc096b06c5c5b4e0.tar
go-tangerine-ac03172a8a9d8c217f405973bc096b06c5c5b4e0.tar.gz
go-tangerine-ac03172a8a9d8c217f405973bc096b06c5c5b4e0.tar.bz2
go-tangerine-ac03172a8a9d8c217f405973bc096b06c5c5b4e0.tar.lz
go-tangerine-ac03172a8a9d8c217f405973bc096b06c5c5b4e0.tar.xz
go-tangerine-ac03172a8a9d8c217f405973bc096b06c5c5b4e0.tar.zst
go-tangerine-ac03172a8a9d8c217f405973bc096b06c5c5b4e0.zip
dex: rename lattice to core
-rw-r--r--dex/app.go2
-rw-r--r--dex/handler.go10
-rw-r--r--dex/metrics.go36
-rw-r--r--dex/network.go2
-rw-r--r--dex/peer.go22
-rw-r--r--dex/protocol.go2
-rw-r--r--dex/protocol_test.go12
7 files changed, 43 insertions, 43 deletions
diff --git a/dex/app.go b/dex/app.go
index 7a1bb4cf8..d82d46658 100644
--- a/dex/app.go
+++ b/dex/app.go
@@ -470,7 +470,7 @@ func (d *DexconApp) BlockDelivered(
go d.finalizedBlockFeed.Send(core.NewFinalizedBlockEvent{Block: d.blockchain.CurrentBlock()})
}
-// BlockConfirmed is called when a block is confirmed and added to lattice.
+// BlockConfirmed is called when a block is confirmed.
func (d *DexconApp) BlockConfirmed(block coreTypes.Block) {
d.appMu.Lock()
defer d.appMu.Unlock()
diff --git a/dex/handler.go b/dex/handler.go
index efd0538f4..76219c747 100644
--- a/dex/handler.go
+++ b/dex/handler.go
@@ -790,7 +790,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
// Block proposer-only messages.
- case msg.Code == LatticeBlockMsg:
+ case msg.Code == CoreBlockMsg:
if !pm.isBlockProposer {
break
}
@@ -871,7 +871,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
}
blocks := pm.cache.blocks(hashes)
log.Debug("Push blocks", "blocks", blocks)
- return p.SendLatticeBlocks(blocks)
+ return p.SendCoreBlocks(blocks)
case msg.Code == PullVotesMsg:
if !pm.isBlockProposer {
break
@@ -991,11 +991,11 @@ func (pm *ProtocolManager) BroadcastRecords(records []*enr.Record) {
}
}
-// BroadcastLatticeBlock broadcasts the lattice block to all its peers.
-func (pm *ProtocolManager) BroadcastLatticeBlock(block *coreTypes.Block) {
+// BroadcastCoreBlock broadcasts the core block to all its peers.
+func (pm *ProtocolManager) BroadcastCoreBlock(block *coreTypes.Block) {
pm.cache.addBlock(block)
for _, peer := range pm.peers.Peers() {
- peer.AsyncSendLatticeBlocks([]*coreTypes.Block{block})
+ peer.AsyncSendCoreBlocks([]*coreTypes.Block{block})
}
}
diff --git a/dex/metrics.go b/dex/metrics.go
index ad0721057..2b23af669 100644
--- a/dex/metrics.go
+++ b/dex/metrics.go
@@ -34,10 +34,10 @@ var (
propBlockInTrafficMeter = metrics.NewRegisteredMeter("dex/prop/blocks/in/traffic", nil)
propBlockOutPacketsMeter = metrics.NewRegisteredMeter("dex/prop/blocks/out/packets", nil)
propBlockOutTrafficMeter = metrics.NewRegisteredMeter("dex/prop/blocks/out/traffic", nil)
- propLatticeBlockInPacketsMeter = metrics.NewRegisteredMeter("dex/prop/latticeblocks/in/packets", nil)
- propLatticeBlockInTrafficMeter = metrics.NewRegisteredMeter("dex/prop/latticeblocks/in/traffic", nil)
- propLatticeBlockOutPacketsMeter = metrics.NewRegisteredMeter("dex/prop/latticeblocks/out/packets", nil)
- propLatticeBlockOutTrafficMeter = metrics.NewRegisteredMeter("dex/prop/latticeblocks/out/traffic", nil)
+ propCoreBlockInPacketsMeter = metrics.NewRegisteredMeter("dex/prop/coreblocks/in/packets", nil)
+ propCoreBlockInTrafficMeter = metrics.NewRegisteredMeter("dex/prop/coreblocks/in/traffic", nil)
+ propCoreBlockOutPacketsMeter = metrics.NewRegisteredMeter("dex/prop/coreblocks/out/packets", nil)
+ propCoreBlockOutTrafficMeter = metrics.NewRegisteredMeter("dex/prop/coreblocks/out/traffic", nil)
propVoteInPacketsMeter = metrics.NewRegisteredMeter("dex/prop/votes/in/packets", nil)
propVoteInTrafficMeter = metrics.NewRegisteredMeter("dex/prop/votes/in/traffic", nil)
propVoteOutPacketsMeter = metrics.NewRegisteredMeter("dex/prop/votes/out/packets", nil)
@@ -62,10 +62,10 @@ var (
reqReceiptInTrafficMeter = metrics.NewRegisteredMeter("dex/req/receipts/in/traffic", nil)
reqReceiptOutPacketsMeter = metrics.NewRegisteredMeter("dex/req/receipts/out/packets", nil)
reqReceiptOutTrafficMeter = metrics.NewRegisteredMeter("dex/req/receipts/out/traffic", nil)
- reqLatticeBlockInPacketsMeter = metrics.NewRegisteredMeter("dex/req/latticeblocks/in/packets", nil)
- reqLatticeBlockInTrafficMeter = metrics.NewRegisteredMeter("dex/req/latticeblocks/in/traffic", nil)
- reqLatticeBlockOutPacketsMeter = metrics.NewRegisteredMeter("dex/req/latticeblocks/out/packets", nil)
- reqLatticeBlockOutTrafficMeter = metrics.NewRegisteredMeter("dex/req/latticeblocks/out/traffic", nil)
+ reqCoreBlockInPacketsMeter = metrics.NewRegisteredMeter("dex/req/coreblocks/in/packets", nil)
+ reqCoreBlockInTrafficMeter = metrics.NewRegisteredMeter("dex/req/coreblocks/in/traffic", nil)
+ reqCoreBlockOutPacketsMeter = metrics.NewRegisteredMeter("dex/req/coreblocks/out/packets", nil)
+ reqCoreBlockOutTrafficMeter = metrics.NewRegisteredMeter("dex/req/coreblocks/out/traffic", nil)
reqVoteInPacketsMeter = metrics.NewRegisteredMeter("dex/req/votes/in/packets", nil)
reqVoteInTrafficMeter = metrics.NewRegisteredMeter("dex/req/votes/in/traffic", nil)
reqVoteOutPacketsMeter = metrics.NewRegisteredMeter("dex/req/votes/out/packets", nil)
@@ -124,15 +124,15 @@ func (rw *meteredMsgReadWriter) ReadMsg() (p2p.Msg, error) {
case msg.Code == TxMsg:
packets, traffic = propTxnInPacketsMeter, propTxnInTrafficMeter
- case msg.Code == LatticeBlockMsg:
- packets = propLatticeBlockInPacketsMeter
- traffic = propLatticeBlockInTrafficMeter
+ case msg.Code == CoreBlockMsg:
+ packets = propCoreBlockInPacketsMeter
+ traffic = propCoreBlockInTrafficMeter
case msg.Code == VoteMsg:
packets, traffic = propVoteInPacketsMeter, propVoteInTrafficMeter
case msg.Code == PullBlocksMsg:
- packets = reqLatticeBlockInPacketsMeter
- traffic = reqLatticeBlockInTrafficMeter
+ packets = reqCoreBlockInPacketsMeter
+ traffic = reqCoreBlockInTrafficMeter
case msg.Code == PullVotesMsg:
packets, traffic = reqVoteInPacketsMeter, reqVoteInTrafficMeter
@@ -167,15 +167,15 @@ func (rw *meteredMsgReadWriter) WriteMsg(msg p2p.Msg) error {
case msg.Code == TxMsg:
packets, traffic = propTxnOutPacketsMeter, propTxnOutTrafficMeter
- case msg.Code == LatticeBlockMsg:
- packets = propLatticeBlockOutPacketsMeter
- traffic = propLatticeBlockOutTrafficMeter
+ case msg.Code == CoreBlockMsg:
+ packets = propCoreBlockOutPacketsMeter
+ traffic = propCoreBlockOutTrafficMeter
case msg.Code == VoteMsg:
packets, traffic = propVoteOutPacketsMeter, propVoteOutTrafficMeter
case msg.Code == PullBlocksMsg:
- packets = reqLatticeBlockOutPacketsMeter
- traffic = reqLatticeBlockOutTrafficMeter
+ packets = reqCoreBlockOutPacketsMeter
+ traffic = reqCoreBlockOutTrafficMeter
case msg.Code == PullVotesMsg:
packets, traffic = reqVoteOutPacketsMeter, reqVoteOutTrafficMeter
diff --git a/dex/network.go b/dex/network.go
index c5f81782d..f36850e59 100644
--- a/dex/network.go
+++ b/dex/network.go
@@ -60,7 +60,7 @@ func (n *DexconNetwork) BroadcastVote(vote *types.Vote) {
// BroadcastBlock broadcasts block to all nodes in DEXON network.
func (n *DexconNetwork) BroadcastBlock(block *types.Block) {
- n.pm.BroadcastLatticeBlock(block)
+ n.pm.BroadcastCoreBlock(block)
}
// SendDKGPrivateShare sends PrivateShare to a DKG participant.
diff --git a/dex/peer.go b/dex/peer.go
index d0b81a03e..6a5786e1f 100644
--- a/dex/peer.go
+++ b/dex/peer.go
@@ -87,7 +87,7 @@ const (
// above some healthy uncle limit, so use that.
maxQueuedAnns = 4
- maxQueuedLatticeBlocks = 16
+ maxQueuedCoreBlocks = 16
maxQueuedVotes = 128
maxQueuedAgreements = 16
maxQueuedRandomnesses = 16
@@ -156,7 +156,7 @@ type peer struct {
queuedRecords chan []*enr.Record // Queue of node records to broadcast to the peer
queuedProps chan *types.Block // Queue of blocks to broadcast to the peer
queuedAnns chan *types.Block // Queue of blocks to announce to the peer
- queuedLatticeBlocks chan []*coreTypes.Block
+ queuedCoreBlocks chan []*coreTypes.Block
queuedVotes chan []*coreTypes.Vote
queuedAgreements chan *coreTypes.AgreementResult
queuedRandomnesses chan []*coreTypes.BlockRandomnessResult
@@ -184,7 +184,7 @@ func newPeer(version int, p *p2p.Peer, rw p2p.MsgReadWriter) *peer {
queuedRecords: make(chan []*enr.Record, maxQueuedRecords),
queuedProps: make(chan *types.Block, maxQueuedProps),
queuedAnns: make(chan *types.Block, maxQueuedAnns),
- queuedLatticeBlocks: make(chan []*coreTypes.Block, maxQueuedLatticeBlocks),
+ queuedCoreBlocks: make(chan []*coreTypes.Block, maxQueuedCoreBlocks),
queuedVotes: make(chan []*coreTypes.Vote, maxQueuedVotes),
queuedAgreements: make(chan *coreTypes.AgreementResult, maxQueuedAgreements),
queuedRandomnesses: make(chan []*coreTypes.BlockRandomnessResult, maxQueuedRandomnesses),
@@ -237,11 +237,11 @@ func (p *peer) broadcast() {
return
}
p.Log().Trace("Announced block", "number", block.Number(), "hash", block.Hash())
- case blocks := <-p.queuedLatticeBlocks:
- if err := p.SendLatticeBlocks(blocks); err != nil {
+ case blocks := <-p.queuedCoreBlocks:
+ if err := p.SendCoreBlocks(blocks); err != nil {
return
}
- p.Log().Trace("Broadcast lattice blocks", "count", len(blocks))
+ p.Log().Trace("Broadcast core blocks", "count", len(blocks))
case votes := <-p.queuedVotes:
if err := p.SendVotes(votes); err != nil {
return
@@ -468,15 +468,15 @@ func (p *peer) AsyncSendNewBlock(block *types.Block) {
}
}
-func (p *peer) SendLatticeBlocks(blocks []*coreTypes.Block) error {
- return p2p.Send(p.rw, LatticeBlockMsg, blocks)
+func (p *peer) SendCoreBlocks(blocks []*coreTypes.Block) error {
+ return p2p.Send(p.rw, CoreBlockMsg, blocks)
}
-func (p *peer) AsyncSendLatticeBlocks(blocks []*coreTypes.Block) {
+func (p *peer) AsyncSendCoreBlocks(blocks []*coreTypes.Block) {
select {
- case p.queuedLatticeBlocks <- blocks:
+ case p.queuedCoreBlocks <- blocks:
default:
- p.Log().Debug("Dropping lattice block propagation")
+ p.Log().Debug("Dropping core block propagation")
}
}
diff --git a/dex/protocol.go b/dex/protocol.go
index d72e95478..afa6e560d 100644
--- a/dex/protocol.go
+++ b/dex/protocol.go
@@ -84,7 +84,7 @@ const (
// Protocol messages belonging to dex/64
RecordMsg = 0x11
- LatticeBlockMsg = 0x20
+ CoreBlockMsg = 0x20
VoteMsg = 0x21
AgreementMsg = 0x22
RandomnessMsg = 0x23
diff --git a/dex/protocol_test.go b/dex/protocol_test.go
index 22281d0f2..422824559 100644
--- a/dex/protocol_test.go
+++ b/dex/protocol_test.go
@@ -316,7 +316,7 @@ func TestSendNodeRecords(t *testing.T) {
wg.Wait()
}
-func TestRecvLatticeBlocks(t *testing.T) {
+func TestRecvCoreBlocks(t *testing.T) {
pm, _ := newTestProtocolManagerMust(t, downloader.FullSync, 0, nil, nil)
p, _ := newTestPeer("peer", dex64, pm, true)
defer pm.Stop()
@@ -351,7 +351,7 @@ func TestRecvLatticeBlocks(t *testing.T) {
},
}
- if err := p2p.Send(p.app, LatticeBlockMsg, []*coreTypes.Block{&block}); err != nil {
+ if err := p2p.Send(p.app, CoreBlockMsg, []*coreTypes.Block{&block}); err != nil {
t.Fatalf("send error: %v", err)
}
@@ -367,7 +367,7 @@ func TestRecvLatticeBlocks(t *testing.T) {
}
}
-func TestSendLatticeBlocks(t *testing.T) {
+func TestSendCoreBlocks(t *testing.T) {
pm, _ := newTestProtocolManagerMust(t, downloader.FullSync, 0, nil, nil)
p, _ := newTestPeer("peer", dex64, pm, true)
defer pm.Stop()
@@ -403,12 +403,12 @@ func TestSendLatticeBlocks(t *testing.T) {
}
waitForRegister(pm, 1)
- pm.BroadcastLatticeBlock(&block)
+ pm.BroadcastCoreBlock(&block)
msg, err := p.app.ReadMsg()
if err != nil {
t.Errorf("%v: read error: %v", p.Peer, err)
- } else if msg.Code != LatticeBlockMsg {
- t.Errorf("%v: got code %d, want %d", p.Peer, msg.Code, LatticeBlockMsg)
+ } else if msg.Code != CoreBlockMsg {
+ t.Errorf("%v: got code %d, want %d", p.Peer, msg.Code, CoreBlockMsg)
}
var bs []*coreTypes.Block