@@ -3,6 +3,7 @@ package backendwrapper
3
3
import (
4
4
"context"
5
5
"encoding/json"
6
+ "errors"
6
7
"fmt"
7
8
"math/big"
8
9
"reflect"
@@ -44,10 +45,16 @@ type Backend struct {
44
45
removedLogsOnce sync.Once
45
46
chainConfig * params.ChainConfig
46
47
}
47
- // TODO AR review addition of db to backend type
48
48
49
49
func NewBackend (b ethapi.Backend ) * Backend {
50
- return & Backend {b : b }
50
+ state , _ , err := b .StateAndHeaderByNumber (context .Background (), 0 )
51
+ if err != nil {
52
+ panic (err .Error ())
53
+ }
54
+ return & Backend {
55
+ b : b ,
56
+ db : state .Database (),
57
+ }
51
58
}
52
59
53
60
func (b * Backend ) SuggestGasTipCap (ctx context.Context ) (* big.Int , error ) {
@@ -125,14 +132,16 @@ func (b *Backend) SendTx(ctx context.Context, signedTx []byte) error {
125
132
return b .b .SendTx (ctx , tx )
126
133
}
127
134
func (b * Backend ) GetTransaction (ctx context.Context , txHash core.Hash ) ([]byte , core.Hash , uint64 , uint64 , error ) { // RLP Encoded transaction {
128
- _ , tx , blockHash , blockNumber , index , err := b .b .GetTransaction (ctx , common .Hash (txHash ))
135
+ found , tx , blockHash , blockNumber , index , err := b .b .GetTransaction (ctx , common .Hash (txHash ))
129
136
if err != nil {
130
137
return nil , core .Hash (blockHash ), blockNumber , index , err
131
138
}
139
+ if ! found {
140
+ return nil , core .Hash (blockHash ), blockNumber , index , errors .New ("not found returned from GetTransaction" )
141
+ }
132
142
enc , err := tx .MarshalBinary ()
133
143
return enc , core .Hash (blockHash ), blockNumber , index , err
134
144
}
135
- // TODO AR the above internal function signature needs review
136
145
func (b * Backend ) GetPoolTransactions () ([][]byte , error ) {
137
146
txs , err := b .b .GetPoolTransactions ()
138
147
if err != nil {
0 commit comments