From 84c231757bd93036e678814fea1f03f977d81cbd Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 12 May 2022 12:03:54 +0300 Subject: [PATCH] compare-states: return 0 in case state matches --- scripts/compare-states/compare-states.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/compare-states/compare-states.go b/scripts/compare-states/compare-states.go index 0fdb12181..c90c1b954 100644 --- a/scripts/compare-states/compare-states.go +++ b/scripts/compare-states/compare-states.go @@ -13,6 +13,8 @@ import ( "github.com/urfave/cli" ) +var errStateMatches = errors.New("state matches") + func initClient(addr string, name string) (*client.Client, uint32, error) { c, err := client.New(context.Background(), addr, client.Options{}) 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()) if ra.Equals(rb) { - return 0, fmt.Errorf("state matches at %d", h) + return 0, fmt.Errorf("%w at %d", errStateMatches, h) } bad := h for bad-good > 1 { @@ -98,6 +100,9 @@ func cliMain(c *cli.Context) error { } h, err := bisectState(ca, cb, ha-1) if err != nil { + if errors.Is(err, errStateMatches) { + return nil + } return err } blk, err := ca.GetBlockByIndex(h)