Skip to content

Commit

Permalink
Revert "Excessive mutex locks were removed" and add missed defer
Browse files Browse the repository at this point in the history
This reverts commit e65d6bd and adds missed defer call.

Signed-off-by: fubss <ivanlaish@gmail.com>
  • Loading branch information
fubss committed Apr 22, 2024
1 parent e65d6bd commit d05b1e2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/ledger/kvledger/kv_ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,8 @@ func (l *kvLedger) GetTransactionByID(txID string) (*peer.ProcessedTransaction,

// GetBlockchainInfo returns basic info about blockchain
func (l *kvLedger) GetBlockchainInfo() (*common.BlockchainInfo, error) {
l.blockAPIsRWLock.RLock()
defer l.blockAPIsRWLock.RUnlock()
bcInfo, err := l.blockStore.GetBlockchainInfo()
return bcInfo, err
}
Expand All @@ -543,6 +545,8 @@ func (l *kvLedger) GetBlocksIterator(startBlockNumber uint64) (commonledger.Resu

// GetBlockByHash returns a block given it's hash
func (l *kvLedger) GetBlockByHash(blockHash []byte) (*common.Block, error) {
l.blockAPIsRWLock.RLock()
defer l.blockAPIsRWLock.RUnlock()
block, err := l.blockStore.RetrieveBlockByHash(blockHash)
return block, err
}
Expand Down Expand Up @@ -1020,6 +1024,8 @@ func (itr *blocksItr) Next() (commonledger.QueryResult, error) {
if err != nil {
return nil, err
}
itr.blockAPIsRWLock.RLock()
defer itr.blockAPIsRWLock.RUnlock()
return block, nil
}

Expand Down

0 comments on commit d05b1e2

Please sign in to comment.