aboutsummaryrefslogtreecommitdiffstats
path: root/dex/handler.go
diff options
context:
space:
mode:
authorSonic <sonic@cobinhood.com>2018-10-20 10:10:47 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:23:39 +0800
commit6f50d557abae1def74f0e4509711da3d33dba43c (patch)
tree66f6a43f6da96a1e616005421225bb8f102238e6 /dex/handler.go
parent45dee648b6f28f73e781f71a10561dc064327edf (diff)
downloadgo-tangerine-6f50d557abae1def74f0e4509711da3d33dba43c.tar.gz
go-tangerine-6f50d557abae1def74f0e4509711da3d33dba43c.tar.zst
go-tangerine-6f50d557abae1def74f0e4509711da3d33dba43c.zip
dex: no need to rlp encode/decode now, consensus supports it
Diffstat (limited to 'dex/handler.go')
-rw-r--r--dex/handler.go18
1 files changed, 8 insertions, 10 deletions
diff --git a/dex/handler.go b/dex/handler.go
index e9ef91fd5..ce6a0366c 100644
--- a/dex/handler.go
+++ b/dex/handler.go
@@ -709,11 +709,11 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
}
pm.nodeTable.Add(metas)
case msg.Code == LatticeBlockMsg:
- var rb rlpLatticeBlock
- if err := msg.Decode(&rb); err != nil {
+ var block coreTypes.Block
+ if err := msg.Decode(&block); err != nil {
return errResp(ErrDecode, "msg %v: %v", msg, err)
}
- pm.receiveCh <- fromRLPLatticeBlock(&rb)
+ pm.receiveCh <- &block
case msg.Code == VoteMsg:
var vote coreTypes.Vote
if err := msg.Decode(&vote); err != nil {
@@ -736,11 +736,11 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
pm.receiveCh <- &randomness
case msg.Code == DKGPrivateShareMsg:
// Do not relay this msg
- var rps rlpDKGPrivateShare
- if err := msg.Decode(&rps); err != nil {
+ var ps coreTypes.DKGPrivateShare
+ if err := msg.Decode(&ps); err != nil {
return errResp(ErrDecode, "msg %v: %v", msg, err)
}
- pm.receiveCh <- fromRLPDKGPrivateShare(&rps)
+ pm.receiveCh <- &ps
case msg.Code == DKGPartialSignatureMsg:
// broadcast in DKG set
var psig coreTypes.DKGPartialSignature
@@ -826,8 +826,7 @@ func (pm *ProtocolManager) BroadcastMetas(metas []*NodeMeta) {
// TODO(sonic): block size is big, try not to send to all peers
// to reduce traffic
func (pm *ProtocolManager) BroadcastLatticeBlock(block *coreTypes.Block) {
- hash := rlpHash(toRLPLatticeBlock(block))
- for _, peer := range pm.peers.PeersWithoutLatticeBlock(hash) {
+ for _, peer := range pm.peers.PeersWithoutLatticeBlock(rlpHash(block)) {
peer.AsyncSendLatticeBlock(block)
}
}
@@ -893,9 +892,8 @@ func (pm *ProtocolManager) SendDKGPrivateShare(
func (pm *ProtocolManager) BroadcastDKGPrivateShare(
privateShare *coreTypes.DKGPrivateShare) {
label := peerLabel{set: dkgset, round: privateShare.Round}
- h := rlpHash(toRLPDKGPrivateShare(privateShare))
for _, peer := range pm.peers.PeersWithLabel(label) {
- if !peer.knownDKGPrivateShares.Contains(h) {
+ if !peer.knownDKGPrivateShares.Contains(rlpHash(privateShare)) {
peer.AsyncSendDKGPrivateShare(privateShare)
}
}