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

refactor(core-state): wallet manager indexes #2845

Merged
merged 7 commits into from Jul 27, 2019

Conversation

spkjp
Copy link
Contributor

@spkjp spkjp commented Jul 27, 2019

The WalletManager has several wallet indexes (byPublicKey, etc.), but it's difficult
to add custom indexes. This PR introduces some new functions to make it easier to create a custom wallet index and also makes the whole indexing more generic in general.

Example:

walletManager.registerIndex("customIndex", (index: State.IWalletIndex, wallet: State.IWallet): void => {
    if (wallet.hasAttribute("custom.attribute")) {
        index.set(wallet.getAttribute("custom.attribute"), wallet);
    }
});

const wallet = new Wallet(...);
wallet.setAttribute("custom.attribute", "something");
walletManager.reindex(wallet);

expect(walletManager.findByIndex("customIndex", "something")).toBe(wallet);

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Refactor
  • Performance
  • Tests
  • Build
  • Documentation
  • Code style update
  • Continuous Integration
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes
  • No

Does this PR release a new version?

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

  • It's submitted to the develop branch, not the master branch
  • All tests are passing
  • New/updated tests are included

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

@faustbrian faustbrian merged commit f934468 into 2.6 Jul 27, 2019
@ghost ghost deleted the refactor/core-state/wallet-manager-indexes branch July 27, 2019 13:29
vasild added a commit that referenced this pull request Jul 29, 2019
…o-db

* ArkEcosystem/core/2.6:
  feat(core-state): wallet manager indexes (#2845)
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.

None yet

2 participants