@leofcoin/chain 1.4.32 → 1.4.34
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 +5 -3
- package/package.json +1 -1
package/exports/chain.js
CHANGED
|
@@ -610,7 +610,7 @@ class Chain extends Contract {
|
|
|
610
610
|
let promises = [];
|
|
611
611
|
let data = await new peernet.protos['peernet-request']({ request: 'lastBlock' });
|
|
612
612
|
let node = await peernet.prepareMessage(data);
|
|
613
|
-
for (const peer of peernet
|
|
613
|
+
for (const peer of peernet?.connections) {
|
|
614
614
|
if (peer.connected && peer.readyState === 'open' && peer.peerId !== this.id) {
|
|
615
615
|
promises.push(async () => {
|
|
616
616
|
try {
|
|
@@ -682,8 +682,10 @@ class Chain extends Contract {
|
|
|
682
682
|
this.#lastBlock = { ...localBlock.decoded, hash: await localBlock.hash() };
|
|
683
683
|
}
|
|
684
684
|
else {
|
|
685
|
-
|
|
686
|
-
|
|
685
|
+
if (globalThis.peernet?.connections.length > 0) {
|
|
686
|
+
const latestBlock = await this.#getLatestBlock();
|
|
687
|
+
await this.#syncChain(latestBlock);
|
|
688
|
+
}
|
|
687
689
|
}
|
|
688
690
|
}
|
|
689
691
|
catch (error) {
|