@leofcoin/chain 1.4.30 → 1.4.31
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/chain.js +2 -2
- package/package.json +1 -1
package/exports/chain.js
CHANGED
|
@@ -703,6 +703,7 @@ class Chain extends Contract {
|
|
|
703
703
|
async #syncChain(lastBlock) {
|
|
704
704
|
if (this.#chainSyncing || !lastBlock || !lastBlock.hash || !lastBlock.hash)
|
|
705
705
|
return;
|
|
706
|
+
this.#chainSyncing = true;
|
|
706
707
|
if (this.#knownBlocks?.length === Number(lastBlock.index) + 1) {
|
|
707
708
|
let promises = [];
|
|
708
709
|
promises = await Promise.allSettled(this.#knownBlocks.map(async (address) => {
|
|
@@ -713,7 +714,6 @@ class Chain extends Contract {
|
|
|
713
714
|
await Promise.allSettled(promises.map(({ value }) => peernet.get(value.address, 'block')));
|
|
714
715
|
}
|
|
715
716
|
if (!this.lastBlock || Number(this.lastBlock.index) < Number(lastBlock.index)) {
|
|
716
|
-
this.#chainSyncing = true;
|
|
717
717
|
// TODO: check if valid
|
|
718
718
|
const localIndex = this.lastBlock ? this.lastBlock.index : 0;
|
|
719
719
|
const index = lastBlock.index;
|
|
@@ -724,8 +724,8 @@ class Chain extends Contract {
|
|
|
724
724
|
const start = (this.#blocks.length - blocksSynced) - 1;
|
|
725
725
|
await this.#loadBlocks(this.blocks.slice(start));
|
|
726
726
|
await this.#updateState(new BlockMessage(this.#blocks[this.#blocks.length - 1]));
|
|
727
|
-
this.#chainSyncing = false;
|
|
728
727
|
}
|
|
728
|
+
this.#chainSyncing = false;
|
|
729
729
|
}
|
|
730
730
|
async #peerConnected(peer) {
|
|
731
731
|
let node = await new peernet.protos['peernet-request']({ request: 'lastBlock' });
|