Skip to content

Commit

Permalink
ignore cache error (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Oct 30, 2024
1 parent 44ca7f5 commit 792459c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
14 changes: 3 additions & 11 deletions indexer/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,11 @@ func (e *EVMIndexerImpl) ListenFinalizeBlock(ctx context.Context, req abci.Reque
Extra: []byte{},
}

// fill parent hash
if blockHeight > 1 {
parentHeader, err := e.BlockHeaderMap.Get(sdkCtx, uint64(blockHeight-1))
if err == nil {
blockHeader.ParentHash = parentHeader.Hash()
}
}

blockHash := blockHeader.Hash()
blockLogs := make([][]*coretypes.Log, 0, len(ethTxs))
for txIndex, ethTx := range ethTxs {
for idx, ethTx := range ethTxs {
txHash := ethTx.Hash()
receipt := receipts[txIndex]
receipt := receipts[idx]

// store tx
rpcTx := rpctypes.NewRPCTransaction(ethTx, blockHash, uint64(blockHeight), uint64(receipt.TransactionIndex), chainId)
Expand All @@ -176,7 +168,7 @@ func (e *EVMIndexerImpl) ListenFinalizeBlock(ctx context.Context, req abci.Reque
log.BlockHash = blockHash
log.BlockNumber = uint64(blockHeight)
log.TxHash = txHash
log.TxIndex = uint(txIndex)
log.TxIndex = uint(receipt.TransactionIndex)
}

blockLogs = append(blockLogs, receipt.Logs)
Expand Down
15 changes: 6 additions & 9 deletions indexer/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"

corestoretypes "cosmossdk.io/core/store"
"cosmossdk.io/errors"
cachekv "cosmossdk.io/store/cachekv"
storetypes "cosmossdk.io/store/types"

Expand Down Expand Up @@ -78,10 +77,9 @@ func (c CacheStore) Set(key, value []byte) error {
storetypes.AssertValidKey(key)
storetypes.AssertValidValue(value)

err := c.cache.Set(string(key), value)
if err != nil {
return errors.Wrap(err, "failed to set cache")
}
// ignore cache error
_ = c.cache.Set(string(key), value)

c.store.Set(key, value)

return nil
Expand All @@ -91,10 +89,9 @@ func (c CacheStore) Set(key, value []byte) error {
func (c CacheStore) Delete(key []byte) error {
storetypes.AssertValidKey(key)

err := c.cache.Delete(string(key))
if err != nil && errors.IsOf(err, bigcache.ErrEntryNotFound) {
return errors.Wrap(err, "failed to delete cache")
}
// ignore cache error
_ = c.cache.Delete(string(key))

c.store.Delete(key)

return nil
Expand Down

0 comments on commit 792459c

Please sign in to comment.