Skip to content

Commit 38c73eb

Browse files
will-20122020xibao
authored andcommitted
feat: add millisecond to rpc field (#273)
Co-authored-by: 2020xibao <2020xibao@gmail.com>
1 parent e3c8da3 commit 38c73eb

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

internal/ethapi/api.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,7 @@ func RPCMarshalBlock(ctx context.Context, block *types.Block, inclTx bool, fullT
14201420
func (s *BlockChainAPI) rpcMarshalHeader(ctx context.Context, header *types.Header) map[string]interface{} {
14211421
fields := RPCMarshalHeader(header)
14221422
fields["totalDifficulty"] = (*hexutil.Big)(s.b.GetTd(ctx, header.Hash()))
1423+
fields["milliTimestamp"] = hexutil.Uint64(header.MilliTimestamp())
14231424
return fields
14241425
}
14251426

@@ -1432,6 +1433,7 @@ func (s *BlockChainAPI) rpcMarshalBlock(ctx context.Context, b *types.Block, inc
14321433
}
14331434
if inclTx {
14341435
fields["totalDifficulty"] = (*hexutil.Big)(s.b.GetTd(ctx, b.Hash()))
1436+
fields["milliTimestamp"] = hexutil.Uint64(b.Header().MilliTimestamp())
14351437
}
14361438
return fields, nil
14371439
}

internal/ethapi/api_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,10 @@ func TestRPCGetBlockOrHeader(t *testing.T) {
19591959
continue
19601960
}
19611961

1962+
if result != nil {
1963+
delete(result, "milliTimestamp")
1964+
}
1965+
19621966
testRPCResponseWithFile(t, i, result, rpc, tt.file)
19631967
}
19641968
}

0 commit comments

Comments
 (0)