diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-03-14 13:15:03 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:58 +0800 |
commit | 691ec7093534274f45dcb939f31807fba8fe5038 (patch) | |
tree | 06ece07deedf6d4e5cae4680bec1eb071602dd9e | |
parent | b11d655eb5dc4c7997f1bf24a0b6800a5826ce97 (diff) | |
download | dexon-691ec7093534274f45dcb939f31807fba8fe5038.tar dexon-691ec7093534274f45dcb939f31807fba8fe5038.tar.gz dexon-691ec7093534274f45dcb939f31807fba8fe5038.tar.bz2 dexon-691ec7093534274f45dcb939f31807fba8fe5038.tar.lz dexon-691ec7093534274f45dcb939f31807fba8fe5038.tar.xz dexon-691ec7093534274f45dcb939f31807fba8fe5038.tar.zst dexon-691ec7093534274f45dcb939f31807fba8fe5038.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 { |