aboutsummaryrefslogtreecommitdiffstats
path: root/core/types/block.go
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-10-18 15:00:27 +0800
committerhaoping-ku <37325897+haoping-ku@users.noreply.github.com>2018-10-18 15:00:27 +0800
commit43299221c586bfb55e225799aedc6d133ba97c3f (patch)
treee607424430237698c4eb8f33e186643fc5849ca6 /core/types/block.go
parent8303e9d054957195717f41804a456e2720b0c4bb (diff)
downloaddexon-consensus-43299221c586bfb55e225799aedc6d133ba97c3f.tar
dexon-consensus-43299221c586bfb55e225799aedc6d133ba97c3f.tar.gz
dexon-consensus-43299221c586bfb55e225799aedc6d133ba97c3f.tar.bz2
dexon-consensus-43299221c586bfb55e225799aedc6d133ba97c3f.tar.lz
dexon-consensus-43299221c586bfb55e225799aedc6d133ba97c3f.tar.xz
dexon-consensus-43299221c586bfb55e225799aedc6d133ba97c3f.tar.zst
dexon-consensus-43299221c586bfb55e225799aedc6d133ba97c3f.zip
core: total ordering flush (#212)
* Implement flush * Panic for all errors from total-ordering * Fix test failure All DAGs generated by blocks-generator would trigger round switching. * Add NewBlocksGeneratorConfig * Add test caes for numChains changes * Resize internal structures * Perform total ordering based on current numChains * Fix not a valid DAG checking * Comparing blocks by height is not correct * Fix blocks from future round are delivered first by revealer * Make sure only picking one candidate in one chain. Blocks on the same chain in different rounds would not have acking relation. * Fix stuffs * Fix the issue that two candidates from the same chain are picked. * Rework candidateChainMapping * Add test case for phi, k changed * Refine testing code for round change * Add breakpoints in global vector * Remove not a valid dag checking. * Adding comments * Add check to forward acking * Fix vet failure * Prepareing height record with breakpoint * Fixup: add check to make sure delivered round IDs are increasing.
Diffstat (limited to 'core/types/block.go')
-rw-r--r--core/types/block.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/core/types/block.go b/core/types/block.go
index e384f95..63bcec4 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -146,31 +146,31 @@ func (b ByHash) Swap(i int, j int) {
b[i], b[j] = b[j], b[i]
}
-// ByHeight is the helper type for sorting slice of blocks by height.
-type ByHeight []*Block
+// ByPosition is the helper type for sorting slice of blocks by position.
+type ByPosition []*Block
// Len implements Len method in sort.Sort interface.
-func (bs ByHeight) Len() int {
+func (bs ByPosition) Len() int {
return len(bs)
}
// Less implements Less method in sort.Sort interface.
-func (bs ByHeight) Less(i int, j int) bool {
- return bs[i].Position.Height < bs[j].Position.Height
+func (bs ByPosition) Less(i int, j int) bool {
+ return bs[j].Position.Newer(&bs[i].Position)
}
// Swap implements Swap method in sort.Sort interface.
-func (bs ByHeight) Swap(i int, j int) {
+func (bs ByPosition) Swap(i int, j int) {
bs[i], bs[j] = bs[j], bs[i]
}
// Push implements Push method in heap interface.
-func (bs *ByHeight) Push(x interface{}) {
+func (bs *ByPosition) Push(x interface{}) {
*bs = append(*bs, x.(*Block))
}
// Pop implements Pop method in heap interface.
-func (bs *ByHeight) Pop() (ret interface{}) {
+func (bs *ByPosition) Pop() (ret interface{}) {
n := len(*bs)
*bs, ret = (*bs)[0:n-1], (*bs)[n-1]
return