diff --git a/tools/cmd/debug/heal_synth.go b/tools/cmd/debug/heal_synth.go index 86cc1f4c0..af35efa2f 100644 --- a/tools/cmd/debug/heal_synth.go +++ b/tools/cmd/debug/heal_synth.go @@ -45,7 +45,6 @@ func healSynth(cmd *cobra.Command, args []string) { // Pull chains pullSynthDirChains(h) pullSynthSrcChains(h, srcUrl) - pullSynthDstChains(h, dstUrl) // Pull accounts pullSynthLedger(h, srcUrl) @@ -61,7 +60,6 @@ func healSynth(cmd *cobra.Command, args []string) { // Pull chains pullSynthDirChains(h) pullSynthSrcChains(h, srcUrl) - pullSynthDstChains(h, dstUrl) // Pull accounts pullAgain: @@ -136,7 +134,7 @@ func pullSynthDirChains(h *healer) { check(h.light.PullAccount(ctx, protocol.DnUrl().JoinPath(protocol.Network))) - check(h.light.PullAccountWithChains(ctx, protocol.DnUrl().JoinPath(protocol.Ledger), include("root").and("root-index"))) + check(h.light.PullAccountWithChains(ctx, protocol.DnUrl().JoinPath(protocol.Ledger), includeRootChain)) check(h.light.IndexAccountChains(ctx, protocol.DnUrl().JoinPath(protocol.Ledger))) check(h.light.PullAccountWithChains(ctx, protocol.DnUrl().JoinPath(protocol.AnchorPool), func(c *api.ChainRecord) bool { @@ -149,7 +147,7 @@ func pullSynthSrcChains(h *healer, part *url.URL) { ctx, cancel, _ := api.ContextWithBatchData(h.ctx) defer cancel() - check(h.light.PullAccountWithChains(ctx, part.JoinPath(protocol.Ledger), include("root").and("root-index"))) + check(h.light.PullAccountWithChains(ctx, part.JoinPath(protocol.Ledger), includeRootChain)) check(h.light.IndexAccountChains(ctx, part.JoinPath(protocol.Ledger))) check(h.light.PullAccountWithChains(ctx, part.JoinPath(protocol.Synthetic), func(c *api.ChainRecord) bool { @@ -158,25 +156,8 @@ func pullSynthSrcChains(h *healer, part *url.URL) { check(h.light.IndexAccountChains(ctx, part.JoinPath(protocol.Synthetic))) } -func pullSynthDstChains(h *healer, part *url.URL) { - // ctx, cancel, _ := api.ContextWithBatchData(h.ctx) - // defer cancel() - - // check(h.light.PullAccountWithChains(ctx, part.JoinPath(protocol.Ledger), include("root").and("root-index"))) - // check(h.light.IndexAccountChains(ctx, part.JoinPath(protocol.Ledger))) - // check(h.light.PullAccountWithChains(ctx, part.JoinPath(protocol.AnchorPool), skipSigChain)) - // check(h.light.IndexAccountChains(ctx, part.JoinPath(protocol.AnchorPool))) - - // if healSinceDuration > 0 { - // check(h.light.PullMessagesForAccountSince(ctx, part.JoinPath(protocol.AnchorPool), time.Now().Add(-healSinceDuration), "main")) - // } else { - // check(h.light.PullMessagesForAccount(ctx, part.JoinPath(protocol.AnchorPool), "main")) - // } - // check(h.light.IndexReceivedAnchors(ctx, part)) -} - func pullSynthLedger(h *healer, part *url.URL) *protocol.SyntheticLedger { - check(h.light.PullAccountWithChains(h.ctx, part.JoinPath(protocol.Synthetic), skipAllChains)) + check(h.light.PullAccountWithChains(h.ctx, part.JoinPath(protocol.Synthetic), func(cr *api.ChainRecord) bool { return false })) batch := h.light.OpenDB(false) defer batch.Discard() @@ -186,24 +167,14 @@ func pullSynthLedger(h *healer, part *url.URL) *protocol.SyntheticLedger { return ledger } -func skipSigChain(c *api.ChainRecord) bool { - return c.Name != "signature" -} - func skipAllChains(*api.ChainRecord) bool { return false } -type chainFilter func(*api.ChainRecord) bool - -func include(name string) chainFilter { return chainFilter(nil).and(name) } - -func (f chainFilter) and(name string) chainFilter { - g := func(c *api.ChainRecord) bool { - return c.Name == name - } - if f == nil { - return g +func includeRootChain(c *api.ChainRecord) bool { + switch c.Name { + case "root", "root-index": + return true } - return func(c *api.ChainRecord) bool { return f(c) || g(c) } + return false }