remove uncle

pull/1217/head
Richard Liu 5 years ago
parent 117ffd5039
commit 622954b538
  1. 26
      hmyclient/hmyclient.go

@ -114,30 +114,6 @@ func (c *Client) getBlock(ctx context.Context, method string, args ...interface{
if head.TxHash != types.EmptyRootHash && len(body.Transactions) == 0 {
return nil, fmt.Errorf("server returned empty transaction list but block header indicates transactions")
}
// Load uncles because they are not included in the block response.
var uncles []*types.Header
if len(body.UncleHashes) > 0 {
uncles = make([]*types.Header, len(body.UncleHashes))
reqs := make([]rpc.BatchElem, len(body.UncleHashes))
for i := range reqs {
reqs[i] = rpc.BatchElem{
Method: "eth_getUncleByBlockHashAndIndex",
Args: []interface{}{body.Hash, hexutil.EncodeUint64(uint64(i))},
Result: &uncles[i],
}
}
if err := c.c.BatchCallContext(ctx, reqs); err != nil {
return nil, err
}
for i := range reqs {
if reqs[i].Error != nil {
return nil, reqs[i].Error
}
if uncles[i] == nil {
return nil, fmt.Errorf("got null header for uncle %d of block %x", i, body.Hash[:])
}
}
}
// Fill the sender cache of transactions in the block.
txs := make([]*types.Transaction, len(body.Transactions))
for i, tx := range body.Transactions {
@ -146,7 +122,7 @@ func (c *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, []*types.Header{}), nil
}
func toBlockNumArg(number *big.Int) string {

Loading…
Cancel
Save