Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the DID DHT API #76

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft

Support the DID DHT API #76

wants to merge 15 commits into from

Conversation

decentralgabe
Copy link
Member

@decentralgabe decentralgabe commented Dec 19, 2023

Fix #43 #13 #24 #72

  • Support full API except historical resolution and retention proofs (will be in follow ups)
  • Multiple tweaks to the API during impl

}
}

if err = s.db.WriteDID(storage.GatewayRecord{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a possible race condition when publishing the same did? Perhaps some idempotency key is necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I'm also worried about multiple DIDs updating the type index at the same time...

}

var (
knownTypes = []TypeMapping{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side question: how are types registered? Is it a centralized registry?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

// WriteDID writes a DID to the storage and adds it to the type index(es) it is associated with
func (s *Storage) WriteDID(record GatewayRecord) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you intend to handle failures in the middle? For example, the write succeeds, but the update does not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally this should be a txn with rollbacks

Comment on lines +76 to +91
for _, currType := range currTypes {
if _, ok := newTypeMap[currType]; !ok {
if err := s.RemoveDIDFromTypeIndex(id, currType); err != nil {
return err
}
}
}

// add the DID to any type indexes it is now associated with
for _, newType := range newTypes {
if _, ok := currTypeMap[newType]; !ok {
if err := s.AddDIDToTypeIndex(id, newType); err != nil {
return err
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing and then adding add steps which may fail in the middle.

Instead, consider replacing the types with the new value. This might be more easily supported by the storage layer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea will update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Gateway/DIDs API
2 participants