diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-03-14 13:15:03 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:27:22 +0800 |
commit | 87c2523f9e2c01ccf1ff9c25a99406ee91afc646 (patch) | |
tree | c2ac2c1bd05a1986af8de3caa2f0115e5fb621a5 | |
parent | 6f3f370b317c57125f20237b4e3b7c05f888cc1c (diff) | |
download | go-tangerine-87c2523f9e2c01ccf1ff9c25a99406ee91afc646.tar go-tangerine-87c2523f9e2c01ccf1ff9c25a99406ee91afc646.tar.gz go-tangerine-87c2523f9e2c01ccf1ff9c25a99406ee91afc646.tar.bz2 go-tangerine-87c2523f9e2c01ccf1ff9c25a99406ee91afc646.tar.lz go-tangerine-87c2523f9e2c01ccf1ff9c25a99406ee91afc646.tar.xz go-tangerine-87c2523f9e2c01ccf1ff9c25a99406ee91afc646.tar.zst go-tangerine-87c2523f9e2c01ccf1ff9c25a99406ee91afc646.zip |
dex: priority for ba vote (#256)
* dex: priority select on vote
* More aggressive priority for vote
* collect all queuedVotes
-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 { |