@leofcoin/chain 1.6.3 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/exports/browser/chain.js +2 -2
- package/exports/chain.js +2 -2
- package/package.json +1 -1
package/exports/browser/chain.js
CHANGED
|
@@ -4467,7 +4467,7 @@ class State extends Contract {
|
|
|
4467
4467
|
if (block !== undefined) {
|
|
4468
4468
|
block = await new BlockMessage(block);
|
|
4469
4469
|
const { index } = block.decoded;
|
|
4470
|
-
if (this.#blocks[index
|
|
4470
|
+
if (this.#blocks[index] && this.#blocks[index].hash !== block.hash)
|
|
4471
4471
|
throw `invalid block ${hash} @${index}`;
|
|
4472
4472
|
if (!(await globalThis.peernet.has(hash)))
|
|
4473
4473
|
await globalThis.peernet.put(hash, block.encoded, 'block');
|
|
@@ -4628,7 +4628,7 @@ class State extends Contract {
|
|
|
4628
4628
|
const index = lastBlock.index;
|
|
4629
4629
|
await this.resolveBlock(lastBlock.hash);
|
|
4630
4630
|
console.log('ok');
|
|
4631
|
-
let blocksSynced = localIndex > 0 ? (localIndex > index ? localIndex - index : index + -localIndex) : index;
|
|
4631
|
+
let blocksSynced = localIndex > 0 ? (localIndex > index ? localIndex - index + 1 : index + -localIndex + 1) : index + 1;
|
|
4632
4632
|
debug$1(`synced ${blocksSynced} ${blocksSynced > 1 ? 'blocks' : 'block'}`);
|
|
4633
4633
|
const blocks = this.#blocks;
|
|
4634
4634
|
const start = blocks.length - blocksSynced;
|
package/exports/chain.js
CHANGED
|
@@ -835,7 +835,7 @@ class State extends Contract {
|
|
|
835
835
|
if (block !== undefined) {
|
|
836
836
|
block = await new BlockMessage(block);
|
|
837
837
|
const { index } = block.decoded;
|
|
838
|
-
if (this.#blocks[index
|
|
838
|
+
if (this.#blocks[index] && this.#blocks[index].hash !== block.hash)
|
|
839
839
|
throw `invalid block ${hash} @${index}`;
|
|
840
840
|
if (!(await globalThis.peernet.has(hash)))
|
|
841
841
|
await globalThis.peernet.put(hash, block.encoded, 'block');
|
|
@@ -996,7 +996,7 @@ class State extends Contract {
|
|
|
996
996
|
const index = lastBlock.index;
|
|
997
997
|
await this.resolveBlock(lastBlock.hash);
|
|
998
998
|
console.log('ok');
|
|
999
|
-
let blocksSynced = localIndex > 0 ? (localIndex > index ? localIndex - index : index + -localIndex) : index;
|
|
999
|
+
let blocksSynced = localIndex > 0 ? (localIndex > index ? localIndex - index + 1 : index + -localIndex + 1) : index + 1;
|
|
1000
1000
|
debug$1(`synced ${blocksSynced} ${blocksSynced > 1 ? 'blocks' : 'block'}`);
|
|
1001
1001
|
const blocks = this.#blocks;
|
|
1002
1002
|
const start = blocks.length - blocksSynced;
|