mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-29 04:31:44 +00:00
uint64 height (Refs #911)
This commit is contained in:
committed by
Ethan Buchman
parent
b2489b4318
commit
b3492356e6
@ -53,7 +53,7 @@ func TestBlockEvents(t *testing.T) {
|
||||
}
|
||||
|
||||
// listen for a new block; ensure height increases by 1
|
||||
var firstBlockHeight int
|
||||
var firstBlockHeight uint64
|
||||
for j := 0; j < 3; j++ {
|
||||
evtTyp := types.EventNewBlock
|
||||
evt, err := client.WaitForOneEvent(c, evtTyp, waitForEventTimeout)
|
||||
@ -67,7 +67,7 @@ func TestBlockEvents(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
|
||||
require.Equal(block.Header.Height, firstBlockHeight+j)
|
||||
require.Equal(block.Header.Height, firstBlockHeight+uint64(j))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func DefaultWaitStrategy(delta int) (abort error) {
|
||||
//
|
||||
// If waiter is nil, we use DefaultWaitStrategy, but you can also
|
||||
// provide your own implementation
|
||||
func WaitForHeight(c StatusClient, h int, waiter Waiter) error {
|
||||
func WaitForHeight(c StatusClient, h uint64, waiter Waiter) error {
|
||||
if waiter == nil {
|
||||
waiter = DefaultWaitStrategy
|
||||
}
|
||||
@ -42,7 +42,7 @@ func WaitForHeight(c StatusClient, h int, waiter Waiter) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
delta = h - s.LatestBlockHeight
|
||||
delta = int(h - s.LatestBlockHeight)
|
||||
// wait for the time, or abort early
|
||||
if err := waiter(delta); err != nil {
|
||||
return err
|
||||
|
@ -66,11 +66,11 @@ func TestWaitForHeight(t *testing.T) {
|
||||
require.Nil(pre.Error)
|
||||
prer, ok := pre.Response.(*ctypes.ResultStatus)
|
||||
require.True(ok)
|
||||
assert.Equal(10, prer.LatestBlockHeight)
|
||||
assert.Equal(uint64(10), prer.LatestBlockHeight)
|
||||
|
||||
post := r.Calls[4]
|
||||
require.Nil(post.Error)
|
||||
postr, ok := post.Response.(*ctypes.ResultStatus)
|
||||
require.True(ok)
|
||||
assert.Equal(15, postr.LatestBlockHeight)
|
||||
assert.Equal(uint64(15), postr.LatestBlockHeight)
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ func (c *HTTP) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *HTTP) BlockchainInfo(minHeight, maxHeight int) (*ctypes.ResultBlockchainInfo, error) {
|
||||
func (c *HTTP) BlockchainInfo(minHeight, maxHeight uint64) (*ctypes.ResultBlockchainInfo, error) {
|
||||
result := new(ctypes.ResultBlockchainInfo)
|
||||
_, err := c.rpc.Call("blockchain",
|
||||
map[string]interface{}{"minHeight": minHeight, "maxHeight": maxHeight},
|
||||
@ -143,7 +143,7 @@ func (c *HTTP) Genesis() (*ctypes.ResultGenesis, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *HTTP) Block(height *int) (*ctypes.ResultBlock, error) {
|
||||
func (c *HTTP) Block(height *uint64) (*ctypes.ResultBlock, error) {
|
||||
result := new(ctypes.ResultBlock)
|
||||
_, err := c.rpc.Call("block", map[string]interface{}{"height": height}, result)
|
||||
if err != nil {
|
||||
@ -152,7 +152,7 @@ func (c *HTTP) Block(height *int) (*ctypes.ResultBlock, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *HTTP) Commit(height *int) (*ctypes.ResultCommit, error) {
|
||||
func (c *HTTP) Commit(height *uint64) (*ctypes.ResultCommit, error) {
|
||||
result := new(ctypes.ResultCommit)
|
||||
_, err := c.rpc.Call("commit", map[string]interface{}{"height": height}, result)
|
||||
if err != nil {
|
||||
@ -187,7 +187,7 @@ func (c *HTTP) TxSearch(query string, prove bool) ([]*ctypes.ResultTx, error) {
|
||||
return *results, nil
|
||||
}
|
||||
|
||||
func (c *HTTP) Validators(height *int) (*ctypes.ResultValidators, error) {
|
||||
func (c *HTTP) Validators(height *uint64) (*ctypes.ResultValidators, error) {
|
||||
result := new(ctypes.ResultValidators)
|
||||
_, err := c.rpc.Call("validators", map[string]interface{}{"height": height}, result)
|
||||
if err != nil {
|
||||
|
@ -46,9 +46,9 @@ type ABCIClient interface {
|
||||
// SignClient groups together the interfaces need to get valid
|
||||
// signatures and prove anything about the chain
|
||||
type SignClient interface {
|
||||
Block(height *int) (*ctypes.ResultBlock, error)
|
||||
Commit(height *int) (*ctypes.ResultCommit, error)
|
||||
Validators(height *int) (*ctypes.ResultValidators, error)
|
||||
Block(height *uint64) (*ctypes.ResultBlock, error)
|
||||
Commit(height *uint64) (*ctypes.ResultCommit, error)
|
||||
Validators(height *uint64) (*ctypes.ResultValidators, error)
|
||||
Tx(hash []byte, prove bool) (*ctypes.ResultTx, error)
|
||||
TxSearch(query string, prove bool) ([]*ctypes.ResultTx, error)
|
||||
}
|
||||
@ -56,7 +56,7 @@ type SignClient interface {
|
||||
// HistoryClient shows us data from genesis to now in large chunks.
|
||||
type HistoryClient interface {
|
||||
Genesis() (*ctypes.ResultGenesis, error)
|
||||
BlockchainInfo(minHeight, maxHeight int) (*ctypes.ResultBlockchainInfo, error)
|
||||
BlockchainInfo(minHeight, maxHeight uint64) (*ctypes.ResultBlockchainInfo, error)
|
||||
}
|
||||
|
||||
type StatusClient interface {
|
||||
|
@ -100,7 +100,7 @@ func (Local) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) {
|
||||
return core.UnsafeDialSeeds(seeds)
|
||||
}
|
||||
|
||||
func (Local) BlockchainInfo(minHeight, maxHeight int) (*ctypes.ResultBlockchainInfo, error) {
|
||||
func (Local) BlockchainInfo(minHeight, maxHeight uint64) (*ctypes.ResultBlockchainInfo, error) {
|
||||
return core.BlockchainInfo(minHeight, maxHeight)
|
||||
}
|
||||
|
||||
@ -108,15 +108,15 @@ func (Local) Genesis() (*ctypes.ResultGenesis, error) {
|
||||
return core.Genesis()
|
||||
}
|
||||
|
||||
func (Local) Block(height *int) (*ctypes.ResultBlock, error) {
|
||||
func (Local) Block(height *uint64) (*ctypes.ResultBlock, error) {
|
||||
return core.Block(height)
|
||||
}
|
||||
|
||||
func (Local) Commit(height *int) (*ctypes.ResultCommit, error) {
|
||||
func (Local) Commit(height *uint64) (*ctypes.ResultCommit, error) {
|
||||
return core.Commit(height)
|
||||
}
|
||||
|
||||
func (Local) Validators(height *int) (*ctypes.ResultValidators, error) {
|
||||
func (Local) Validators(height *uint64) (*ctypes.ResultValidators, error) {
|
||||
return core.Validators(height)
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ func (c Client) DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) {
|
||||
return core.UnsafeDialSeeds(seeds)
|
||||
}
|
||||
|
||||
func (c Client) BlockchainInfo(minHeight, maxHeight int) (*ctypes.ResultBlockchainInfo, error) {
|
||||
func (c Client) BlockchainInfo(minHeight, maxHeight uint64) (*ctypes.ResultBlockchainInfo, error) {
|
||||
return core.BlockchainInfo(minHeight, maxHeight)
|
||||
}
|
||||
|
||||
@ -119,14 +119,14 @@ func (c Client) Genesis() (*ctypes.ResultGenesis, error) {
|
||||
return core.Genesis()
|
||||
}
|
||||
|
||||
func (c Client) Block(height *int) (*ctypes.ResultBlock, error) {
|
||||
func (c Client) Block(height *uint64) (*ctypes.ResultBlock, error) {
|
||||
return core.Block(height)
|
||||
}
|
||||
|
||||
func (c Client) Commit(height *int) (*ctypes.ResultCommit, error) {
|
||||
func (c Client) Commit(height *uint64) (*ctypes.ResultCommit, error) {
|
||||
return core.Commit(height)
|
||||
}
|
||||
|
||||
func (c Client) Validators(height *int) (*ctypes.ResultValidators, error) {
|
||||
func (c Client) Validators(height *uint64) (*ctypes.ResultValidators, error) {
|
||||
return core.Validators(height)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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"`
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user