@@ -365,15 +365,18 @@ func (s *PublicBlockChainAPI) GetHeaderByHash(ctx context.Context, hash common.H
365365// - When fullTx is true all transactions in the block are returned, otherwise
366366// only the transaction hash is returned.
367367func (s * PublicBlockChainAPI ) GetBlockByNumber (ctx context.Context , number rpc.BlockNumber , fullTx bool ) (map [string ]interface {}, error ) {
368+ if number == rpc .LatestBlockNumber && s .b .UsePendingState () {
369+ number = rpc .PendingBlockNumber // Use pending state for API queries if latest is requested and flag is set
370+ }
368371 block , err := s .b .BlockByNumber (ctx , number )
369372 if block != nil && err == nil {
370373 response , err := RPCMarshalETHBlock (block , true , fullTx , s .b .NodeLocation ())
371- if err == nil && number == rpc .PendingBlockNumber {
374+ /* if err == nil && number == rpc.PendingBlockNumber {
372375 // Pending blocks need to nil out a few fields
373376 for _, field := range []string{"hash", "nonce", "miner"} {
374377 response[field] = nil
375378 }
376- }
379+ }*/
377380 return response , err
378381 }
379382 return nil , err
@@ -383,6 +386,9 @@ func (s *PublicBlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.B
383386// detail, otherwise only the transaction hash is returned.
384387func (s * PublicBlockChainAPI ) GetBlockByHash (ctx context.Context , hash common.Hash , fullTx bool ) (map [string ]interface {}, error ) {
385388 block , err := s .b .BlockByHash (ctx , hash )
389+ if block == nil && s .b .UsePendingState () {
390+ block = s .b .PendingBlockByHash (hash )
391+ }
386392 if block != nil {
387393 return RPCMarshalETHBlock (block , true , fullTx , s .b .NodeLocation ())
388394 }
@@ -963,7 +969,7 @@ func RPCMarshalETHBlock(block *types.WorkObject, inclTx bool, fullTx bool, nodeL
963969 return newRPCTransactionFromBlockHash (block , tx .Hash (), false , nodeLocation ), nil
964970 }
965971 }
966- txs := block .Transactions ()
972+ txs := block .QuaiTransactions ()
967973 transactions := make ([]interface {}, len (txs ))
968974 var err error
969975 for i , tx := range txs {
@@ -1303,14 +1309,13 @@ func (s *PublicBlockChainAPI) GetTransactionReceipt(ctx context.Context, hash co
13031309 }
13041310 usePending = true
13051311 blockNumber = s .b .CurrentHeader ().NumberU64 (s .b .NodeCtx ()) + 1
1306- blockHash = common.Hash {}
13071312 } else {
13081313 return nil , nil
13091314 }
13101315 }
13111316 receipt := & types.Receipt {}
13121317 if usePending {
1313- receipt = s .b .GetPendingReceipt (hash )
1318+ receipt , blockHash = s .b .GetPendingReceipt (hash )
13141319 if receipt == nil {
13151320 return nil , nil
13161321 }
0 commit comments