@leofcoin/chain 1.8.24 → 1.8.26
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 +27 -7
- package/exports/chain.js +27 -7
- package/package.json +1 -1
package/exports/browser/chain.js
CHANGED
|
@@ -5329,11 +5329,14 @@ class State extends Contract {
|
|
|
5329
5329
|
try {
|
|
5330
5330
|
await this.jobber.add(() => this.#resolveBlock(hash));
|
|
5331
5331
|
this.#resolving = false;
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5332
|
+
try {
|
|
5333
|
+
const lastBlockHash = await globalThis.stateStore.get('lastBlock');
|
|
5334
|
+
if (lastBlockHash === hash) {
|
|
5335
|
+
this.#resolveErrored = false;
|
|
5336
|
+
return;
|
|
5337
|
+
}
|
|
5336
5338
|
}
|
|
5339
|
+
catch (error) { }
|
|
5337
5340
|
if (!this.#blockHashMap.has(this.#lastResolved.previousHash) && this.#lastResolved.previousHash !== '0x0')
|
|
5338
5341
|
return this.resolveBlock(this.#lastResolved.previousHash);
|
|
5339
5342
|
}
|
|
@@ -5509,7 +5512,8 @@ class State extends Contract {
|
|
|
5509
5512
|
try {
|
|
5510
5513
|
const result = await peer.request(node.encoded);
|
|
5511
5514
|
debug$1({ result });
|
|
5512
|
-
|
|
5515
|
+
console.log({ result });
|
|
5516
|
+
return { result: new LastBlockMessage(result), peer };
|
|
5513
5517
|
}
|
|
5514
5518
|
catch (error) {
|
|
5515
5519
|
const peerId = peer?.peerId || peer?.id || peer?.address || 'unknown';
|
|
@@ -6395,7 +6399,15 @@ class Chain extends VersionControl {
|
|
|
6395
6399
|
if (lastBlock) {
|
|
6396
6400
|
if (!this.lastBlock || higherThenCurrentLocal) {
|
|
6397
6401
|
try {
|
|
6398
|
-
|
|
6402
|
+
let knownBlocksResponse = await this.#makeRequest(peer, 'knownBlocks');
|
|
6403
|
+
if (knownBlocksResponse instanceof Uint8Array) {
|
|
6404
|
+
try {
|
|
6405
|
+
knownBlocksResponse = JSON.parse(new TextDecoder().decode(knownBlocksResponse));
|
|
6406
|
+
}
|
|
6407
|
+
catch (e) {
|
|
6408
|
+
console.log(e);
|
|
6409
|
+
}
|
|
6410
|
+
}
|
|
6399
6411
|
if (knownBlocksResponse.blocks)
|
|
6400
6412
|
for (const hash of knownBlocksResponse.blocks) {
|
|
6401
6413
|
this.wantList.push(hash);
|
|
@@ -6431,7 +6443,15 @@ class Chain extends VersionControl {
|
|
|
6431
6443
|
}
|
|
6432
6444
|
}, 3000);
|
|
6433
6445
|
try {
|
|
6434
|
-
|
|
6446
|
+
let stateInfo = await this.#makeRequest(peer, 'stateInfo');
|
|
6447
|
+
if (stateInfo instanceof Uint8Array) {
|
|
6448
|
+
try {
|
|
6449
|
+
stateInfo = JSON.parse(new TextDecoder().decode(stateInfo));
|
|
6450
|
+
}
|
|
6451
|
+
catch (e) {
|
|
6452
|
+
console.log(e);
|
|
6453
|
+
}
|
|
6454
|
+
}
|
|
6435
6455
|
await this.syncChain(lastBlock);
|
|
6436
6456
|
this.machine.states.info = stateInfo;
|
|
6437
6457
|
}
|
package/exports/chain.js
CHANGED
|
@@ -1470,11 +1470,14 @@ class State extends Contract {
|
|
|
1470
1470
|
try {
|
|
1471
1471
|
await this.jobber.add(() => this.#resolveBlock(hash));
|
|
1472
1472
|
this.#resolving = false;
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1473
|
+
try {
|
|
1474
|
+
const lastBlockHash = await globalThis.stateStore.get('lastBlock');
|
|
1475
|
+
if (lastBlockHash === hash) {
|
|
1476
|
+
this.#resolveErrored = false;
|
|
1477
|
+
return;
|
|
1478
|
+
}
|
|
1477
1479
|
}
|
|
1480
|
+
catch (error) { }
|
|
1478
1481
|
if (!this.#blockHashMap.has(this.#lastResolved.previousHash) && this.#lastResolved.previousHash !== '0x0')
|
|
1479
1482
|
return this.resolveBlock(this.#lastResolved.previousHash);
|
|
1480
1483
|
}
|
|
@@ -1650,7 +1653,8 @@ class State extends Contract {
|
|
|
1650
1653
|
try {
|
|
1651
1654
|
const result = await peer.request(node.encoded);
|
|
1652
1655
|
debug$1({ result });
|
|
1653
|
-
|
|
1656
|
+
console.log({ result });
|
|
1657
|
+
return { result: new LastBlockMessage(result), peer };
|
|
1654
1658
|
}
|
|
1655
1659
|
catch (error) {
|
|
1656
1660
|
const peerId = peer?.peerId || peer?.id || peer?.address || 'unknown';
|
|
@@ -2536,7 +2540,15 @@ class Chain extends VersionControl {
|
|
|
2536
2540
|
if (lastBlock) {
|
|
2537
2541
|
if (!this.lastBlock || higherThenCurrentLocal) {
|
|
2538
2542
|
try {
|
|
2539
|
-
|
|
2543
|
+
let knownBlocksResponse = await this.#makeRequest(peer, 'knownBlocks');
|
|
2544
|
+
if (knownBlocksResponse instanceof Uint8Array) {
|
|
2545
|
+
try {
|
|
2546
|
+
knownBlocksResponse = JSON.parse(new TextDecoder().decode(knownBlocksResponse));
|
|
2547
|
+
}
|
|
2548
|
+
catch (e) {
|
|
2549
|
+
console.log(e);
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2540
2552
|
if (knownBlocksResponse.blocks)
|
|
2541
2553
|
for (const hash of knownBlocksResponse.blocks) {
|
|
2542
2554
|
this.wantList.push(hash);
|
|
@@ -2572,7 +2584,15 @@ class Chain extends VersionControl {
|
|
|
2572
2584
|
}
|
|
2573
2585
|
}, 3000);
|
|
2574
2586
|
try {
|
|
2575
|
-
|
|
2587
|
+
let stateInfo = await this.#makeRequest(peer, 'stateInfo');
|
|
2588
|
+
if (stateInfo instanceof Uint8Array) {
|
|
2589
|
+
try {
|
|
2590
|
+
stateInfo = JSON.parse(new TextDecoder().decode(stateInfo));
|
|
2591
|
+
}
|
|
2592
|
+
catch (e) {
|
|
2593
|
+
console.log(e);
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2576
2596
|
await this.syncChain(lastBlock);
|
|
2577
2597
|
this.machine.states.info = stateInfo;
|
|
2578
2598
|
}
|