mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-09 11:31:19 +00:00
change delta's type from int to int64
This commit is contained in:
parent
cd5a5d332f
commit
d41c0b10c8
@ -10,11 +10,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Waiter is informed of current height, decided whether to quit early
|
// Waiter is informed of current height, decided whether to quit early
|
||||||
type Waiter func(delta int) (abort error)
|
type Waiter func(delta int64) (abort error)
|
||||||
|
|
||||||
// DefaultWaitStrategy is the standard backoff algorithm,
|
// DefaultWaitStrategy is the standard backoff algorithm,
|
||||||
// but you can plug in another one
|
// but you can plug in another one
|
||||||
func DefaultWaitStrategy(delta int) (abort error) {
|
func DefaultWaitStrategy(delta int64) (abort error) {
|
||||||
if delta > 10 {
|
if delta > 10 {
|
||||||
return errors.Errorf("Waiting for %d blocks... aborting", delta)
|
return errors.Errorf("Waiting for %d blocks... aborting", delta)
|
||||||
} else if delta > 0 {
|
} else if delta > 0 {
|
||||||
@ -36,13 +36,13 @@ func WaitForHeight(c StatusClient, h int64, waiter Waiter) error {
|
|||||||
if waiter == nil {
|
if waiter == nil {
|
||||||
waiter = DefaultWaitStrategy
|
waiter = DefaultWaitStrategy
|
||||||
}
|
}
|
||||||
delta := 1
|
delta := int64(1)
|
||||||
for delta > 0 {
|
for delta > 0 {
|
||||||
s, err := c.Status()
|
s, err := c.Status()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
delta = int(h - s.LatestBlockHeight)
|
delta = h - s.LatestBlockHeight
|
||||||
// wait for the time, or abort early
|
// wait for the time, or abort early
|
||||||
if err := waiter(delta); err != nil {
|
if err := waiter(delta); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -50,7 +50,7 @@ func TestWaitForHeight(t *testing.T) {
|
|||||||
|
|
||||||
// since we can't update in a background goroutine (test --race)
|
// since we can't update in a background goroutine (test --race)
|
||||||
// we use the callback to update the status height
|
// we use the callback to update the status height
|
||||||
myWaiter := func(delta int) error {
|
myWaiter := func(delta int64) error {
|
||||||
// update the height for the next call
|
// update the height for the next call
|
||||||
m.Call.Response = &ctypes.ResultStatus{LatestBlockHeight: 15}
|
m.Call.Response = &ctypes.ResultStatus{LatestBlockHeight: 15}
|
||||||
return client.DefaultWaitStrategy(delta)
|
return client.DefaultWaitStrategy(delta)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user