mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-16 18:00:46 +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 {
|
type rpcBlock struct {
|
||||||
Hash common.Hash `json:"hash"`
|
Hash *common.Hash `json:"hash"`
|
||||||
Transactions []rpcTransaction `json:"transactions"`
|
Transactions []rpcTransaction `json:"transactions"`
|
||||||
UncleHashes []common.Hash `json:"uncles"`
|
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 {
|
if err := json.Unmarshal(raw, &body); err != nil {
|
||||||
return nil, err
|
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.
|
// Quick-verify transaction and uncle lists. This mostly helps with debugging the server.
|
||||||
if head.UncleHash == types.EmptyUncleHash && len(body.UncleHashes) > 0 {
|
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")
|
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))
|
txs := make([]*types.Transaction, len(body.Transactions))
|
||||||
for i, tx := range body.Transactions {
|
for i, tx := range body.Transactions {
|
||||||
if tx.From != nil {
|
if tx.From != nil {
|
||||||
setSenderFromServer(tx.tx, *tx.From, body.Hash)
|
setSenderFromServer(tx.tx, *tx.From, *body.Hash)
|
||||||
}
|
}
|
||||||
txs[i] = tx.tx
|
txs[i] = tx.tx
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue