aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/dexon-consensus/core/total-ordering.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-01-04 16:24:26 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:21 +0800
commit9a8e616df90409e1a94b7843d1ceddcf010bc11b (patch)
tree9ee2a492ea8c5406bf7df078b1b2f028af1d65a7 /vendor/github.com/dexon-foundation/dexon-consensus/core/total-ordering.go
parentb92aa8f1590c3ecb1e2fe8ba12a5092ca190786c (diff)
downloadgo-tangerine-9a8e616df90409e1a94b7843d1ceddcf010bc11b.tar.gz
go-tangerine-9a8e616df90409e1a94b7843d1ceddcf010bc11b.tar.zst
go-tangerine-9a8e616df90409e1a94b7843d1ceddcf010bc11b.zip
vendor: sync to latest core (#125)
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/total-ordering.go')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/total-ordering.go26
1 files changed, 15 insertions, 11 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/total-ordering.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/total-ordering.go
index 744471a84..de8dd0bb7 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/total-ordering.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/total-ordering.go
@@ -1159,14 +1159,11 @@ CheckNextCandidateLoop:
}
// flushBlocks flushes blocks.
-func (to *totalOrdering) flushBlocks(
- b *types.Block) (flushed []*types.Block, mode uint32, err error) {
-
+func (to *totalOrdering) flushBlocks() (
+ flushed []*types.Block, mode uint32, err error) {
mode = TotalOrderingModeFlush
cfg := to.getCurrentConfig()
- if cfg.isLastBlock(b) {
- to.flushReadyChains[b.Position.ChainID] = struct{}{}
- }
+
// Flush blocks until last blocks from all chains appeared.
if len(to.flushReadyChains) < int(cfg.numChains) {
return
@@ -1281,9 +1278,8 @@ func (to *totalOrdering) getCurrentConfig() *totalOrderingConfig {
return to.configs[cfgIdx]
}
-// processBlock is the entry point of totalOrdering.
-func (to *totalOrdering) processBlock(
- b *types.Block) ([]*types.Block, uint32, error) {
+// addBlock adds a block to the working set of total ordering module.
+func (to *totalOrdering) addBlock(b *types.Block) error {
// NOTE: Block b is assumed to be in topologically sorted, i.e., all its
// acking blocks are during or after total ordering stage.
cfg := to.getCurrentConfig()
@@ -1291,7 +1287,7 @@ func (to *totalOrdering) processBlock(
to.buildBlockRelation(b)
isOldest, err := to.updateVectors(b)
if err != nil {
- return nil, uint32(0), err
+ return err
}
// Mark the proposer of incoming block as dirty.
if b.Position.ChainID < cfg.numChains {
@@ -1310,8 +1306,16 @@ func (to *totalOrdering) processBlock(
to.prepareCandidate(b)
}
}
+ if to.duringFlush && cfg.isLastBlock(b) {
+ to.flushReadyChains[b.Position.ChainID] = struct{}{}
+ }
+ return nil
+}
+
+// extractBlocks check if there is any deliverable set.
+func (to *totalOrdering) extractBlocks() ([]*types.Block, uint32, error) {
if to.duringFlush {
- return to.flushBlocks(b)
+ return to.flushBlocks()
}
return to.deliverBlocks()
}