Skip to content

Commit dbf1710

Browse files
committed
Build transaction context in BlockRes
1 parent 88f2a96 commit dbf1710

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

‎rpc/responses.go‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,20 @@ func NewBlockRes(block *types.Block, fullTx bool) *BlockRes {
5555
// res.MinGasPrice =
5656
res.GasUsed = newHexNum(block.GasUsed())
5757
res.UnixTimestamp = newHexNum(block.Time())
58-
res.Transactions = NewTransactionsRes(block.Transactions())
58+
59+
res.Transactions = make([]*TransactionRes, len(block.Transactions()))
60+
for i, tx := range block.Transactions() {
61+
res.Transactions[i] = NewTransactionRes(tx)
62+
res.Transactions[i].BlockHash = res.BlockHash
63+
res.Transactions[i].BlockNumber = res.BlockNumber
64+
res.Transactions[i].TxIndex = newHexNum(i)
65+
}
66+
5967
res.Uncles = make([]*hexdata, len(block.Uncles()))
6068
for i, uncle := range block.Uncles() {
6169
res.Uncles[i] = newHexData(uncle.Hash())
6270
}
71+
6372
return res
6473
}
6574

@@ -94,14 +103,6 @@ func NewTransactionRes(tx *types.Transaction) *TransactionRes {
94103
return v
95104
}
96105

97-
func NewTransactionsRes(txs []*types.Transaction) []*TransactionRes {
98-
v := make([]*TransactionRes, len(txs))
99-
for i, tx := range txs {
100-
v[i] = NewTransactionRes(tx)
101-
}
102-
return v
103-
}
104-
105106
// type FilterLogRes struct {
106107
// Hash string `json:"hash"`
107108
// Address string `json:"address"`

0 commit comments

Comments
 (0)