forked from cerc-io/ipld-eth-server
adapt uncle retrieval methods to work for v5
This commit is contained in:
+11
-33
@@ -374,21 +374,11 @@ func (b *Backend) BlockByHash(ctx context.Context, hash common.Hash) (*types.Blo
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// When num. of uncles = 2,
|
||||
// Check if calculated uncle hash matches the one in header
|
||||
// If not, re-order the two uncles
|
||||
// Assumption: Max num. of uncles in mainnet = 2
|
||||
if len(uncles) == 2 {
|
||||
uncleHash := types.CalcUncleHash(uncles)
|
||||
if uncleHash != header.UncleHash {
|
||||
uncles[0], uncles[1] = uncles[1], uncles[0]
|
||||
|
||||
uncleHash = types.CalcUncleHash(uncles)
|
||||
// Check if uncle hash matches after re-ordering
|
||||
if uncleHash != header.UncleHash {
|
||||
log.Error("uncle hash mismatch for block hash: ", hash.Hex())
|
||||
}
|
||||
}
|
||||
// We should not have any non-determinism in the ordering of the uncles returned to us now
|
||||
uncleHash := types.CalcUncleHash(uncles)
|
||||
// Check if uncle hash matches expected hash
|
||||
if uncleHash != header.UncleHash {
|
||||
log.Error("uncle hash mismatch for block hash: ", hash.Hex())
|
||||
}
|
||||
|
||||
// Fetch transactions
|
||||
@@ -427,15 +417,9 @@ func (b *Backend) GetUnclesByBlockHash(tx *sqlx.Tx, hash common.Hash) ([]*types.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
uncles := make([]*types.Header, len(uncleBytes))
|
||||
for i, bytes := range uncleBytes {
|
||||
var uncle types.Header
|
||||
err = rlp.DecodeBytes(bytes, &uncle)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
uncles[i] = &uncle
|
||||
uncles := make([]*types.Header, 0)
|
||||
if err := rlp.DecodeBytes(uncleBytes, uncles); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return uncles, nil
|
||||
@@ -448,15 +432,9 @@ func (b *Backend) GetUnclesByBlockHashAndNumber(tx *sqlx.Tx, hash common.Hash, n
|
||||
return nil, err
|
||||
}
|
||||
|
||||
uncles := make([]*types.Header, len(uncleBytes))
|
||||
for i, bytes := range uncleBytes {
|
||||
var uncle types.Header
|
||||
err = rlp.DecodeBytes(bytes, &uncle)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
uncles[i] = &uncle
|
||||
uncles := make([]*types.Header, 0)
|
||||
if err := rlp.DecodeBytes(uncleBytes, uncles); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return uncles, nil
|
||||
|
||||
Reference in New Issue
Block a user