Open
Conversation
e0516bd to
0e82bd8
Compare
laizy
reviewed
Sep 19, 2017
|
|
||
| func (al *KnownAddressList) RandGetAddresses(nbrAddrs []NodeAddr) []NodeAddr { | ||
| var keys []uint64 | ||
| for k := range al.List { |
Contributor
There was a problem hiding this comment.
- missing lock here.
- maybe it is better to directly copy out the address instead of the key to avoid unnecessary existence check in the latter code.
| ka.srcAddr.ID = na.ID | ||
| } | ||
|
|
||
| func (ka *KnownAddress) NetAddress() NodeAddr { |
Contributor
There was a problem hiding this comment.
use NodeAddr directly or type KnownAddress NodeAddr to avoid redundant code ?
Contributor
Author
There was a problem hiding this comment.
This structure will add other members in next version.
1. When receive address message save the addresses in address list. 2. If the connection is less than MaxOutboundCnt, select addresses from address list and connect them. 3. When receive getaddr request, randomly select some address and send addr response. At most send 8 address. Signed-off-by: Jin Qing <1091147665@qq.com>
If the connection is less than MaxOutboundCnt, the node will pick peers from address list and connect them. So we don't need reconnect now. Signed-off-by: Jin Qing <1091147665@qq.com>
If the connection more than max connect peers, disconnect one node. Signed-off-by: Jin Qing <1091147665@qq.com>
If address list less than 1000 send getaddr request Signed-off-by: Jin Qing <1091147665@qq.com>
laizy
reviewed
Sep 30, 2017
| func (ka *KnownAddress) updateLastDisconnect() { | ||
| // set last disconnect time to now | ||
| ka.lastattempt = time.Now() | ||
| } |
Contributor
There was a problem hiding this comment.
It seems that the upper two function signatures have opposite function body.
Judge whether the peer is bad before connect it. If it is bad won't connect it. Signed-off-by: Jin Qing <1091147665@qq.com>
Honglei-Cong
pushed a commit
to Honglei-Cong/DNA
that referenced
this pull request
Nov 27, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If receive getaddr request, randomly select some address and send addr response. At most send 8 address.
When receive addr message, save the addresses in address list