OSDN Git Service

feat(warder): add warder backbone (#181)
[bytom/vapor.git] / protocol / state / blockindex.go
index 3bccd84..e2e1354 100644 (file)
@@ -97,9 +97,9 @@ type BlockIndex struct {
 // NewBlockIndex will create a empty BlockIndex
 func NewBlockIndex() *BlockIndex {
        return &BlockIndex{
-               index:     make(map[bc.Hash]*BlockNode),
+               index:       make(map[bc.Hash]*BlockNode),
                heightIndex: make(map[uint64][]*BlockNode),
-               mainChain: make([]*BlockNode, 0, approxNodesPerDay),
+               mainChain:   make([]*BlockNode, 0, approxNodesPerDay),
        }
 }
 
@@ -118,24 +118,6 @@ func (bi *BlockIndex) GetNode(hash *bc.Hash) *BlockNode {
        return bi.index[*hash]
 }
 
-// NodeByHeightInSameChain return the node of specified height
-// And the node satisfies the same chain as the node that specifies the hash 
-// Height of the block of the specified node hash must greater than height parameter
-func (bi *BlockIndex) NodeByHeightInSameChain(nodeHash *bc.Hash, height uint64) *BlockNode {
-       bi.RLock()
-       defer bi.RUnlock()
-
-       blockNode := bi.index[*nodeHash]
-       prevBlockNode := blockNode
-       for prevBlockNode != nil && prevBlockNode.Height != height {
-               if prevBlockNode.Height < height {
-                       return nil
-               }
-               prevBlockNode = bi.index[prevBlockNode.Parent.Hash]
-       }
-       return prevBlockNode
-}
-
 func (bi *BlockIndex) BestNode() *BlockNode {
        bi.RLock()
        defer bi.RUnlock()