diff options
author | Mission Liao <mission.liao@dexon.org> | 2019-02-15 14:18:59 +0800 |
---|---|---|
committer | Jimmy Hu <jimmy.hu@dexon.org> | 2019-02-19 10:48:50 +0800 |
commit | 4dbdc22e355cf1f6f0c39af1b2f3737b7527bc0c (patch) | |
tree | 625b7d34aa700d072ffb8e68dc89ed3936b76d29 /simulation/block-list.go | |
parent | e4825619fb2499f5f534537c1a4d52d3e0bcacfe (diff) | |
download | tangerine-consensus-4dbdc22e355cf1f6f0c39af1b2f3737b7527bc0c.tar.gz tangerine-consensus-4dbdc22e355cf1f6f0c39af1b2f3737b7527bc0c.tar.zst tangerine-consensus-4dbdc22e355cf1f6f0c39af1b2f3737b7527bc0c.zip |
big-bang: single chain (#446)
Diffstat (limited to 'simulation/block-list.go')
-rw-r--r-- | simulation/block-list.go | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/simulation/block-list.go b/simulation/block-list.go deleted file mode 100644 index 9e329a7..0000000 --- a/simulation/block-list.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2018 The dexon-consensus Authors -// This file is part of the dexon-consensus library. -// -// The dexon-consensus library is free software: you can redistribute it -// and/or modify it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// The dexon-consensus library is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser -// General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the dexon-consensus library. If not, see -// <http://www.gnu.org/licenses/>. - -package simulation - -import ( - "time" - - "github.com/dexon-foundation/dexon-consensus/common" -) - -// BlockList is the list of blocks from the result of Total Ordering Algorithm. -type BlockList struct { - ID int `json:"id"` - BlockHash common.Hashes `json:"blockhash"` - ConfirmLatency []time.Duration `json:"confirmlatency"` - // The index is required by heap.Interface. - index int -} - -// PendingBlockList is a PrioirtyQueue maintaining the BlockList received -// before the previous one (based on ID). -type PendingBlockList []*BlockList - -// Len, Less and Swap are implementing heap.Interface -func (p PendingBlockList) Len() int { return len(p) } -func (p PendingBlockList) Less(i, j int) bool { return p[i].ID < p[j].ID } -func (p PendingBlockList) Swap(i, j int) { - p[i], p[j] = p[j], p[i] - p[i].index = i - p[j].index = j -} - -// Push item in the Heap. -func (p *PendingBlockList) Push(x interface{}) { - n := len(*p) - item := x.(*BlockList) - item.index = n - *p = append(*p, item) -} - -// Pop the element from the Heap. -func (p *PendingBlockList) Pop() interface{} { - old := *p - n := len(old) - item := old[n-1] - item.index = -1 // For safety. - *p = old[0 : n-1] - return item -} |