diff --git a/index.js b/index.js index 0c9937a..c2e498e 100644 --- a/index.js +++ b/index.js @@ -139,10 +139,13 @@ Blockchain.prototype.putBlocks = function (blocks, cb) { Blockchain.prototype.putBlock = function (block, cb, isGenesis) { const self = this - // perform put with mutex dance - lockUnlock(function (done) { - self._putBlock(block, done, isGenesis) - }, cb) + // make sure init has completed + self._initLock.await(() => { + // perform put with mutex dance + lockUnlock(function (done) { + self._putBlock(block, done, isGenesis) + }, cb) + }) // lock, call fn, unlock function lockUnlock (fn, cb) {