Browse Source

change delta's type from int to int64

pull/914/head
Anton Kaliaev 7 years ago
parent
commit
d41c0b10c8
No known key found for this signature in database GPG Key ID: 7B6881D965918214
2 changed files with 5 additions and 5 deletions
  1. +4
    -4
      rpc/client/helpers.go
  2. +1
    -1
      rpc/client/helpers_test.go

+ 4
- 4
rpc/client/helpers.go View File

@ -10,11 +10,11 @@ import (
)
// 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,
// but you can plug in another one
func DefaultWaitStrategy(delta int) (abort error) {
func DefaultWaitStrategy(delta int64) (abort error) {
if delta > 10 {
return errors.Errorf("Waiting for %d blocks... aborting", delta)
} else if delta > 0 {
@ -36,13 +36,13 @@ func WaitForHeight(c StatusClient, h int64, waiter Waiter) error {
if waiter == nil {
waiter = DefaultWaitStrategy
}
delta := 1
delta := int64(1)
for delta > 0 {
s, err := c.Status()
if err != nil {
return err
}
delta = int(h - s.LatestBlockHeight)
delta = h - s.LatestBlockHeight
// wait for the time, or abort early
if err := waiter(delta); err != nil {
return err


+ 1
- 1
rpc/client/helpers_test.go View File

@ -50,7 +50,7 @@ func TestWaitForHeight(t *testing.T) {
// since we can't update in a background goroutine (test --race)
// 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
m.Call.Response = &ctypes.ResultStatus{LatestBlockHeight: 15}
return client.DefaultWaitStrategy(delta)


Loading…
Cancel
Save