aboutsummaryrefslogtreecommitdiffstats
path: root/core/total-ordering.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-09-03 10:01:40 +0800
committerGitHub <noreply@github.com>2018-09-03 10:01:40 +0800
commitc8d3092208f73ee991a123052a71b7dbf7fffc27 (patch)
treefdcb3b90b859531e042dbbdd6bcd7b0cca40e86a /core/total-ordering.go
parent9491ddae81640e04f8aed38e2cddeb64cc62d55b (diff)
downloaddexon-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar
dexon-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.gz
dexon-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.bz2
dexon-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.lz
dexon-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.xz
dexon-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.tar.zst
dexon-consensus-c8d3092208f73ee991a123052a71b7dbf7fffc27.zip
core: Add a new structure `Position` and move `ShardID`, `ChainID` and `Height` from `Block` (#89)
Diffstat (limited to 'core/total-ordering.go')
-rw-r--r--core/total-ordering.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/core/total-ordering.go b/core/total-ordering.go
index 1edccdf..3c1c23e 100644
--- a/core/total-ordering.go
+++ b/core/total-ordering.go
@@ -300,10 +300,10 @@ func (v *totalOrderingCandidateInfo) addBlock(
rec := v.ackedStatus[proposerIndex]
if rec.count == 0 {
- rec.minHeight = b.Height
+ rec.minHeight = b.Position.Height
rec.count = 1
} else {
- if b.Height < rec.minHeight {
+ if b.Position.Height < rec.minHeight {
err = ErrNotValidDAG
return
}
@@ -489,7 +489,7 @@ func (global *totalOrderingGlobalVector) addBlock(
blocksFromProposer := global.blocks[proposerIndex]
if len(blocksFromProposer) > 0 {
lastBlock := blocksFromProposer[len(blocksFromProposer)-1]
- if b.Height-lastBlock.Height != 1 {
+ if b.Position.Height-lastBlock.Position.Height != 1 {
err = ErrNotValidDAG
return
}
@@ -516,7 +516,7 @@ func (global *totalOrderingGlobalVector) updateCandidateInfo(
continue
}
rec = info.ackedStatus[idx]
- rec.minHeight = blocks[0].Height
+ rec.minHeight = blocks[0].Position.Height
rec.count = uint64(len(blocks))
}
global.cachedCandidateInfo = info
@@ -529,7 +529,7 @@ func (global *totalOrderingGlobalVector) updateCandidateInfo(
continue
}
rec = info.ackedStatus[idx]
- rec.minHeight = blocks[0].Height
+ rec.minHeight = blocks[0].Position.Height
rec.count = uint64(len(blocks))
}
}
@@ -716,7 +716,7 @@ func (to *totalOrdering) prepareCandidate(
sort.Ints(to.allocatedCandidateSlotIndexes)
info.ackedStatus[proposerIndex] = &totalOrderingHeightRecord{
- minHeight: candidate.Height,
+ minHeight: candidate.Position.Height,
count: uint64(len(to.globalVector.blocks[proposerIndex])),
}
ackedsForCandidate, exists := to.acked[candidate.Hash]
@@ -736,7 +736,7 @@ func (to *totalOrdering) prepareCandidate(
// If this block acks this candidate, all newer blocks
// from the same validator also 'indirect' acks it.
rec = info.ackedStatus[idx]
- rec.minHeight = b.Height
+ rec.minHeight = b.Position.Height
rec.count = uint64(len(blocks) - i)
break
}