blockstore: fix logger, improve messages

This commit is contained in:
Braydon Fuller 2019-03-19 10:34:14 -07:00
parent f24f64b483
commit f3e517c3c0
No known key found for this signature in database
GPG Key ID: F24F232D108B3AD4
3 changed files with 21 additions and 4 deletions

View File

@ -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);
}
}

View File

@ -26,7 +26,7 @@ class LevelBlockStore extends AbstractBlockStore {
*/
constructor(options) {
super();
super(options);
this.location = options.location;

View File

@ -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;