OSDN Git Service

modify function name
authoroys <oys@oysdeMBP.localdomain>
Wed, 19 Jun 2019 02:17:51 +0000 (10:17 +0800)
committeroys <oys@oysdeMBP.localdomain>
Wed, 19 Jun 2019 02:17:51 +0000 (10:17 +0800)
database/store.go
protocol/bbft.go
protocol/store.go

index 38b4f03..a627a8d 100644 (file)
@@ -124,8 +124,8 @@ func GetBlockHashByHeight(db dbm.DB, height uint64) (*bc.Hash, error) {
        return hash, nil
 }
 
-// GetBlockHeightIndex return block hashes by given height
-func GetBlockHeightIndex(db dbm.DB, height uint64) ([]*bc.Hash, error) {
+// GetBlockHashesByHeight return block hashes by given height
+func GetBlockHashesByHeight(db dbm.DB, height uint64) ([]*bc.Hash, error) {
        binaryHashes := db.Get(calcblockHeightIndexPrefix(height))
        if binaryHashes == nil {
                return nil, fmt.Errorf("There are no block hashes with given height %s", height)
@@ -187,7 +187,7 @@ func NewStore(db dbm.DB) *Store {
        }
 
        fillHeightIndexFn := func(height uint64) ([]*bc.Hash, error) {
-               return GetBlockHeightIndex(db, height)
+               return GetBlockHashesByHeight(db, height)
        }
 
        fillMainChainHashFn := func(height uint64) (*bc.Hash, error) {
@@ -276,8 +276,8 @@ func (s *Store) GetBlockHashByHeight(height uint64) (*bc.Hash, error) {
        return s.blockIndex.GetBlockHashByHeight(height)
 }
 
-// GetBlockHeightIndex return the block hash by the specified height
-func (s *Store) GetBlockHeightIndex(height uint64) ([]*bc.Hash, error) {
+// GetBlockHashesByHeight return the block hash by the specified height
+func (s *Store) GetBlockHashesByHeight(height uint64) ([]*bc.Hash, error) {
        return s.blockIndex.GetBlockHashesByHeight(height)
 }
 
index eb5180d..026c0a4 100644 (file)
@@ -160,7 +160,7 @@ func (c *Chain) checkNodeSign(bh *types.BlockHeader, consensusNode *state.Consen
                return errInvalidSignature
        }
 
-       blockHashes, err := c.consensusNodeManager.store.GetBlockHeightIndex(bh.Height)
+       blockHashes, err := c.consensusNodeManager.store.GetBlockHashesByHeight(bh.Height)
        if err != nil {
                return err
        }
@@ -205,7 +205,7 @@ func (c *Chain) SignBlock(block *types.Block) ([]byte, error) {
        c.cond.L.Lock()
        defer c.cond.L.Unlock()
        //check double sign in same block height
-       blockHashes, err := c.consensusNodeManager.store.GetBlockHeightIndex(block.Height)
+       blockHashes, err := c.consensusNodeManager.store.GetBlockHashesByHeight(block.Height)
        if err != nil {
                return nil, err
        }
index 3720acc..df536d4 100644 (file)
@@ -26,7 +26,7 @@ type Store interface {
        GetVoteResult(uint64) (*state.VoteResult, error)
 
        GetBlockHashByHeight(uint64) (*bc.Hash, error)
-       GetBlockHeightIndex(uint64) ([]*bc.Hash, error)
+       GetBlockHashesByHeight(uint64) ([]*bc.Hash, error)
        GetBlockNode(*bc.Hash) (*state.BlockNode, error)
        SaveBlock(*types.Block, *bc.TransactionStatus) error
        SaveBlockHeader(*types.BlockHeader) error