mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-20 05:41:35 +00:00
parent
773b513213
commit
76dd02eed4
1 changed files with 8 additions and 2 deletions
|
|
@ -131,7 +131,7 @@ func (ec *Client) BlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumb
|
|||
}
|
||||
|
||||
type rpcBlock struct {
|
||||
Hash common.Hash `json:"hash"`
|
||||
Hash *common.Hash `json:"hash"`
|
||||
Transactions []rpcTransaction `json:"transactions"`
|
||||
UncleHashes []common.Hash `json:"uncles"`
|
||||
}
|
||||
|
|
@ -157,6 +157,12 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface
|
|||
if err := json.Unmarshal(raw, &body); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Pending blocks don't return a block hash, compute it for sender caching.
|
||||
if body.Hash == nil {
|
||||
tmp := head.Hash()
|
||||
body.Hash = &tmp
|
||||
}
|
||||
|
||||
// Quick-verify transaction and uncle lists. This mostly helps with debugging the server.
|
||||
if head.UncleHash == types.EmptyUncleHash && len(body.UncleHashes) > 0 {
|
||||
return nil, errors.New("server returned non-empty uncle list but block header indicates no uncles")
|
||||
|
|
@ -198,7 +204,7 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface
|
|||
txs := make([]*types.Transaction, len(body.Transactions))
|
||||
for i, tx := range body.Transactions {
|
||||
if tx.From != nil {
|
||||
setSenderFromServer(tx.tx, *tx.From, body.Hash)
|
||||
setSenderFromServer(tx.tx, *tx.From, *body.Hash)
|
||||
}
|
||||
txs[i] = tx.tx
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue