parent
c20de3c4bd
commit
3ccd6b6dbb
@ -599,13 +599,12 @@ func (b *Block) BaseFeePerGas(ctx context.Context) (*hexutil.Big, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Block) Parent(ctx context.Context) (*Block, error) {
|
func (b *Block) Parent(ctx context.Context) (*Block, error) {
|
||||||
// If the block header hasn't been fetched, and we'll need it, fetch it.
|
|
||||||
if b.numberOrHash == nil && b.header == nil {
|
|
||||||
if _, err := b.resolveHeader(ctx); err != nil {
|
if _, err := b.resolveHeader(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if b.header == nil || b.header.Number.Uint64() < 1 {
|
||||||
|
return nil, nil
|
||||||
}
|
}
|
||||||
if b.header != nil && b.header.Number.Uint64() > 0 {
|
|
||||||
num := rpc.BlockNumberOrHashWithNumber(rpc.BlockNumber(b.header.Number.Uint64() - 1))
|
num := rpc.BlockNumberOrHashWithNumber(rpc.BlockNumber(b.header.Number.Uint64() - 1))
|
||||||
return &Block{
|
return &Block{
|
||||||
backend: b.backend,
|
backend: b.backend,
|
||||||
@ -613,8 +612,6 @@ func (b *Block) Parent(ctx context.Context) (*Block, error) {
|
|||||||
hash: b.header.ParentHash,
|
hash: b.header.ParentHash,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *Block) Difficulty(ctx context.Context) (hexutil.Big, error) {
|
func (b *Block) Difficulty(ctx context.Context) (hexutil.Big, error) {
|
||||||
header, err := b.resolveHeader(ctx)
|
header, err := b.resolveHeader(ctx)
|
||||||
|
Loading…
Reference in New Issue
Block a user