add fullTx option

This commit is contained in:
Sina Mahmoodi 2024-05-28 21:50:26 +02:00
parent e3827828fd
commit 9139685944
2 changed files with 7 additions and 5 deletions

View file

@ -1241,7 +1241,7 @@ func (s *BlockChainAPI) SimulateV1(ctx context.Context, opts simOpts, blockNrOrH
if state == nil || err != nil { if state == nil || err != nil {
return nil, err return nil, err
} }
sim := &simulator{b: s.b, state: state, base: base, traceTransfers: opts.TraceTransfers, validate: opts.Validation} sim := &simulator{b: s.b, state: state, base: base, traceTransfers: opts.TraceTransfers, validate: opts.Validation, fullTx: opts.ReturnFullTransactions}
return sim.execute(ctx, opts.BlockStateCalls) return sim.execute(ctx, opts.BlockStateCalls)
} }

View file

@ -71,6 +71,7 @@ type simOpts struct {
BlockStateCalls []simBlock BlockStateCalls []simBlock
TraceTransfers bool TraceTransfers bool
Validation bool Validation bool
ReturnFullTransactions bool
} }
type simulator struct { type simulator struct {
@ -80,6 +81,7 @@ type simulator struct {
base *types.Header base *types.Header
traceTransfers bool traceTransfers bool
validate bool validate bool
fullTx bool
} }
func (sim *simulator) execute(ctx context.Context, blocks []simBlock) ([]map[string]interface{}, error) { func (sim *simulator) execute(ctx context.Context, blocks []simBlock) ([]map[string]interface{}, error) {
@ -233,7 +235,7 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
withdrawals = make([]*types.Withdrawal, 0) withdrawals = make([]*types.Withdrawal, 0)
} }
b := types.NewBlockWithWithdrawals(header, txes, nil, receipts, withdrawals, trie.NewStackTrie(nil)) b := types.NewBlockWithWithdrawals(header, txes, nil, receipts, withdrawals, trie.NewStackTrie(nil))
res := RPCMarshalBlock(b, true, false, config) res := RPCMarshalBlock(b, true, sim.fullTx, config)
repairLogs(callResults, res["hash"].(common.Hash)) repairLogs(callResults, res["hash"].(common.Hash))
res["calls"] = callResults res["calls"] = callResults