@@ -879,21 +879,54 @@ func (m *MultiArchiver) FetchIssuanceProof(ctx context.Context,
879
879
// intended to be a performance optimized lookup compared to fetching a proof
880
880
// and checking for ErrProofNotFound. The multi archiver only considers a proof
881
881
// to be present if all backends have it.
882
- func (m * MultiArchiver ) HasProof (ctx context.Context , id Locator ) (bool , error ) {
882
+ func (m * MultiArchiver ) HasProof (ctx context.Context ,
883
+ id Locator ) (bool , error ) {
884
+
885
+ var (
886
+ someHaveProof = false
887
+ allHaveProof = true
888
+ )
883
889
for _ , archive := range m .backends {
884
890
ok , err := archive .HasProof (ctx , id )
885
891
if err != nil {
886
892
return false , err
887
893
}
888
894
889
- // We are expecting all backends to have the proof, otherwise we
890
- // consider the proof not to be found.
891
- if ! ok {
892
- return false , nil
893
- }
895
+ someHaveProof = someHaveProof || ok
896
+ allHaveProof = allHaveProof && ok
897
+ }
898
+
899
+ // If all backends have the proof, then we don't need to do anything
900
+ // further and can return that result.
901
+ if allHaveProof {
902
+ return true , nil
894
903
}
895
904
896
- return true , nil
905
+ // If no backends have the proof, then this is just a proof we don't
906
+ // know about, which is fine too.
907
+ if ! someHaveProof {
908
+ return false , nil
909
+ }
910
+
911
+ // If only some but not all backends have the proof, it's possible that
912
+ // the other ones are in the process of importing it right now. So we
913
+ // re-try a couple of times to see if the proof becomes available
914
+ // eventually.
915
+ return fn .RetryFuncN (
916
+ ctx , fn .DefaultRetryConfig (), func () (bool , error ) {
917
+ allHaveProof = true
918
+ for _ , archive := range m .backends {
919
+ ok , err := archive .HasProof (ctx , id )
920
+ if err != nil {
921
+ return false , err
922
+ }
923
+
924
+ allHaveProof = allHaveProof && ok
925
+ }
926
+
927
+ return allHaveProof , nil
928
+ },
929
+ )
897
930
}
898
931
899
932
// FetchProofs fetches all proofs for assets uniquely identified by the passed
0 commit comments