modified GetBlockByNumber and GetBlockByHash function to call getHeaderWithAuthor function

This commit is contained in:
Pratik Patil 2022-06-21 11:34:00 +05:30
parent b9d1869d95
commit b3c02842b9

View file

@ -834,6 +834,9 @@ func (s *PublicBlockChainAPI) getHeaderWithAuthor(head *types.Header) error {
func (s *PublicBlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) {
block, err := s.b.BlockByNumber(ctx, number)
if block != nil && err == nil {
if err = s.getHeaderWithAuthor(block.Header()); err != nil {
return nil, err
}
response, err := s.rpcMarshalBlock(ctx, block, true, fullTx)
if err == nil && number == rpc.PendingBlockNumber {
// Pending blocks need to nil out a few fields
@ -857,6 +860,9 @@ func (s *PublicBlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.B
func (s *PublicBlockChainAPI) GetBlockByHash(ctx context.Context, hash common.Hash, fullTx bool) (map[string]interface{}, error) {
block, err := s.b.BlockByHash(ctx, hash)
if block != nil {
if err = s.getHeaderWithAuthor(block.Header()); err != nil {
return nil, err
}
response, err := s.rpcMarshalBlock(ctx, block, true, fullTx)
// append marshalled bor transaction
if err == nil && response != nil {