From 2a341854c7dbaef696330369aada2fcf275a774c Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Tue, 25 Mar 2025 14:16:21 +0800 Subject: [PATCH] core/txpool/blobpool: prevent panic in case of nil pointer --- core/txpool/blobpool/lookup.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/txpool/blobpool/lookup.go b/core/txpool/blobpool/lookup.go index e3cfdea936..7607cd487a 100644 --- a/core/txpool/blobpool/lookup.go +++ b/core/txpool/blobpool/lookup.go @@ -50,7 +50,10 @@ func (l *lookup) exists(txhash common.Hash) bool { // storeidOfTx returns the datastore storage item id of a transaction. func (l *lookup) storeidOfTx(txhash common.Hash) (uint64, bool) { meta, ok := l.txIndex[txhash] - return meta.id, ok + if !ok { + return 0, false + } + return meta.id, true } // storeidOfBlob returns the datastore storage item id of a blob. @@ -70,7 +73,10 @@ func (l *lookup) storeidOfBlob(vhash common.Hash) (uint64, bool) { // sizeOfTx returns the RLP-encoded size of transaction func (l *lookup) sizeOfTx(txhash common.Hash) (uint64, bool) { meta, ok := l.txIndex[txhash] - return meta.size, ok + if !ok { + return 0, false + } + return meta.size, true } // track inserts a new set of mappings from blob versioned hashes to transaction