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

fix(core-transaction-pool): wallet-manager fallback to database wallet manager findByIndex() when no "local" match #3256

Merged
merged 3 commits into from
Nov 15, 2019

Conversation

air1one
Copy link
Contributor

@air1one air1one commented Nov 14, 2019

Summary

Resolves #3242

Transaction pool wallet manager : try database wallet manager findByIndex() when local findByIndex() doesn't return a match.

We might not have all existing wallets indexes on transaction pool wallet manager : so in case we get no match we should try with database wallet manager.

Checklist

  • Documentation (if necessary)
  • Tests (if necessary)
  • Ready to be merged

try find index with db wallet manager if no match "locally"
@codecov
Copy link

codecov bot commented Nov 14, 2019

Codecov Report

Merging #3256 into develop will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #3256      +/-   ##
==========================================
+ Coverage    65.18%   65.2%   +0.02%     
==========================================
  Files          431     431              
  Lines        12123   12132       +9     
  Branches      1631    1633       +2     
==========================================
+ Hits          7902    7911       +9     
  Misses        4188    4188              
  Partials        33      33
Impacted Files Coverage Δ
...ckages/core-transaction-pool/src/wallet-manager.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f028f8...5f0b6a6. Read the comment docs.

@dated
Copy link
Contributor

dated commented Nov 14, 2019

With these changes the following lines become obsolete, is that right?

const dbWalletManager: State.IWalletManager = app.resolvePlugin<Database.IDatabaseService>("database")
.walletManager;
const lockWallet: State.IWallet = dbWalletManager.findByIndex(State.WalletIndexes.Locks, lockId);

Instead, we can call findByIndex on the wallet manager passed to the throwIfCannotBeApplied method directly.

@dated
Copy link
Contributor

dated commented Nov 14, 2019

And another question for my personal understanding: should the Wallet Managers be allowed to be out of sync at all?

@spkjp
Copy link
Contributor

spkjp commented Nov 14, 2019

@dated Initially the PoolWalletManager has no wallets and clones every database wallet that is missing. The reason why it is an issue for HTLC is because findByIndex is called directly, which doesn't have the fallback to the database wallets as findByAddress/findByPublicKey do. This PR adds the fallback.

With these changes the following lines become obsolete, is that right?

Yes, these should be obsolete now. @air1one

@dated
Copy link
Contributor

dated commented Nov 14, 2019

Understood! Thanks for the explanation!

@air1one
Copy link
Contributor Author

air1one commented Nov 15, 2019

With these changes the following lines become obsolete, is that right?

No I think it's better to keep it this way, we actually want to check just against the database wallets, with associated lock transaction forged. (we don't want to validate if the lock transaction is still in the pool and was applied just to tx pool wallet, even though in theory this shouldn't happen)

@air1one air1one merged commit 9c9e7b3 into develop Nov 15, 2019
@ghost ghost deleted the fix/core-transaction-pool/wallet-manager-findByIndex branch November 15, 2019 09:59
faustbrian pushed a commit that referenced this pull request Feb 12, 2020
…t manager findByIndex() when no "local" match (#3256)
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.

3 participants