@@ -428,25 +428,26 @@ func (f *Fabric) updateAnchors(trustID string, kind trustKind) error {
428428 return nil
429429}
430430
431- // Resolve a single handle. Supports dotted names like "hello.alice@bitcoin".
432- func (f * Fabric ) Resolve (handle string ) (Resolved , error ) {
431+ // Resolve a single handle. Returns nil if not found. Supports dotted names like "hello.alice@bitcoin".
432+ func (f * Fabric ) Resolve (handle string ) (* Resolved , error ) {
433433 batch , err := f .ResolveAll ([]string {handle })
434434 if err != nil {
435- return Resolved {} , err
435+ return nil , err
436436 }
437437 for _ , z := range batch .Zones {
438438 if z .Handle == handle {
439- return Resolved {Zone : z , Roots : batch .Roots }, nil
439+ return & Resolved {Zone : z , Roots : batch .Roots }, nil
440440 }
441441 }
442- return Resolved {}, & FabricError { Code : "decode" , Message : handle + " not found" }
442+ return nil , nil
443443}
444444
445445// ResolveById resolves a numeric ID to a handle by querying relays
446446// for the reverse mapping, then verifying via forward resolution.
447- func (f * Fabric ) ResolveById (numId string ) (Resolved , error ) {
447+ // Returns nil if not found.
448+ func (f * Fabric ) ResolveById (numId string ) (* Resolved , error ) {
448449 if err := f .Bootstrap (); err != nil {
449- return Resolved {} , err
450+ return nil , err
450451 }
451452 urls := f .pool .ShuffledURLs (4 )
452453 var lastErr error = & FabricError {Code : "no_peers" , Message : "reverse resolution failed" }
@@ -486,6 +487,9 @@ func (f *Fabric) ResolveById(numId string) (Resolved, error) {
486487 lastErr = err
487488 continue
488489 }
490+ if resolved == nil {
491+ continue
492+ }
489493
490494 if resolved .Zone .NumId == nil || * resolved .Zone .NumId != numId {
491495 lastErr = & FabricError {Code : "verify" , Message : fmt .Sprintf ("reverse mismatch: expected %s" , numId )}
@@ -494,7 +498,7 @@ func (f *Fabric) ResolveById(numId string) (Resolved, error) {
494498
495499 return resolved , nil
496500 }
497- return Resolved {} , lastErr
501+ return nil , lastErr
498502}
499503
500504// SearchAddr searches for handles by address record, verifies via forward resolution.
0 commit comments