-
Notifications
You must be signed in to change notification settings - Fork 808
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
Separate mempool indexer #650
Conversation
use before and after for setting up.
remove unnecessary methods
When restoring mempool from db, it returns transactions sorted by txid. But indexer logic depends on transactions being in dependency orders, so it does not have to deal with the orphan logic. This will change load method to use proper orphan handling and emit events in order even on load.
Codecov Report
@@ Coverage Diff @@
## master #650 +/- ##
==========================================
+ Coverage 53.33% 54.55% +1.21%
==========================================
Files 104 105 +1
Lines 27676 27725 +49
Branches 4738 4744 +6
==========================================
+ Hits 14762 15126 +364
+ Misses 12914 12599 -315
Continue to review full report at Codecov.
|
In regards to the fix for #499 and #594 here is the scenario that would cause the issue:
Thanks @nodar-chkuaselidze for explanation of the above scenario. |
Taking a look at the persistence issue for the mempool, and it's also related to the coin index. As described in the commit 66042d8 the coin index depends on the order, and thus there is an issue when restoring, if the order is not correct. I've applied to same test to the current master branch 01a7156 to demonstrate the issue, see braydonf@73fab1a. The test will fail at assertions of the coin index size, the test will pass without these assertions (lines 664 and 644), and will pass with the assertions for the tx address index. |
/** | ||
* Find all transactions pertaining to a certain address. | ||
* Note: this does not accept multiple addresses. | ||
* @param {Address} addrs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this function accept addrs
instead of addr
and then place the single address into an array to iterate over if it only accepts a single address?
This could be exported in |
* @alias module:mempool.MempoolIndexerOptions | ||
*/ | ||
|
||
class MempoolIndexerOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These options don't seem necessary since there is really only 1 option that it sets
for (const addr of addrs) { | ||
const items = this.index.get(addr); | ||
|
||
assert(items); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These assert
statements could use messages
@@ -404,8 +417,12 @@ class FullNode extends Node { | |||
*/ | |||
|
|||
async getCoinsByAddress(addrs) { | |||
const mempool = this.mempool.getCoinsByAddress(addrs); | |||
if (!this.mempoolIndex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why return early here when there is no mempoolIndex
? Can't there be coins that are in the chain db still?
These updates are not necessary with #758 and have included other fixes and updates well. It may be nice to separate the indexer and combine with |
I've incorporated tests from this PR into #758 |
Check full details: bcoin-org/bcash#117
Related Issues in bcoin: #594 and #499.
Summary:
This separate coin/tx indexer from the mempool and moves to its separate file.
view
to theadd entry
event.Other PRs: