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

Signing takes a lot if there is a lot of identities #229

Closed
ajunge opened this issue Sep 2, 2020 · 0 comments
Closed

Signing takes a lot if there is a lot of identities #229

ajunge opened this issue Sep 2, 2020 · 0 comments

Comments

@ajunge
Copy link
Member

ajunge commented Sep 2, 2020

Signing in an environment with a lot of identities is very slow. Basically because

async getIdentity(did: string): Promise<AbstractIdentity> {
    const identities = await this.getIdentities()
    const identity = identities.find(item => item.did === did)
    if (identity) {
      return identity
    } else {
      return Promise.reject('No identity: ' + did)
    }
  }

gets all the identities first and then select one.

Maybe is easier something like:

async getIdentity(did: string): Promise<AbstractIdentity> {
    let identity: AbstractIdentity;
    for (const identityProvider of this.identityProviders) {
      const providerIdentity = await identityProvider.getIdentity(did);
      if(providerIdentity) identity = providerIdentity;
    }
    if (identity) {
      return identity
    } else {
      return Promise.reject('No identity: ' + did)
    }
  }

is much faster, and scales better, since the providers number is constant.

ajunge pushed a commit to Notabene-id/daf that referenced this issue Sep 2, 2020
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

No branches or pull requests

1 participant