blockstore: fix logger, improve messages
This commit is contained in:
parent
f24f64b483
commit
f3e517c3c0
@ -32,7 +32,7 @@ class FileBlockStore extends AbstractBlockStore {
|
||||
*/
|
||||
|
||||
constructor(options) {
|
||||
super();
|
||||
super(options);
|
||||
|
||||
assert(isAbsolute(options.location), 'Location not absolute.');
|
||||
|
||||
@ -101,7 +101,7 @@ class FileBlockStore extends AbstractBlockStore {
|
||||
if (!missing)
|
||||
return;
|
||||
|
||||
this.logger.info(`Indexing block type ${type}...`);
|
||||
this.logger.info('Indexing block type %d...', type);
|
||||
|
||||
for (const fileno of filenos) {
|
||||
const b = this.db.batch();
|
||||
@ -166,7 +166,7 @@ class FileBlockStore extends AbstractBlockStore {
|
||||
|
||||
await b.write();
|
||||
|
||||
this.logger.info(`Indexed ${blocks} blocks from ${filepath}...`);
|
||||
this.logger.info('Indexed %d blocks (file=%s).', blocks, filepath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ class LevelBlockStore extends AbstractBlockStore {
|
||||
*/
|
||||
|
||||
constructor(options) {
|
||||
super();
|
||||
super(options);
|
||||
|
||||
this.location = options.location;
|
||||
|
||||
|
||||
@ -292,6 +292,23 @@ describe('BlockStore', function() {
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
it('will pass options to super', () => {
|
||||
const info = () => 'info';
|
||||
const logger = {
|
||||
context: () => {
|
||||
return {info};
|
||||
}
|
||||
};
|
||||
|
||||
const store = new FileBlockStore({
|
||||
location: '/tmp/.bcoin/blocks',
|
||||
maxFileLength: 1024,
|
||||
logger: logger
|
||||
});
|
||||
|
||||
assert.strictEqual(store.logger.info, info);
|
||||
});
|
||||
|
||||
it('will error with invalid location', () => {
|
||||
let err = null;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user