aboutsummaryrefslogtreecommitdiffstats
path: root/dex/peer.go
diff options
context:
space:
mode:
authorSonic <sonic@cobinhood.com>2018-10-16 17:01:19 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:50 +0800
commitcbc8f1ac578845341b02563210184ff849c38c22 (patch)
tree9aadf4c8bcb68677eb4c6a6be60ed4d553b1c870 /dex/peer.go
parentf380e368335fa323d3f914943ceb077f4413d5a3 (diff)
downloaddexon-cbc8f1ac578845341b02563210184ff849c38c22.tar.gz
dexon-cbc8f1ac578845341b02563210184ff849c38c22.tar.zst
dexon-cbc8f1ac578845341b02563210184ff849c38c22.zip
dex: implement peerSetLoop
Diffstat (limited to 'dex/peer.go')
-rw-r--r--dex/peer.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/dex/peer.go b/dex/peer.go
index 342d0f033..1f2b9518d 100644
--- a/dex/peer.go
+++ b/dex/peer.go
@@ -778,6 +778,7 @@ func (ps *peerSet) Close() {
func (ps *peerSet) BuildNotaryConn(round uint64) {
ps.lock.Lock()
defer ps.lock.Unlock()
+ defer ps.dumpPeerLabel(fmt.Sprintf("BuildNotaryConn: %d", round))
if _, ok := ps.notaryHistory[round]; ok {
return
@@ -816,9 +817,21 @@ func (ps *peerSet) BuildNotaryConn(round uint64) {
}
}
+func (ps *peerSet) dumpPeerLabel(s string) {
+ log.Trace(s, "peer num", len(ps.peers))
+ for id, labels := range ps.peer2Labels {
+ _, ok := ps.peers[id]
+ for label := range labels {
+ log.Trace(s, "connected", ok, "id", id[:16],
+ "round", label.round, "cid", label.chainID, "set", label.set)
+ }
+ }
+}
+
func (ps *peerSet) ForgetNotaryConn(round uint64) {
ps.lock.Lock()
defer ps.lock.Unlock()
+ defer ps.dumpPeerLabel(fmt.Sprintf("ForgetNotaryConn: %d", round))
// forget all the rounds before the given round
for r := range ps.notaryHistory {
@@ -862,6 +875,7 @@ func notarySetName(chainID uint32, round uint64) string {
func (ps *peerSet) BuildDKGConn(round uint64) {
ps.lock.Lock()
defer ps.lock.Unlock()
+ defer ps.dumpPeerLabel(fmt.Sprintf("BuildDKGConn: %d", round))
selfID := ps.srvr.Self().ID.String()
s, err := ps.gov.DKGSet(round)
if err != nil {
@@ -886,6 +900,7 @@ func (ps *peerSet) BuildDKGConn(round uint64) {
func (ps *peerSet) ForgetDKGConn(round uint64) {
ps.lock.Lock()
defer ps.lock.Unlock()
+ defer ps.dumpPeerLabel(fmt.Sprintf("ForgetDKGConn: %d", round))
// forget all the rounds before the given round
for r := range ps.dkgHistory {
@@ -919,6 +934,7 @@ func (ps *peerSet) forgetDKGConn(round uint64) {
// make sure the ps.lock is hold
func (ps *peerSet) addDirectPeer(id string, label peerLabel) {
+ log.Trace("peerSet addDirectPeer", "id", id[:8], "round", label.round, "cid", label.chainID)
// if the peer exists add the label
if p, ok := ps.peers[id]; ok {
p.addLabel(label)