@@ -67,6 +67,7 @@ type SimulatedBackend struct {
6767 stuckTransactions types.Transactions // holds onto all txes that don't go into the pending block due to low gas
6868 pendingBlock * types.Block // Currently pending block that will be imported on request
6969 pendingState * state.StateDB // Currently pending state that will be the active on request
70+ pendingReceipts types.Receipts // Currently receipts for the pending block
7071
7172 events * filters.EventSystem // Event system for filtering log events live
7273
@@ -87,8 +88,8 @@ func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.Genesis
8788 database : database ,
8889 blockchain : blockchain ,
8990 config : genesis .Config ,
90- events : filters .NewEventSystem (& filterBackend {database , blockchain }, false ),
9191 }
92+ backend .events = filters .NewEventSystem (& filterBackend {database , blockchain , backend }, false )
9293 backend .rollback (blockchain .CurrentBlock ())
9394 return backend
9495}
@@ -690,7 +691,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
690691 }
691692 var remainingTxes types.Transactions
692693 // Include tx in chain
693- blocks , _ := core .GenerateChain (b .config , block , ethash .NewFaker (), b .database , 1 , func (number int , block * core.BlockGen ) {
694+ blocks , receipts := core .GenerateChain (b .config , block , ethash .NewFaker (), b .database , 1 , func (number int , block * core.BlockGen ) {
694695 for _ , tx := range b .pendingBlock .Transactions () {
695696 // if market gas price is not set or tx gas price is lower than the set market gas price
696697 if b .marketGasPrice == nil || b .marketGasPrice .Cmp (tx .GasPrice ()) <= 0 {
@@ -711,6 +712,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
711712 b .pendingBlock = blocks [0 ]
712713 b .pendingState , _ = state .New (b .pendingBlock .Root (), stateDB .Database (), nil )
713714 b .stuckTransactions = remainingTxes
715+ b .pendingReceipts = receipts [0 ]
714716
715717 return nil
716718}
@@ -723,7 +725,7 @@ func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.Filter
723725 var filter * filters.Filter
724726 if query .BlockHash != nil {
725727 // Block filter requested, construct a single-shot filter
726- filter = filters .NewBlockFilter (& filterBackend {b .database , b .blockchain }, * query .BlockHash , query .Addresses , query .Topics )
728+ filter = filters .NewBlockFilter (& filterBackend {b .database , b .blockchain , b }, * query .BlockHash , query .Addresses , query .Topics )
727729 } else {
728730 // Initialize unset filter boundaries to run from genesis to chain head
729731 from := int64 (0 )
@@ -735,7 +737,7 @@ func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.Filter
735737 to = query .ToBlock .Int64 ()
736738 }
737739 // Construct the range filter
738- filter = filters .NewRangeFilter (& filterBackend {b .database , b .blockchain }, from , to , query .Addresses , query .Topics )
740+ filter = filters .NewRangeFilter (& filterBackend {b .database , b .blockchain , b }, from , to , query .Addresses , query .Topics )
739741 }
740742 // Run the filter and return all the logs
741743 logs , err := filter .Logs (ctx )
@@ -856,8 +858,9 @@ func (m callMsg) AccessList() types.AccessList { return m.CallMsg.AccessList }
856858// filterBackend implements filters.Backend to support filtering for logs without
857859// taking bloom-bits acceleration structures into account.
858860type filterBackend struct {
859- db ethdb.Database
860- bc * core.BlockChain
861+ db ethdb.Database
862+ bc * core.BlockChain
863+ backend * SimulatedBackend
861864}
862865
863866func (fb * filterBackend ) ChainDb () ethdb.Database { return fb .db }
@@ -874,6 +877,10 @@ func (fb *filterBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*t
874877 return fb .bc .GetHeaderByHash (hash ), nil
875878}
876879
880+ func (fb * filterBackend ) PendingBlockAndReceipts () (* types.Block , types.Receipts ) {
881+ return fb .backend .pendingBlock , fb .backend .pendingReceipts
882+ }
883+
877884func (fb * filterBackend ) GetReceipts (ctx context.Context , hash common.Hash ) (types.Receipts , error ) {
878885 number := rawdb .ReadHeaderNumber (fb .db , hash )
879886 if number == nil {
0 commit comments