forked from TrueCloudLab/neoneo-go
compare-states: return 0 in case state matches
This commit is contained in:
parent
dafd3639e8
commit
84c231757b
1 changed files with 6 additions and 1 deletions
|
@ -13,6 +13,8 @@ import (
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var errStateMatches = errors.New("state matches")
|
||||||
|
|
||||||
func initClient(addr string, name string) (*client.Client, uint32, error) {
|
func initClient(addr string, name string) (*client.Client, uint32, error) {
|
||||||
c, err := client.New(context.Background(), addr, client.Options{})
|
c, err := client.New(context.Background(), addr, client.Options{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -57,7 +59,7 @@ func bisectState(ca *client.Client, cb *client.Client, h uint32) (uint32, error)
|
||||||
}
|
}
|
||||||
fmt.Printf("at %d: %s vs %s\n", h, ra.StringLE(), rb.StringLE())
|
fmt.Printf("at %d: %s vs %s\n", h, ra.StringLE(), rb.StringLE())
|
||||||
if ra.Equals(rb) {
|
if ra.Equals(rb) {
|
||||||
return 0, fmt.Errorf("state matches at %d", h)
|
return 0, fmt.Errorf("%w at %d", errStateMatches, h)
|
||||||
}
|
}
|
||||||
bad := h
|
bad := h
|
||||||
for bad-good > 1 {
|
for bad-good > 1 {
|
||||||
|
@ -98,6 +100,9 @@ func cliMain(c *cli.Context) error {
|
||||||
}
|
}
|
||||||
h, err := bisectState(ca, cb, ha-1)
|
h, err := bisectState(ca, cb, ha-1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, errStateMatches) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
blk, err := ca.GetBlockByIndex(h)
|
blk, err := ca.GetBlockByIndex(h)
|
||||||
|
|
Loading…
Reference in a new issue