-
Notifications
You must be signed in to change notification settings - Fork 809
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
Neutrino: Sync #1168
base: master
Are you sure you want to change the base?
Neutrino: Sync #1168
Changes from all commits
0d84694
ed0ce73
059acb4
9750e82
d1d8e80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
console.log('Starting bcoin'); | ||
process.title = 'bcoin'; | ||
const Neutrino = require('../lib/node/neutrino'); | ||
|
||
const node = new Neutrino({ | ||
file: true, | ||
argv: true, | ||
env: true, | ||
logFile: true, | ||
logConsole: true, // todo: remove | ||
logLevel: 'debug', // todo: remove | ||
db: 'leveldb', | ||
memory: false, | ||
workers: true, | ||
loader: require | ||
}); | ||
|
||
if (!node.config.bool('no-wallet') && !node.has('walletdb')) { | ||
const plugin = require('../lib/wallet/plugin'); | ||
node.use(plugin); | ||
} | ||
|
||
(async () => { | ||
await node.ensure(); | ||
await node.open(); | ||
await node.connect(); | ||
node.startSync(); | ||
})().catch((err) => { | ||
console.error(err.stack); | ||
process.exit(1); | ||
}); | ||
|
||
process.on('unhandledRejection', (err, promise) => { | ||
throw err; | ||
}); | ||
|
||
process.on('SIGINT', async () => { | ||
await node.close(); | ||
}); |
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -85,6 +85,31 @@ class FilterIndexer extends Indexer { | |||||||||||
this.put(layout.f.encode(hash), gcsFilter.hash()); | ||||||||||||
} | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* Save filter | ||||||||||||
* @param {Hash} blockHash | ||||||||||||
* @param {BasicFilter} basicFilter | ||||||||||||
* @param {Hash} filterHeader | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: add blockheight |
||||||||||||
* @returns {Promise} | ||||||||||||
*/ | ||||||||||||
|
||||||||||||
async saveFilter(blockHash, blockHeight, basicFilter, filterHeader) { | ||||||||||||
assert(blockHash); | ||||||||||||
assert(blockHeight); | ||||||||||||
assert(basicFilter); | ||||||||||||
assert(filterHeader); | ||||||||||||
Comment on lines
+97
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can probably use 1 assertion here
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We won't be able to know which value gives out the error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And why would you do a logical and here? What if for example my bits are There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm guessing he meant |
||||||||||||
|
||||||||||||
const filter = new Filter(); | ||||||||||||
filter.filter = basicFilter.toRaw(); | ||||||||||||
filter.header = filterHeader; | ||||||||||||
Comment on lines
+102
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe I'm being too picky about code styles but I'd prefer if you pass an options object instead of assigning values to class variables There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that many functions in |
||||||||||||
|
||||||||||||
this.batch = this.db.batch(); | ||||||||||||
|
||||||||||||
await this.blocks.writeFilter(blockHash, filter.toRaw(), this.filterType); | ||||||||||||
this.put(layout.f.encode(blockHash), basicFilter.hash()); | ||||||||||||
await super.syncHeight(blockHash, blockHeight); | ||||||||||||
} | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* Prune compact filters. | ||||||||||||
* @private | ||||||||||||
|
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.
@masterchief164 Do we need to add neutrino to bcoin-browser? AFAIK, bcoin-browser is obselete.