mirror of https://github.com/poanetwork/gecko.git
nits
This commit is contained in:
parent
aab9005d68
commit
4ac34ad296
|
@ -18,13 +18,14 @@ type priorityQueue []*vertexItem
|
|||
|
||||
func (pq priorityQueue) Len() int { return len(pq) }
|
||||
|
||||
// Returns true if the vertex at index i has greater height than the vertex at
|
||||
// index j.
|
||||
func (pq priorityQueue) Less(i, j int) bool {
|
||||
statusI := pq[i].vertex.Status()
|
||||
statusJ := pq[j].vertex.Status()
|
||||
|
||||
// Put unknown vertices at the front of the heap to ensure
|
||||
// once we have made it below a certain height in DAG traversal
|
||||
// we do not need to reset
|
||||
// Put unknown vertices at the front of the heap to ensure once we have made
|
||||
// it below a certain height in DAG traversal we do not need to reset
|
||||
if !statusI.Fetched() {
|
||||
return true
|
||||
}
|
||||
|
@ -40,6 +41,7 @@ func (pq priorityQueue) Swap(i, j int) {
|
|||
pq[j].index = j
|
||||
}
|
||||
|
||||
// Push adds an item to this priority queue. x must have type *vertexItem
|
||||
func (pq *priorityQueue) Push(x interface{}) {
|
||||
n := len(*pq)
|
||||
item := x.(*vertexItem)
|
||||
|
@ -47,6 +49,7 @@ func (pq *priorityQueue) Push(x interface{}) {
|
|||
*pq = append(*pq, item)
|
||||
}
|
||||
|
||||
// Pop returns the last item in this priorityQueue
|
||||
func (pq *priorityQueue) Pop() interface{} {
|
||||
old := *pq
|
||||
n := len(old)
|
||||
|
@ -84,6 +87,8 @@ func (vh *maxHeightVertexHeap) Clear() {
|
|||
vh.elementIDs.Clear()
|
||||
}
|
||||
|
||||
// Push adds an element to this heap. Returns true if the element was added.
|
||||
// Returns false if it was already in the heap.
|
||||
func (vh *maxHeightVertexHeap) Push(vtx avalanche.Vertex) bool {
|
||||
vtxID := vtx.ID()
|
||||
if vh.elementIDs.Contains(vtxID) {
|
||||
|
@ -98,6 +103,9 @@ func (vh *maxHeightVertexHeap) Push(vtx avalanche.Vertex) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// If there are any vertices in this heap with status Unknown, removes one such
|
||||
// vertex and returns it. Otherwise, removes and returns the vertex in this heap
|
||||
// with the greatest height.
|
||||
func (vh *maxHeightVertexHeap) Pop() avalanche.Vertex {
|
||||
vtx := heap.Pop(vh.heap).(*vertexItem).vertex
|
||||
vh.elementIDs.Remove(vtx.ID())
|
||||
|
|
|
@ -49,7 +49,7 @@ func TestUniqueVertexHeapReturnsOrdered(t *testing.T) {
|
|||
|
||||
vtxZ := h.Pop()
|
||||
if !vtxZ.ID().Equals(vtx4.ID()) {
|
||||
t.Fatalf("Heap did not pop unknonw element first")
|
||||
t.Fatalf("Heap did not pop unknown element first")
|
||||
}
|
||||
|
||||
vtxA := h.Pop()
|
||||
|
|
|
@ -36,10 +36,10 @@ type VM interface {
|
|||
fxs []*Fx,
|
||||
) error
|
||||
|
||||
// Bootstrapping is called when the node is starting to bootstrap.
|
||||
// Bootstrapping is called when the node is starting to bootstrap this chain.
|
||||
Bootstrapping() error
|
||||
|
||||
// Bootstrapped is called when the node is exiting bootstrapping.
|
||||
// Bootstrapped is called when the node is done bootstrapping this chain.
|
||||
Bootstrapped() error
|
||||
|
||||
// Shutdown is called when the node is shutting down.
|
||||
|
|
|
@ -68,6 +68,7 @@ type VM struct {
|
|||
// State management
|
||||
state *prefixedState
|
||||
|
||||
// Set to true once this VM is marked as `Bootstrapped` by the engine
|
||||
bootstrapped bool
|
||||
|
||||
// Transaction issuing
|
||||
|
@ -200,7 +201,8 @@ func (vm *VM) Initialize(
|
|||
return vm.db.Commit()
|
||||
}
|
||||
|
||||
// Bootstrapping marks this VM as bootstrapping
|
||||
// Bootstrapping is called by the consensus engine when it starts bootstrapping
|
||||
// this chain
|
||||
func (vm *VM) Bootstrapping() error {
|
||||
for _, fx := range vm.fxs {
|
||||
if err := fx.Fx.Bootstrapping(); err != nil {
|
||||
|
@ -210,7 +212,8 @@ func (vm *VM) Bootstrapping() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Bootstrapped marks this VM as bootstrapped
|
||||
// Bootstrapped is called by the consensus engine when it is done bootstrapping
|
||||
// this chain
|
||||
func (vm *VM) Bootstrapped() error {
|
||||
for _, fx := range vm.fxs {
|
||||
if err := fx.Fx.Bootstrapped(); err != nil {
|
||||
|
|
Loading…
Reference in New Issue