Skip to content

Commit

Permalink
IS-869 Fix problem with new block removal
Browse files Browse the repository at this point in the history
  • Loading branch information
dimalit authored Oct 17, 2023
2 parents d580980 + ff99191 commit b96e9c8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions libweb3jsonrpc/Eth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ void GappedTransactionIndexCache::ensureCached( BlockNumber _bn ) const {
if ( _bn != PendingBlock && _bn != LatestBlock && real2gappedCache.count( _bn ) )
return;

assert( real2gappedCache.size() <= cacheSize );
if ( real2gappedCache.size() >= cacheSize ) {
real2gappedCache.erase( real2gappedCache.begin() );
gapped2realCache.erase( gapped2realCache.begin() );
}

// can be empty for absent blocks
h256s transactions = client.transactionHashes( _bn );

Expand All @@ -82,11 +88,6 @@ void GappedTransactionIndexCache::ensureCached( BlockNumber _bn ) const {
real2gappedCache[_bn][realIndex] = gappedIndex;

} // for

if ( real2gappedCache.size() > cacheSize ) {
real2gappedCache.erase( real2gappedCache.begin() );
gapped2realCache.erase( gapped2realCache.begin() );
}
}

bool skippedInvalidTransactionsInBlock( BlockNumber _bn, const Interface& _client ) {
Expand Down Expand Up @@ -600,7 +601,6 @@ Json::Value Eth::eth_getBlockByNumber( string const& _blockNumber, bool _include

#ifdef HISTORIC_STATE
h256 bh = client()->hashFromNumber( h );
// TODO Make it work with _blockNumber = pending!! Don't merge without this!
return eth_getBlockByHash( "0x" + bh.hex(), _includeTransactions );
} catch ( const JsonRpcException& ) {
throw;
Expand Down

0 comments on commit b96e9c8

Please sign in to comment.