Skip to content

Commit 0e4a762

Browse files
committed
rename block fields in api
1 parent 0b14f58 commit 0e4a762

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

internal/common/block.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ type Block struct {
3535
// BlockModel represents a simplified Block structure for Swagger documentation
3636
type BlockModel struct {
3737
ChainId string `json:"chain_id"`
38-
Number uint64 `json:"number"`
39-
Hash string `json:"hash"`
38+
BlockNumber uint64 `json:"block_number"`
39+
BlockHash string `json:"block_hash"`
4040
ParentHash string `json:"parent_hash"`
41-
Timestamp uint64 `json:"timestamp"`
41+
BlockTimestamp uint64 `json:"block_timestamp"`
4242
Nonce string `json:"nonce"`
4343
Sha3Uncles string `json:"sha3_uncles"`
4444
MixHash string `json:"mix_hash"`
@@ -76,10 +76,10 @@ type RawBlock = map[string]interface{}
7676
func (b *Block) Serialize() BlockModel {
7777
return BlockModel{
7878
ChainId: b.ChainId.String(),
79-
Number: b.Number.Uint64(),
80-
Hash: b.Hash,
79+
BlockNumber: b.Number.Uint64(),
80+
BlockHash: b.Hash,
8181
ParentHash: b.ParentHash,
82-
Timestamp: uint64(b.Timestamp.Unix()),
82+
BlockTimestamp: uint64(b.Timestamp.Unix()),
8383
Nonce: b.Nonce,
8484
Sha3Uncles: b.Sha3Uncles,
8585
MixHash: b.MixHash,

internal/handlers/search_handlers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ func TestSearch_BlockNumber(t *testing.T) {
5959
err := json.Unmarshal(w.Body.Bytes(), &response)
6060
assert.NoError(t, err)
6161
assert.Equal(t, SearchResultTypeBlock, response.Data.Type)
62-
assert.Equal(t, blockNumber.Uint64(), response.Data.Blocks[0].Number)
63-
assert.Equal(t, "0xabc", response.Data.Blocks[0].Hash)
62+
assert.Equal(t, blockNumber.Uint64(), response.Data.Blocks[0].BlockNumber)
63+
assert.Equal(t, "0xabc", response.Data.Blocks[0].BlockHash)
6464

6565
mockStorage.AssertExpectations(t)
6666
}

0 commit comments

Comments
 (0)