diff options
author | Sonic <sonic@dexon.org> | 2019-02-11 18:59:21 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:27:22 +0800 |
commit | 3e676f603793b9996e4b44c0b525d21bee44529f (patch) | |
tree | 576386d669528910e59fdc4c93c679188f38d585 | |
parent | 30d6c027cda04c08a1216b32d9fda2e19f53f4c0 (diff) | |
download | go-tangerine-3e676f603793b9996e4b44c0b525d21bee44529f.tar go-tangerine-3e676f603793b9996e4b44c0b525d21bee44529f.tar.gz go-tangerine-3e676f603793b9996e4b44c0b525d21bee44529f.tar.bz2 go-tangerine-3e676f603793b9996e4b44c0b525d21bee44529f.tar.lz go-tangerine-3e676f603793b9996e4b44c0b525d21bee44529f.tar.xz go-tangerine-3e676f603793b9996e4b44c0b525d21bee44529f.tar.zst go-tangerine-3e676f603793b9996e4b44c0b525d21bee44529f.zip |
p2p, dex: some fixes (#189)
* p2p: try resolving direct dial when dial fail
* dex: avoid concurrent map read and map write
-rw-r--r-- | dex/peer.go | 3 | ||||
-rw-r--r-- | p2p/dial.go | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/dex/peer.go b/dex/peer.go index 67a59348d..97f42ccac 100644 --- a/dex/peer.go +++ b/dex/peer.go @@ -958,6 +958,9 @@ func (ps *peerSet) Close() { } func (ps *peerSet) BuildConnection(round uint64) { + ps.lock.Lock() + defer ps.lock.Unlock() + dkgLabel := peerLabel{set: dkgset, round: round} if _, ok := ps.label2Nodes[dkgLabel]; !ok { dkgPKs, err := ps.gov.DKGSet(round) diff --git a/p2p/dial.go b/p2p/dial.go index 99acade36..b323bdac1 100644 --- a/p2p/dial.go +++ b/p2p/dial.go @@ -323,7 +323,7 @@ func (t *dialTask) Do(srv *Server) { if err != nil { log.Trace("Dial error", "task", t, "err", err) // Try resolving the ID of static nodes if dialing failed. - if _, ok := err.(*dialError); ok && t.flags&staticDialedConn != 0 { + if _, ok := err.(*dialError); ok && t.flags&(staticDialedConn|directDialedConn) != 0 { if t.resolve(srv) { t.dial(srv, t.dest) } |