diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-04-09 16:47:03 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-15 22:09:55 +0800 |
commit | a4113280621ff1d3954430376ae6254a4e754ab0 (patch) | |
tree | c709e52d6111057ac3cc445e25dc21bb3cf9abeb /vendor/github.com | |
parent | 6c638ddfa6223d575819f9d4bdeb846da8fbe219 (diff) | |
download | go-tangerine-a4113280621ff1d3954430376ae6254a4e754ab0.tar.gz go-tangerine-a4113280621ff1d3954430376ae6254a4e754ab0.tar.zst go-tangerine-a4113280621ff1d3954430376ae6254a4e754ab0.zip |
vendor: sync to latest core
Diffstat (limited to 'vendor/github.com')
-rw-r--r-- | vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go index f1a383bb3..966c70aaa 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go @@ -264,8 +264,9 @@ func (recv *consensusBAReceiver) ConfirmBlock( } IDs = append(IDs, ID) psigs = append(psigs, vote.PartialSignature) + } else { + voteList = append(voteList, *vote) } - voteList = append(voteList, *vote) } if block.Position.Round >= DKGDelayRound { rand, err := cryptoDKG.RecoverSignature(psigs, IDs) @@ -289,7 +290,9 @@ func (recv *consensusBAReceiver) ConfirmBlock( Randomness: block.Randomness, } // touchAgreementResult does not support concurrent access. - recv.consensus.msgChan <- (*selfAgreementResult)(result) + go func() { + recv.consensus.priorityMsgChan <- (*selfAgreementResult)(result) + }() recv.consensus.logger.Debug("Broadcast AgreementResult", "result", result) recv.consensus.network.BroadcastAgreementResult(result) @@ -518,6 +521,7 @@ type Consensus struct { logger common.Logger resetDeliveryGuardTicker chan struct{} msgChan chan interface{} + priorityMsgChan chan interface{} waitGroup sync.WaitGroup processBlockChan chan *types.Block @@ -679,6 +683,7 @@ func newConsensusForRound( logger: logger, resetDeliveryGuardTicker: make(chan struct{}), msgChan: make(chan interface{}, 1024), + priorityMsgChan: make(chan interface{}, 1024), processBlockChan: make(chan *types.Block, 1024), } con.ctx, con.ctxCancel = context.WithCancel(context.Background()) @@ -1223,9 +1228,16 @@ MessageLoop: } var msg interface{} select { - case msg = <-con.msgChan: - case <-con.ctx.Done(): - return + case msg = <-con.priorityMsgChan: + default: + } + if msg == nil { + select { + case msg = <-con.msgChan: + case msg = <-con.priorityMsgChan: + case <-con.ctx.Done(): + return + } } switch val := msg.(type) { case *selfAgreementResult: |