Skip to content

Commit

Permalink
ethclient: include withdrawals in ethclient block responses (ethereum…
Browse files Browse the repository at this point in the history
…#26778)

* include withdrawals in ethclient responses

* omit empty withdrawals array in json serialization
  • Loading branch information
peterbitfly authored and mmsqe committed Dec 7, 2023
1 parent 550b7c0 commit b005119
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ethclient/ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ func (ec *Client) PeerCount(ctx context.Context) (uint64, error) {
}

type rpcBlock struct {
Hash common.Hash `json:"hash"`
Transactions []rpcTransaction `json:"transactions"`
UncleHashes []common.Hash `json:"uncles"`
Hash common.Hash `json:"hash"`
Transactions []rpcTransaction `json:"transactions"`
UncleHashes []common.Hash `json:"uncles"`
Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"`
}

func (ec *Client) getBlock(ctx context.Context, method string, args ...interface{}) (*types.Block, error) {
Expand Down Expand Up @@ -169,7 +170,7 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface
}
txs[i] = tx.tx
}
return types.NewBlockWithHeader(head).WithBody(txs, uncles), nil
return types.NewBlockWithHeader(head).WithBody(txs, uncles).WithWithdrawals(body.Withdrawals), nil
}

// HeaderByHash returns the block header with the given hash.
Expand Down

0 comments on commit b005119

Please sign in to comment.