mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
internal/era: fix rlp decode of header and correctly read total difficulty
This commit is contained in:
parent
67defc417c
commit
e9cb2074d3
2 changed files with 5 additions and 4 deletions
|
|
@ -181,7 +181,7 @@ func (e *Era) InitialTD() (*big.Int, error) {
|
|||
if r, n, err = newSnappyReader(e.s, TypeCompressedHeader, off); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rlp.Decode(r, header); err != nil {
|
||||
if err := rlp.Decode(r, &header); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
off += n
|
||||
|
|
@ -199,7 +199,8 @@ func (e *Era) InitialTD() (*big.Int, error) {
|
|||
if r, _, err = e.s.ReaderAt(TypeTotalDifficulty, off); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rlp.Decode(r, rawTd); err != nil {
|
||||
rawTd, err = io.ReadAll(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
td := new(big.Int).SetBytes(reverseOrder(rawTd))
|
||||
|
|
|
|||
|
|
@ -103,8 +103,8 @@ func (it *Iterator) BlockAndReceipts() (*types.Block, types.Receipts, error) {
|
|||
// TotalDifficulty returns the total difficulty for the iterator's current
|
||||
// position.
|
||||
func (it *Iterator) TotalDifficulty() (*big.Int, error) {
|
||||
var td []byte
|
||||
if err := rlp.Decode(it.inner.TotalDifficulty, td); err != nil {
|
||||
td, err := io.ReadAll(it.inner.TotalDifficulty)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return new(big.Int).SetBytes(reverseOrder(td)), nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue