Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
feat: use different domain when anchor origin is down
Browse files Browse the repository at this point in the history
Signed-off-by: Firas Qutishat <firas.qutishat@securekey.com>
  • Loading branch information
fqutishat committed Aug 9, 2022
1 parent 7c7e258 commit ccb35f4
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions component/vdr/orb/vdr.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,12 +648,22 @@ func (v *VDR) Update(didDoc *docdid.Doc, opts ...vdrapi.DIDMethodOption) error {
updateOpt = append(updateOpt, updatedAlsoKnownAsOpts...)

updateOpt = append(updateOpt, update.WithSidetreeEndpoint(func() ([]string, error) {
var endpoint *models.Endpoint
endpoint, errGet := v.discoveryService.GetEndpoint(docResolution.DocumentMetadata.Method.AnchorOrigin)
if errGet != nil {
logger.Warnf("failed to get anchor origin %s endpoints will choose random domain: %w",
docResolution.DocumentMetadata.Method.AnchorOrigin, errGet)

// TODO make sure it's latest anchor origin
endpoint, err = v.discoveryService.GetEndpoint(docResolution.DocumentMetadata.Method.AnchorOrigin)
if err != nil {
return nil, fmt.Errorf("failed to get endpoints: %w", err)
domain, errChoose := v.selectDomainSvc.Choose(v.domains)
if err != nil {
return nil, errChoose
}

domainEndpoint, err := v.discoveryService.GetEndpoint(domain)
if err != nil {
return nil, fmt.Errorf("failed to get endpoints: %w", err)
}

return domainEndpoint.OperationEndpoints, nil
}

return endpoint.OperationEndpoints, nil
Expand Down

0 comments on commit ccb35f4

Please sign in to comment.