aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-03-14 13:15:03 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 13:50:04 +0800
commit3bafc3d2ffe8bfc194fb225f2bc138afac5af3b0 (patch)
treeb61aead807a874c199794b606be3f44345482ac9
parentf7f54422e9f5ae177a6732e28c32cf7d73cfb1aa (diff)
downloaddexon-3bafc3d2ffe8bfc194fb225f2bc138afac5af3b0.tar
dexon-3bafc3d2ffe8bfc194fb225f2bc138afac5af3b0.tar.gz
dexon-3bafc3d2ffe8bfc194fb225f2bc138afac5af3b0.tar.bz2
dexon-3bafc3d2ffe8bfc194fb225f2bc138afac5af3b0.tar.lz
dexon-3bafc3d2ffe8bfc194fb225f2bc138afac5af3b0.tar.xz
dexon-3bafc3d2ffe8bfc194fb225f2bc138afac5af3b0.tar.zst
dexon-3bafc3d2ffe8bfc194fb225f2bc138afac5af3b0.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.go17
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 {