diff --git a/strata.js b/strata.js index bff257d9..5cb8a38c 100644 --- a/strata.js +++ b/strata.js @@ -1498,7 +1498,7 @@ Sheaf.prototype.writeDelete = function (queue, page, index, callback) { } Sheaf.prototype.writeHeader = function (queue, page) { - var header = [ 0, ++page.entries, page.right ] + var header = [ ++page.entries, 0, page.right ] return this.writeEntry({ queue: queue, page: page, header: header, type: 'header' }) } @@ -1594,7 +1594,10 @@ prototype(Sheaf, 'replay', cadence(function (async, fd, stat, read, page, positi page.position += length var entry = this.readEntry(slice.slice(offset, offset + length), !leaf) var header = this.readHeader(entry) - if (entry.header[0]) { + if (entry.header[1] == 0) { + page.right = entry.header[2] + page.entries++ + } else { ok(header.entry == ++page.entries, 'entry count is off') var index = header.index if (leaf) { @@ -1621,9 +1624,6 @@ prototype(Sheaf, 'replay', cadence(function (async, fd, stat, read, page, positi key: key, address: address, heft: heft }) } - } else { - page.right = entry.header[2] - page.entries++ } i = offset = offset + length } diff --git a/t/basics/create.t.js b/t/basics/create.t.js index 6dc19821..c2e36493 100755 --- a/t/basics/create.t.js +++ b/t/basics/create.t.js @@ -17,7 +17,7 @@ function prove (async, assert) { vivify(tmp, async()) load(__dirname + '/fixtures/create.after.json', async()) }, function (actual, expected) { - assert.say(actual) + assert.say(actual[1]) assert.say(expected) assert(actual, expected, 'written') diff --git a/t/proof.js b/t/proof.js index 80a1b723..80ada3ef 100644 --- a/t/proof.js +++ b/t/proof.js @@ -159,7 +159,7 @@ function abstracted (dir) { position = 0 dir[file].forEach(function (line, index) { var json = line.header - if (json[0]) { + if (json[1]) { ok(index + 1 == json[0], 'entry record is wrong') if (json[1] > 0) { record.log.push({ type: 'add', value: line.body }) @@ -168,7 +168,7 @@ function abstracted (dir) { } } else { ok(index == 0, 'header not first entry') - ok(json[1] == 1, 'header not first entry') + ok(json[0] == 1, 'header not first entry') if (json[2]) record.right = Math.abs(json[2]) } }) @@ -310,7 +310,7 @@ function directivize (json) { position += length return record }) - directory[address].unshift({ header: [ 0, 1, object.right || 0 ]}) + directory[address].unshift({ header: [ 1, 0, object.right || 0 ]}) } }