Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ONT-927 optimize sync block msg send #404

Merged
merged 1 commit into from
Jun 26, 2018
Merged

ONT-927 optimize sync block msg send #404

merged 1 commit into from
Jun 26, 2018

Conversation

xiemylogos
Copy link
Contributor

No description provided.

@@ -400,7 +401,7 @@ func (self *PeerSyncer) requestBlock(blkNum uint32) (*Block, error) {
return nil, err
}
self.server.msgSendC <- &SendMsgEvent{
ToPeer: self.peerIdx,
ToPeer: math.MaxUint32,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if only broadcasting support, consider fix this in self.server.msgSendC handling??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. I will delete some unused code,like send to peer function.

@@ -266,3 +268,17 @@ func (pool *PeerPool) getPeer(idx uint32) *Peer {

return nil
}

func (pool *PeerPool) addP2pId(peerIdx uint32, p2pId uint64) {
pool.lock.RLock()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need Lock

if !present {
self.peerPool.addP2pId(peerIdx, payload.PeerId)
} else {
if p2pid != payload.PeerId {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use if !present || p2pid != payload.PeerId

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

self.peerPool.addP2pId(peerIdx, payload.PeerId)
}
}
self.peerPool.addP2pId(peerIdx, payload.PeerId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant ?

@laizy laizy merged commit 46d4192 into ontio:master Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants