mirror of https://github.com/poanetwork/gecko.git
Merge pull request #62 from ava-labs/timestamp-api-fix
Make GetBlock API method return timestamp with quotes
This commit is contained in:
commit
12aa3897b3
|
@ -8,6 +8,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/ava-labs/gecko/ids"
|
"github.com/ava-labs/gecko/ids"
|
||||||
|
"github.com/ava-labs/gecko/utils/json"
|
||||||
|
|
||||||
"github.com/ava-labs/gecko/utils/formatting"
|
"github.com/ava-labs/gecko/utils/formatting"
|
||||||
)
|
)
|
||||||
|
@ -50,10 +51,10 @@ func (s *Service) ProposeBlock(_ *http.Request, args *ProposeBlockArgs, reply *P
|
||||||
|
|
||||||
// APIBlock is the API representation of a block
|
// APIBlock is the API representation of a block
|
||||||
type APIBlock struct {
|
type APIBlock struct {
|
||||||
Timestamp int64 `json:"timestamp"` // Timestamp of most recent block
|
Timestamp json.Uint64 `json:"timestamp"` // Timestamp of most recent block
|
||||||
Data string `json:"data"` // Data in the most recent block. Base 58 repr. of 5 bytes.
|
Data string `json:"data"` // Data in the most recent block. Base 58 repr. of 5 bytes.
|
||||||
ID string `json:"id"` // String repr. of ID of the most recent block
|
ID string `json:"id"` // String repr. of ID of the most recent block
|
||||||
ParentID string `json:"parentID"` // String repr. of ID of the most recent block's parent
|
ParentID string `json:"parentID"` // String repr. of ID of the most recent block's parent
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBlockArgs are the arguments to GetBlock
|
// GetBlockArgs are the arguments to GetBlock
|
||||||
|
@ -93,7 +94,7 @@ func (s *Service) GetBlock(_ *http.Request, args *GetBlockArgs, reply *GetBlockR
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.APIBlock.ID = block.ID().String()
|
reply.APIBlock.ID = block.ID().String()
|
||||||
reply.APIBlock.Timestamp = block.Timestamp
|
reply.APIBlock.Timestamp = json.Uint64(block.Timestamp)
|
||||||
reply.APIBlock.ParentID = block.ParentID().String()
|
reply.APIBlock.ParentID = block.ParentID().String()
|
||||||
byteFormatter := formatting.CB58{Bytes: block.Data[:]}
|
byteFormatter := formatting.CB58{Bytes: block.Data[:]}
|
||||||
reply.Data = byteFormatter.String()
|
reply.Data = byteFormatter.String()
|
||||||
|
|
Loading…
Reference in New Issue