From d1e747cf2f5aa0591aec9ca2c80a4bfcce1f3c9c Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Thu, 7 Mar 2019 15:27:21 -0800 Subject: [PATCH] blockstore: minor, update comments and docs --- bench/blockstore.js | 7 ++++--- lib/blockchain/chaindb.js | 3 +-- lib/blockstore/abstract.js | 4 ++-- lib/blockstore/common.js | 6 +++--- lib/blockstore/file.js | 13 ++++++++----- lib/blockstore/layout.js | 4 ++-- lib/blockstore/level.js | 2 +- lib/blockstore/records.js | 4 ++-- 8 files changed, 23 insertions(+), 20 deletions(-) diff --git a/bench/blockstore.js b/bench/blockstore.js index 362869ea..817633b0 100644 --- a/bench/blockstore.js +++ b/bench/blockstore.js @@ -1,5 +1,5 @@ /*! - * bench/blockstore.js - benchmark block store for bcoin + * bench/blockstore.js - benchmark blockstore for bcoin * * This can be run to benchmark the performance of the blockstore * module for writing, reading and pruning block data. Results are @@ -7,14 +7,15 @@ * * Usage: * node ./blockstore.js [--maxfile=] [--total=] - [--location=] [--store=] [--unsafe] + * [--location=] [--store=] + * [--output=] [--unsafe] * * Options: * - `maxfile` The maximum file size (applies to "file" store). * - `total` The total number of block bytes to write. * - `location` The location to store block data. * - `store` This can be "file" or "level". - * - `output` This can be "json" or "bench". + * - `output` This can be "json", "bench" or "benchjson". * - `unsafe` This will allocate block data directly from memory * instead of random, it is faster. * diff --git a/lib/blockchain/chaindb.js b/lib/blockchain/chaindb.js index 96b38493..eef121c4 100644 --- a/lib/blockchain/chaindb.js +++ b/lib/blockchain/chaindb.js @@ -1667,8 +1667,7 @@ class ChainDB { if (this.options.spv) return; - // Write actual block data (this may be - // better suited to flat files in the future). + // Write actual block data. await this.blocks.write(hash, block.toRaw()); if (!view) diff --git a/lib/blockstore/abstract.js b/lib/blockstore/abstract.js index e12d0488..efde8bd5 100644 --- a/lib/blockstore/abstract.js +++ b/lib/blockstore/abstract.js @@ -1,5 +1,5 @@ /*! - * blockstore/abstract.js - abstract block store for bcoin + * blockstore/abstract.js - abstract blockstore for bcoin * Copyright (c) 2019, Braydon Fuller (MIT License). * https://github.com/bcoin-org/bcoin */ @@ -52,7 +52,7 @@ class AbstractBlockStore { /** * This method closes resources and prepares - * store to be closed. + * the store to be closed. * @returns {Promise} */ diff --git a/lib/blockstore/common.js b/lib/blockstore/common.js index 3bfed645..f1cb310f 100644 --- a/lib/blockstore/common.js +++ b/lib/blockstore/common.js @@ -1,5 +1,5 @@ /*! - * common.js - block store constants for bcoin + * common.js - blockstore constants for bcoin * Copyright (c) 2019, Braydon Fuller (MIT License). * https://github.com/bcoin-org/bcoin */ @@ -11,7 +11,7 @@ */ /** - * Data types. + * Block data types. * @enum {Number} */ @@ -21,7 +21,7 @@ exports.types = { }; /** - * File prefixes for data types. + * File prefixes for block data types. * @enum {String} */ diff --git a/lib/blockstore/file.js b/lib/blockstore/file.js index 132a388f..5ebe2aa5 100644 --- a/lib/blockstore/file.js +++ b/lib/blockstore/file.js @@ -1,5 +1,5 @@ /*! - * blockstore/file.js - file block store for bcoin + * blockstore/file.js - file blockstore for bcoin * Copyright (c) 2019, Braydon Fuller (MIT License). * https://github.com/bcoin-org/bcoin */ @@ -157,7 +157,7 @@ class FileBlockStore extends AbstractBlockStore { /** * This closes the file block store and underlying - * databases for indexing. + * indexing databases. */ async close() { @@ -170,6 +170,7 @@ class FileBlockStore extends AbstractBlockStore { * This method will determine the file path based on the file number * and the current block data location. * @private + * @param {Number} type - The type of block data * @param {Number} fileno - The number of the file. * @returns {Promise} */ @@ -199,9 +200,10 @@ class FileBlockStore extends AbstractBlockStore { /** * This method will select and potentially allocate a file to - * write a block based on the size. + * write a block based on the size and type. * @private - * @param {Number} length - The number of bytes of the data to be written. + * @param {Number} type - The type of block data + * @param {Number} length - The number of bytes * @returns {Promise} */ @@ -280,6 +282,7 @@ class FileBlockStore extends AbstractBlockStore { * data to the last written file and updating indexes to point * to the file and position. * @private + * @param {Number} type - The type of block data * @param {Buffer} hash - The block hash * @param {Buffer} data - The block data * @returns {Promise} @@ -372,7 +375,7 @@ class FileBlockStore extends AbstractBlockStore { * This methods reads data from disk by retrieving the index of * the data and reading from the correponding file and location. * @private - * @param {Buffer} type - The data type + * @param {Number} type - The type of block data * @param {Buffer} hash - The block hash * @param {Number} offset - The offset within the block * @param {Number} length - The number of bytes of the data diff --git a/lib/blockstore/layout.js b/lib/blockstore/layout.js index 8b221d5c..ce5cf290 100644 --- a/lib/blockstore/layout.js +++ b/lib/blockstore/layout.js @@ -1,5 +1,5 @@ /*! - * blockstore/layout.js - file block store data layout for bcoin + * blockstore/layout.js - file blockstore data layout for bcoin * Copyright (c) 2019, Braydon Fuller (MIT License). * https://github.com/bcoin-org/bcoin */ @@ -11,7 +11,7 @@ const bdb = require('bdb'); /* * Database Layout: * V -> db version - * B[type] -> last file record by type + * F[type] -> last file record by type * f[type][fileno] -> file record by type and file number * b[type][hash] -> block record by type and block hash */ diff --git a/lib/blockstore/level.js b/lib/blockstore/level.js index f745e370..ebc09675 100644 --- a/lib/blockstore/level.js +++ b/lib/blockstore/level.js @@ -1,5 +1,5 @@ /*! - * blockstore/level.js - leveldb block store for bcoin + * blockstore/level.js - leveldb blockstore for bcoin * Copyright (c) 2019, Braydon Fuller (MIT License). * https://github.com/bcoin-org/bcoin */ diff --git a/lib/blockstore/records.js b/lib/blockstore/records.js index 1f75ce00..d387171b 100644 --- a/lib/blockstore/records.js +++ b/lib/blockstore/records.js @@ -1,5 +1,5 @@ /*! - * blockstore/records.js - block store records + * blockstore/records.js - blockstore records * Copyright (c) 2019, Braydon Fuller (MIT License). * https://github.com/bcoin-org/bcoin */ @@ -82,7 +82,7 @@ class BlockRecord { class FileRecord { /** - * Create a chain state. + * Create a file record. * @constructor */