hyperledger-archives / aries-framework-go

Hyperledger Aries Framework Go provides packages for building Agent / DIDComm services.
https://wiki.hyperledger.org/display/ARIES/aries-framework-go
Apache License 2.0
240 stars 161 forks source link

LD Remote Provider Store implementation efficiency improvements #3204

Open DRK3 opened 2 years ago

DRK3 commented 2 years ago

The LD Remote Provider Store implementation in https://github.com/hyperledger/aries-framework-go/blob/main/pkg/store/ld/remote_provider_store.go could use the storage provider more efficiently.

When Save(endpoint string) gets called, it stores some data in the underlying key-value store. A UUID is used as the key while the endpoint is used as the value. Whenever save is called, it first queries the store and iterates through every entry to see if the data is already there, in which case the existing data is returned.

My understanding as to why the UUID is used is because that ID is needed in https://github.com/hyperledger/aries-framework-go/blob/main/pkg/controller/rest/ld/operation.go as part of a URL, and so the endpoint can't be directly there as it wouldn't be URL safe.

Instead of this UUID<->endpoint mapping, it would be better to simply encode the endpoint as needed to work within a URL. That should simplify things.

If the UUID<->endpoint mapping is required for some other reason, we could still optimize the Save(endpoint string) method by storing the endpoint with a tag name + value pair that will allow exactly one piece of data to be queried for instead of iterating through the entire store every time.

DRK3 commented 2 years ago

cc @aholovko who may be able to provide more details