Skip to content

Commit

Permalink
tx index optimized
Browse files Browse the repository at this point in the history
Checking duplicate txIds  by block metadata   instead of querying goleveldb;

from FAB-15865

Signed-off-by: XuHugo <xq-310@163.com>
  • Loading branch information
XuHugo committed Jan 28, 2021
1 parent 738b405 commit 90dbefc
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions common/ledger/blkstorage/fsblkstorage/blockindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,17 @@ func (index *blockIndex) isAttributeIndexed(attribute blkstorage.IndexableAttr)

func (index *blockIndex) markDuplicateTxids(blockIdxInfo *blockIdxInfo) error {
uniqueTxids := make(map[string]bool)
for _, txIdxInfo := range blockIdxInfo.txOffsets {
txflg := ledgerUtil.TxValidationFlags(blockIdxInfo.metadata.Metadata[common.BlockMetadataIndex_TRANSACTIONS_FILTER])
for idx, txIdxInfo := range blockIdxInfo.txOffsets {
txid := txIdxInfo.txID
if uniqueTxids[txid] { // txid is duplicate of a previous tx in the block
txIdxInfo.isDuplicate = true
continue
}

loc, err := index.getTxLoc(txid)
if loc != nil { // txid is duplicate of a previous tx in the index
if txflg.Flag(idx) == peer.TxValidationCode_DUPLICATE_TXID{
txIdxInfo.isDuplicate = true
continue
}
if err != blkstorage.ErrNotFoundInIndex {
return err
}
uniqueTxids[txid] = true
}
return nil
Expand Down

0 comments on commit 90dbefc

Please sign in to comment.