|
1 | 1 | package verify |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "context" |
5 | 4 | "errors" |
6 | 5 | "fmt" |
7 | 6 | "math/rand" |
@@ -651,26 +650,27 @@ func verifyIngestFromMhs(cctx *cli.Context, find *client.Client, dhFind *client. |
651 | 650 | } |
652 | 651 |
|
653 | 652 | func verifyIngest(cctx *cli.Context, find *client.Client, dhFind *client.DHashClient, wantProvID peer.ID, mhs []multihash.Multihash) (*verifyResult, error) { |
654 | | - result := &verifyResult{} |
655 | | - mhsCount := len(mhs) |
656 | | - result.TotalMhChecked = mhsCount |
| 653 | + result := &verifyResult{ |
| 654 | + TotalMhChecked: len(mhs), |
| 655 | + } |
657 | 656 |
|
658 | 657 | var response *model.FindResponse |
659 | 658 | var err error |
660 | 659 | if dhFind != nil { |
661 | | - response, err = doDHFind(cctx.Context, dhFind, mhs) |
| 660 | + response, err = client.FindBatch(cctx.Context, dhFind, mhs) |
| 661 | + fmt.Println("🔒 Reader privacy enabled") |
662 | 662 | } else { |
663 | | - response, err = doClearFind(cctx.Context, find, mhs) |
| 663 | + response, err = client.FindBatch(cctx.Context, find, mhs) |
664 | 664 | } |
665 | 665 | if err != nil { |
666 | | - result.FailedToVerify = mhsCount |
| 666 | + result.FailedToVerify = len(mhs) |
667 | 667 | err = fmt.Errorf("failed to connect to indexer: %w", err) |
668 | 668 | result.Errs = append(result.Errs, err) |
669 | 669 | return result, nil |
670 | 670 | } |
671 | 671 |
|
672 | 672 | if response == nil || len(response.MultihashResults) == 0 { |
673 | | - result.Absent = mhsCount |
| 673 | + result.Absent = len(mhs) |
674 | 674 | return result, nil |
675 | 675 | } |
676 | 676 |
|
@@ -701,32 +701,3 @@ func verifyIngest(cctx *cli.Context, find *client.Client, dhFind *client.DHashCl |
701 | 701 | } |
702 | 702 | return result, nil |
703 | 703 | } |
704 | | - |
705 | | -func doDHFind(ctx context.Context, cl *client.DHashClient, mhs []multihash.Multihash) (*model.FindResponse, error) { |
706 | | - var resp *model.FindResponse |
707 | | - for _, mh := range mhs { |
708 | | - r, err := cl.Find(ctx, mh) |
709 | | - if err != nil { |
710 | | - // TODO: Look for error that specifies double-hashing not supported. |
711 | | - var ae *apierror.Error |
712 | | - if errors.As(err, &ae) && ae.Status() == http.StatusNotFound { |
713 | | - continue |
714 | | - } |
715 | | - return nil, err |
716 | | - } |
717 | | - if resp == nil { |
718 | | - resp = r |
719 | | - } else { |
720 | | - resp.MultihashResults = append(resp.MultihashResults, r.MultihashResults...) |
721 | | - } |
722 | | - } |
723 | | - fmt.Println("🔒 Reader privacy enabled") |
724 | | - return resp, nil |
725 | | -} |
726 | | - |
727 | | -func doClearFind(ctx context.Context, cl *client.Client, mhs []multihash.Multihash) (*model.FindResponse, error) { |
728 | | - if len(mhs) == 1 { |
729 | | - return cl.Find(ctx, mhs[0]) |
730 | | - } |
731 | | - return cl.FindBatch(ctx, mhs) |
732 | | -} |
0 commit comments