diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-03-14 13:15:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-14 13:15:03 +0800 |
commit | 0a48465e804c4a2a7ab81fd381bac3a105a41f01 (patch) | |
tree | 5e2432691db942f76a37030cb0c11f44de17102e /dex/peer.go | |
parent | b8ce12b428d44e28f94a44948efdabb9352563d8 (diff) | |
download | dexon-0a48465e804c4a2a7ab81fd381bac3a105a41f01.tar.gz dexon-0a48465e804c4a2a7ab81fd381bac3a105a41f01.tar.zst dexon-0a48465e804c4a2a7ab81fd381bac3a105a41f01.zip |
dex: priority for ba vote (#256)
* dex: priority select on vote
* More aggressive priority for vote
* collect all queuedVotes
Diffstat (limited to 'dex/peer.go')
-rw-r--r-- | dex/peer.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/dex/peer.go b/dex/peer.go index 64798aaaf..d0b81a03e 100644 --- a/dex/peer.go +++ b/dex/peer.go @@ -201,7 +201,24 @@ func newPeer(version int, p *p2p.Peer, rw p2p.MsgReadWriter) *peer { // transaction and notary node records broadcasts into the remote peer. // The goal is to have an async writer that does not lock up node internals. func (p *peer) broadcast() { + queuedVotes := make([]*coreTypes.Vote, 0, maxQueuedVotes) for { + PriorityBroadcastVote: + for { + select { + case votes := <-p.queuedVotes: + queuedVotes = append(queuedVotes, votes...) + default: + break PriorityBroadcastVote + } + } + if len(queuedVotes) != 0 { + if err := p.SendVotes(queuedVotes); err != nil { + return + } + p.Log().Trace("Broadcast votes", "count", len(queuedVotes)) + queuedVotes = queuedVotes[:0] + } select { case records := <-p.queuedRecords: if err := p.SendNodeRecords(records); err != nil { |