func (bi *BlockIndex) LoadBlockNode(blockNodeDisk *db.BlockNodeDisk) (*BlockNode, error) {
	bi.lock.Lock()
	defer bi.lock.Unlock()
	parent := bi.getBlockNodeByHash(blockNodeDisk.Parent)
	if parent == nil && blockNodeDisk.Slot != 0 {
		return nil, ErrNoParent
	}

	newNode := &BlockNode{
		Hash:      blockNodeDisk.Hash,
		Height:    blockNodeDisk.Height,
		Slot:      blockNodeDisk.Slot,
		StateRoot: blockNodeDisk.StateRoot,
		Parent:    parent,
		Children:  make([]*BlockNode, 0),
	}

	bi.index[blockNodeDisk.Hash] = newNode

	if parent != nil {
		parent.Children = append(parent.Children, newNode)
	}

	return newNode, nil
}
// LoadBlockNode loads a block node from disk. The parent must have already been added.
LoadBlockNode loads a block node from disk. The parent must have already been added.
// LoadBlockNode loads a block node from disk . The parent must have already been added .
func (bi *BlockIndex) LoadBlockNode(blockNodeDisk *db.BlockNodeDisk) (*BlockNode, error) {
	bi.lock.Lock()
	defer bi.lock.Unlock()
	parent := bi.getBlockNodeByHash(blockNodeDisk.Parent)
	if parent == nil && blockNodeDisk.Slot != 0 {
		return nil, ErrNoParent
	}
	newNode := &BlockNode{
		Hash:      blockNodeDisk.Hash,
		Height:    blockNodeDisk.Height,
		Slot:      blockNodeDisk.Slot,
		StateRoot: blockNodeDisk.StateRoot,
		Parent:    parent,
		Children:  make([]*BlockNode, 0),
	}
	bi.index[blockNodeDisk.Hash] = newNode
	if parent != nil {
		parent.Children = append(parent.Children, newNode)
	}
	return newNode, nil
}
func ( bi * BlockIndex ) LoadBlockNode ( blockNodeDisk * db . BlockNodeDisk ) ( * BlockNode , error ) { bi . lock . Lock ( ) defer bi . lock . Unlock ( ) parent := bi . getBlockNodeByHash ( blockNodeDisk . Parent ) if parent == nil && blockNodeDisk . Slot != 0 { return nil , ErrNoParent } newNode := & BlockNode { Hash : blockNodeDisk . Hash , Height : blockNodeDisk . Height , Slot : blockNodeDisk . Slot , StateRoot : blockNodeDisk . StateRoot , Parent : parent , Children : make ( [ ] * BlockNode , 0 ) , } bi . index [ blockNodeDisk . Hash ] = newNode if parent != nil { parent . Children = append ( parent . Children , newNode ) } return newNode , nil }
LoadBlockNode loads a block node from disk.
LoadBlockNode loads a block node from disk .