Skip to content

Commit afd09af

Browse files
feat(miner): use []*ethapi.RPCTransaction in RPC response body (#391)
1 parent 36430eb commit afd09af

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

miner/taiko_miner.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import (
66
"github.com/ethereum/go-ethereum/beacon/engine"
77
"github.com/ethereum/go-ethereum/common"
88
"github.com/ethereum/go-ethereum/core/types"
9+
"github.com/ethereum/go-ethereum/internal/ethapi"
910
)
1011

1112
// PreBuiltTxList is a pre-built transaction list based on the latest chain state,
1213
// with estimated gas used / bytes.
1314
type PreBuiltTxList struct {
14-
TxList types.Transactions
15+
TxList []*ethapi.RPCTransaction
1516
EstimatedGasUsed uint64
1617
BytesLength uint64
1718
}

miner/taiko_worker.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/ethereum/go-ethereum/core/txpool"
1616
"github.com/ethereum/go-ethereum/core/types"
1717
"github.com/ethereum/go-ethereum/core/vm"
18+
"github.com/ethereum/go-ethereum/internal/ethapi"
1819
"github.com/ethereum/go-ethereum/log"
1920
"github.com/ethereum/go-ethereum/params"
2021
"github.com/ethereum/go-ethereum/rlp"
@@ -93,7 +94,7 @@ func (w *Miner) buildTransactionsLists(
9394
}
9495

9596
return lastTransaction, &PreBuiltTxList{
96-
TxList: env.txs,
97+
TxList: w.toRPCTransactions(env.txs),
9798
EstimatedGasUsed: env.header.GasLimit - env.gasPool.Gas(),
9899
BytesLength: uint64(len(b)),
99100
}, nil
@@ -338,6 +339,15 @@ loop:
338339
return lastTransaction
339340
}
340341

342+
// toRPCTransactions converts the given transactions to RPC transactions.
343+
func (w *Miner) toRPCTransactions(txs types.Transactions) []*ethapi.RPCTransaction {
344+
var rpcTxs []*ethapi.RPCTransaction
345+
for _, tx := range txs {
346+
rpcTxs = append(rpcTxs, ethapi.NewRPCPendingTransaction(tx, nil, w.chainConfig))
347+
}
348+
return rpcTxs
349+
}
350+
341351
// encodeAndCompressTxList encodes and compresses the given transactions list.
342352
func encodeAndCompressTxList(txs types.Transactions) ([]byte, error) {
343353
b, err := rlp.EncodeToBytes(txs)

0 commit comments

Comments
 (0)