aboutsummaryrefslogtreecommitdiffstats
path: root/dex/peer.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-03-14 13:15:03 +0800
committerGitHub <noreply@github.com>2019-03-14 13:15:03 +0800
commit0a48465e804c4a2a7ab81fd381bac3a105a41f01 (patch)
tree5e2432691db942f76a37030cb0c11f44de17102e /dex/peer.go
parentb8ce12b428d44e28f94a44948efdabb9352563d8 (diff)
downloaddexon-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.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 {