aboutsummaryrefslogtreecommitdiffstats
path: root/dex/peer.go
diff options
context:
space:
mode:
authorSonic <sonic@cobinhood.com>2018-10-16 10:33:24 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:23:39 +0800
commite5137c6582c1ffb6943842aed88b3a31a31c34f1 (patch)
treeb0d24a70b69d429e7c4a95de1fb3852aafd7fb5a /dex/peer.go
parent16f356dcf34722510c59a1f946a5ffa138bd6da7 (diff)
downloadgo-tangerine-e5137c6582c1ffb6943842aed88b3a31a31c34f1.tar
go-tangerine-e5137c6582c1ffb6943842aed88b3a31a31c34f1.tar.gz
go-tangerine-e5137c6582c1ffb6943842aed88b3a31a31c34f1.tar.bz2
go-tangerine-e5137c6582c1ffb6943842aed88b3a31a31c34f1.tar.lz
go-tangerine-e5137c6582c1ffb6943842aed88b3a31a31c34f1.tar.xz
go-tangerine-e5137c6582c1ffb6943842aed88b3a31a31c34f1.tar.zst
go-tangerine-e5137c6582c1ffb6943842aed88b3a31a31c34f1.zip
dex: gov: using dex-consensus-core NodeSetCache
Diffstat (limited to 'dex/peer.go')
-rw-r--r--dex/peer.go28
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
}