@@ -61,9 +61,10 @@ type SimulatedBackend struct {
6161 database ethdb.Database // In memory database to store our testing data
6262 blockchain * core.BlockChain // Ethereum blockchain to handle the consensus
6363
64- mu sync.Mutex
65- pendingBlock * types.Block // Currently pending block that will be imported on request
66- pendingState * state.StateDB // Currently pending state that will be the active on on request
64+ mu sync.Mutex
65+ pendingBlock * types.Block // Currently pending block that will be imported on request
66+ pendingState * state.StateDB // Currently pending state that will be the active on request
67+ pendingReceipts types.Receipts // Currently receipts for the pending block
6768
6869 events * filters.EventSystem // Event system for filtering log events live
6970
@@ -126,8 +127,8 @@ func NewXDCSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64, chainConfi
126127 database : database ,
127128 blockchain : blockchain ,
128129 config : genesis .Config ,
129- events : filters .NewEventSystem (& filterBackend {database , blockchain }, false ),
130130 }
131+ backend .events = filters .NewEventSystem (& filterBackend {database , blockchain , backend }, false )
131132 blockchain .Client = backend
132133 backend .rollback ()
133134 return backend
@@ -146,8 +147,8 @@ func NewSimulatedBackend(alloc core.GenesisAlloc) *SimulatedBackend {
146147 database : database ,
147148 blockchain : blockchain ,
148149 config : genesis .Config ,
149- events : filters .NewEventSystem (& filterBackend {database , blockchain }, false ),
150150 }
151+ backend .events = filters .NewEventSystem (& filterBackend {database , blockchain , backend }, false )
151152 backend .rollback ()
152153 return backend
153154}
@@ -421,7 +422,7 @@ func (b *SimulatedBackend) FilterLogs(ctx context.Context, query XDPoSChain.Filt
421422 var filter * filters.Filter
422423 if query .BlockHash != nil {
423424 // Block filter requested, construct a single-shot filter
424- filter = filters .NewBlockFilter (& filterBackend {b .database , b .blockchain }, * query .BlockHash , query .Addresses , query .Topics )
425+ filter = filters .NewBlockFilter (& filterBackend {b .database , b .blockchain , b }, * query .BlockHash , query .Addresses , query .Topics )
425426 } else {
426427 // Initialize unset filter boundaried to run from genesis to chain head
427428 from := int64 (0 )
@@ -433,7 +434,7 @@ func (b *SimulatedBackend) FilterLogs(ctx context.Context, query XDPoSChain.Filt
433434 to = query .ToBlock .Int64 ()
434435 }
435436 // Construct the range filter
436- filter = filters .NewRangeFilter (& filterBackend {b .database , b .blockchain }, from , to , query .Addresses , query .Topics )
437+ filter = filters .NewRangeFilter (& filterBackend {b .database , b .blockchain , b }, from , to , query .Addresses , query .Topics )
437438 }
438439 // Run the filter and return all the logs
439440 logs , err := filter .Logs (ctx )
@@ -523,8 +524,9 @@ func (m callMsg) AccessList() types.AccessList { return m.CallMsg.AccessList }
523524// filterBackend implements filters.Backend to support filtering for logs without
524525// taking bloom-bits acceleration structures into account.
525526type filterBackend struct {
526- db ethdb.Database
527- bc * core.BlockChain
527+ db ethdb.Database
528+ bc * core.BlockChain
529+ backend * SimulatedBackend
528530}
529531
530532func (fb * filterBackend ) ChainDb () ethdb.Database { return fb .db }
@@ -545,6 +547,10 @@ func (fb *filterBackend) GetReceipts(ctx context.Context, hash common.Hash) (typ
545547 return core .GetBlockReceipts (fb .db , hash , core .GetBlockNumber (fb .db , hash )), nil
546548}
547549
550+ func (fb * filterBackend ) PendingBlockAndReceipts () (* types.Block , types.Receipts ) {
551+ return fb .backend .pendingBlock , fb .backend .pendingReceipts
552+ }
553+
548554func (fb * filterBackend ) GetLogs (ctx context.Context , hash common.Hash ) ([][]* types.Log , error ) {
549555 receipts := core .GetBlockReceipts (fb .db , hash , core .GetBlockNumber (fb .db , hash ))
550556 if receipts == nil {
0 commit comments