@@ -80,6 +80,7 @@ type RetestethEthAPI interface {
80
80
SendRawTransaction (ctx context.Context , rawTx hexutil.Bytes ) (common.Hash , error )
81
81
BlockNumber (ctx context.Context ) (uint64 , error )
82
82
GetBlockByNumber (ctx context.Context , blockNr math.HexOrDecimal64 , fullTx bool ) (map [string ]interface {}, error )
83
+ GetBlockByHash (ctx context.Context , blockHash common.Hash , fullTx bool ) (map [string ]interface {}, error )
83
84
GetBalance (ctx context.Context , address common.Address , blockNr math.HexOrDecimal64 ) (* math.HexOrDecimal256 , error )
84
85
GetCode (ctx context.Context , address common.Address , blockNr math.HexOrDecimal64 ) (hexutil.Bytes , error )
85
86
GetTransactionCount (ctx context.Context , address common.Address , blockNr math.HexOrDecimal64 ) (uint64 , error )
@@ -618,6 +619,20 @@ func (api *RetestethAPI) GetBlockByNumber(ctx context.Context, blockNr math.HexO
618
619
return nil , fmt .Errorf ("block %d not found" , blockNr )
619
620
}
620
621
622
+ func (api * RetestethAPI ) GetBlockByHash (ctx context.Context , blockHash common.Hash , fullTx bool ) (map [string ]interface {}, error ) {
623
+ block := api .blockchain .GetBlockByHash (blockHash )
624
+ if block != nil {
625
+ response , err := RPCMarshalBlock (block , true , fullTx )
626
+ if err != nil {
627
+ return nil , err
628
+ }
629
+ response ["author" ] = response ["miner" ]
630
+ response ["totalDifficulty" ] = (* hexutil .Big )(api .blockchain .GetTd (block .Hash (), block .Number ().Uint64 ()))
631
+ return response , err
632
+ }
633
+ return nil , fmt .Errorf ("block 0x%x not found" , blockHash )
634
+ }
635
+
621
636
func (api * RetestethAPI ) AccountRange (ctx context.Context ,
622
637
blockHashOrNumber * math.HexOrDecimal256 , txIndex uint64 ,
623
638
addressHash * math.HexOrDecimal256 , maxResults uint64 ,
0 commit comments