diff options
author | Sonic <sonic@cobinhood.com> | 2018-10-16 10:33:24 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:50 +0800 |
commit | 04838f384450658d678e44c0f902c0eed9cd04bd (patch) | |
tree | 53d0acae28f78ab024fd3a6d19089ddafd138cbb /dex/peer.go | |
parent | 8a2cd037f77716cf83d17b9cfe8831c81427b91e (diff) | |
download | go-tangerine-04838f384450658d678e44c0f902c0eed9cd04bd.tar go-tangerine-04838f384450658d678e44c0f902c0eed9cd04bd.tar.gz go-tangerine-04838f384450658d678e44c0f902c0eed9cd04bd.tar.bz2 go-tangerine-04838f384450658d678e44c0f902c0eed9cd04bd.tar.lz go-tangerine-04838f384450658d678e44c0f902c0eed9cd04bd.tar.xz go-tangerine-04838f384450658d678e44c0f902c0eed9cd04bd.tar.zst go-tangerine-04838f384450658d678e44c0f902c0eed9cd04bd.zip |
dex: gov: using dex-consensus-core NodeSetCache
Diffstat (limited to 'dex/peer.go')
-rw-r--r-- | dex/peer.go | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/dex/peer.go b/dex/peer.go index 44f61354c..342d0f033 100644 --- a/dex/peer.go +++ b/dex/peer.go @@ -27,6 +27,7 @@ import ( coreTypes "github.com/dexon-foundation/dexon-consensus-core/core/types" "github.com/dexon-foundation/dexon/common" "github.com/dexon-foundation/dexon/core/types" + "github.com/dexon-foundation/dexon/log" "github.com/dexon-foundation/dexon/p2p" "github.com/dexon-foundation/dexon/p2p/discover" "github.com/dexon-foundation/dexon/rlp" @@ -786,7 +787,12 @@ func (ps *peerSet) BuildNotaryConn(round uint64) { selfID := ps.srvr.Self().ID.String() for chainID := uint32(0); chainID < ps.gov.GetNumChains(round); chainID++ { - s := ps.gov.NotarySet(chainID, round) + s, err := ps.gov.NotarySet(round, chainID) + if err != nil { + log.Error("get notary set fail", + "round", round, "chain id", chainID, "err", err) + continue + } // not in notary set, add group if _, ok := s[selfID]; !ok { @@ -826,7 +832,12 @@ func (ps *peerSet) ForgetNotaryConn(round uint64) { func (ps *peerSet) forgetNotaryConn(round uint64) { selfID := ps.srvr.Self().ID.String() for chainID := uint32(0); chainID < ps.gov.GetNumChains(round); chainID++ { - s := ps.gov.NotarySet(chainID, round) + s, err := ps.gov.NotarySet(round, chainID) + if err != nil { + log.Error("get notary set fail", + "round", round, "chain id", chainID, "err", err) + continue + } if _, ok := s[selfID]; !ok { ps.srvr.RemoveGroup(notarySetName(chainID, round)) continue @@ -852,7 +863,12 @@ func (ps *peerSet) BuildDKGConn(round uint64) { ps.lock.Lock() defer ps.lock.Unlock() selfID := ps.srvr.Self().ID.String() - s := ps.gov.DKGSet(round) + s, err := ps.gov.DKGSet(round) + if err != nil { + log.Error("get dkg set fail", "round", round) + return + } + if _, ok := s[selfID]; !ok { return } @@ -882,7 +898,11 @@ func (ps *peerSet) ForgetDKGConn(round uint64) { func (ps *peerSet) forgetDKGConn(round uint64) { selfID := ps.srvr.Self().ID.String() - s := ps.gov.DKGSet(round) + s, err := ps.gov.DKGSet(round) + if err != nil { + log.Error("get dkg set fail", "round", round) + return + } if _, ok := s[selfID]; !ok { return } |