uint64 height (Refs #911)

This commit is contained in:
Anton Kaliaev
2017-11-30 13:08:38 -06:00
committed by Ethan Buchman
parent b2489b4318
commit b3492356e6
64 changed files with 296 additions and 270 deletions

View File

@@ -61,16 +61,16 @@ import (
// ```
//
// <aside class="notice">Returns at most 20 items.</aside>
func BlockchainInfo(minHeight, maxHeight int) (*ctypes.ResultBlockchainInfo, error) {
func BlockchainInfo(minHeight, maxHeight uint64) (*ctypes.ResultBlockchainInfo, error) {
if maxHeight == 0 {
maxHeight = blockStore.Height()
} else {
maxHeight = cmn.MinInt(blockStore.Height(), maxHeight)
maxHeight = cmn.MinUint64(blockStore.Height(), maxHeight)
}
if minHeight == 0 {
minHeight = cmn.MaxInt(1, maxHeight-20)
minHeight = cmn.MaxUint64(1, maxHeight-20)
} else {
minHeight = cmn.MaxInt(minHeight, maxHeight-20)
minHeight = cmn.MaxUint64(minHeight, maxHeight-20)
}
logger.Debug("BlockchainInfoHandler", "maxHeight", maxHeight, "minHeight", minHeight)
@@ -184,7 +184,7 @@ func BlockchainInfo(minHeight, maxHeight int) (*ctypes.ResultBlockchainInfo, err
// "jsonrpc": "2.0"
// }
// ```
func Block(heightPtr *int) (*ctypes.ResultBlock, error) {
func Block(heightPtr *uint64) (*ctypes.ResultBlock, error) {
if heightPtr == nil {
height := blockStore.Height()
blockMeta := blockStore.LoadBlockMeta(height)
@@ -275,7 +275,7 @@ func Block(heightPtr *int) (*ctypes.ResultBlock, error) {
// "jsonrpc": "2.0"
// }
// ```
func Commit(heightPtr *int) (*ctypes.ResultCommit, error) {
func Commit(heightPtr *uint64) (*ctypes.ResultCommit, error) {
if heightPtr == nil {
height := blockStore.Height()
header := blockStore.LoadBlockMeta(height).Header

View File

@@ -42,7 +42,7 @@ import (
// "jsonrpc": "2.0"
// }
// ```
func Validators(heightPtr *int) (*ctypes.ResultValidators, error) {
func Validators(heightPtr *uint64) (*ctypes.ResultValidators, error) {
if heightPtr == nil {
blockHeight, validators := consensusState.GetValidators()
return &ctypes.ResultValidators{blockHeight, validators}, nil

View File

@@ -21,7 +21,7 @@ var subscribeTimeout = 5 * time.Second
type Consensus interface {
GetState() *sm.State
GetValidators() (int, []*types.Validator)
GetValidators() (uint64, []*types.Validator)
GetRoundState() *cstypes.RoundState
}

View File

@@ -84,7 +84,7 @@ func Tx(hash []byte, prove bool) (*ctypes.ResultTx, error) {
}
height := r.Height
index := r.Index
index := int(r.Index) // XXX:overflow
var proof types.TxProof
if prove {

View File

@@ -12,7 +12,7 @@ import (
)
type ResultBlockchainInfo struct {
LastHeight int `json:"last_height"`
LastHeight uint64 `json:"last_height"`
BlockMetas []*types.BlockMeta `json:"block_metas"`
}
@@ -51,7 +51,7 @@ type ResultStatus struct {
PubKey crypto.PubKey `json:"pub_key"`
LatestBlockHash data.Bytes `json:"latest_block_hash"`
LatestAppHash data.Bytes `json:"latest_app_hash"`
LatestBlockHeight int `json:"latest_block_height"`
LatestBlockHeight uint64 `json:"latest_block_height"`
LatestBlockTime int64 `json:"latest_block_time"` // nano
Syncing bool `json:"syncing"`
}
@@ -86,7 +86,7 @@ type Peer struct {
}
type ResultValidators struct {
BlockHeight int `json:"block_height"`
BlockHeight uint64 `json:"block_height"`
Validators []*types.Validator `json:"validators"`
}