@leofcoin/chain 1.8.24 → 1.8.25
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 +20 -3
- package/exports/chain.js +20 -3
- package/package.json +1 -1
package/exports/browser/chain.js
CHANGED
|
@@ -5509,7 +5509,8 @@ class State extends Contract {
|
|
|
5509
5509
|
try {
|
|
5510
5510
|
const result = await peer.request(node.encoded);
|
|
5511
5511
|
debug$1({ result });
|
|
5512
|
-
|
|
5512
|
+
console.log({ result });
|
|
5513
|
+
return { result: new LastBlockMessage(result), peer };
|
|
5513
5514
|
}
|
|
5514
5515
|
catch (error) {
|
|
5515
5516
|
const peerId = peer?.peerId || peer?.id || peer?.address || 'unknown';
|
|
@@ -6395,7 +6396,15 @@ class Chain extends VersionControl {
|
|
|
6395
6396
|
if (lastBlock) {
|
|
6396
6397
|
if (!this.lastBlock || higherThenCurrentLocal) {
|
|
6397
6398
|
try {
|
|
6398
|
-
|
|
6399
|
+
let knownBlocksResponse = await this.#makeRequest(peer, 'knownBlocks');
|
|
6400
|
+
if (knownBlocksResponse instanceof Uint8Array) {
|
|
6401
|
+
try {
|
|
6402
|
+
knownBlocksResponse = JSON.parse(new TextDecoder().decode(knownBlocksResponse));
|
|
6403
|
+
}
|
|
6404
|
+
catch (e) {
|
|
6405
|
+
console.log(e);
|
|
6406
|
+
}
|
|
6407
|
+
}
|
|
6399
6408
|
if (knownBlocksResponse.blocks)
|
|
6400
6409
|
for (const hash of knownBlocksResponse.blocks) {
|
|
6401
6410
|
this.wantList.push(hash);
|
|
@@ -6431,7 +6440,15 @@ class Chain extends VersionControl {
|
|
|
6431
6440
|
}
|
|
6432
6441
|
}, 3000);
|
|
6433
6442
|
try {
|
|
6434
|
-
|
|
6443
|
+
let stateInfo = await this.#makeRequest(peer, 'stateInfo');
|
|
6444
|
+
if (stateInfo instanceof Uint8Array) {
|
|
6445
|
+
try {
|
|
6446
|
+
stateInfo = JSON.parse(new TextDecoder().decode(stateInfo));
|
|
6447
|
+
}
|
|
6448
|
+
catch (e) {
|
|
6449
|
+
console.log(e);
|
|
6450
|
+
}
|
|
6451
|
+
}
|
|
6435
6452
|
await this.syncChain(lastBlock);
|
|
6436
6453
|
this.machine.states.info = stateInfo;
|
|
6437
6454
|
}
|
package/exports/chain.js
CHANGED
|
@@ -1650,7 +1650,8 @@ class State extends Contract {
|
|
|
1650
1650
|
try {
|
|
1651
1651
|
const result = await peer.request(node.encoded);
|
|
1652
1652
|
debug$1({ result });
|
|
1653
|
-
|
|
1653
|
+
console.log({ result });
|
|
1654
|
+
return { result: new LastBlockMessage(result), peer };
|
|
1654
1655
|
}
|
|
1655
1656
|
catch (error) {
|
|
1656
1657
|
const peerId = peer?.peerId || peer?.id || peer?.address || 'unknown';
|
|
@@ -2536,7 +2537,15 @@ class Chain extends VersionControl {
|
|
|
2536
2537
|
if (lastBlock) {
|
|
2537
2538
|
if (!this.lastBlock || higherThenCurrentLocal) {
|
|
2538
2539
|
try {
|
|
2539
|
-
|
|
2540
|
+
let knownBlocksResponse = await this.#makeRequest(peer, 'knownBlocks');
|
|
2541
|
+
if (knownBlocksResponse instanceof Uint8Array) {
|
|
2542
|
+
try {
|
|
2543
|
+
knownBlocksResponse = JSON.parse(new TextDecoder().decode(knownBlocksResponse));
|
|
2544
|
+
}
|
|
2545
|
+
catch (e) {
|
|
2546
|
+
console.log(e);
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2540
2549
|
if (knownBlocksResponse.blocks)
|
|
2541
2550
|
for (const hash of knownBlocksResponse.blocks) {
|
|
2542
2551
|
this.wantList.push(hash);
|
|
@@ -2572,7 +2581,15 @@ class Chain extends VersionControl {
|
|
|
2572
2581
|
}
|
|
2573
2582
|
}, 3000);
|
|
2574
2583
|
try {
|
|
2575
|
-
|
|
2584
|
+
let stateInfo = await this.#makeRequest(peer, 'stateInfo');
|
|
2585
|
+
if (stateInfo instanceof Uint8Array) {
|
|
2586
|
+
try {
|
|
2587
|
+
stateInfo = JSON.parse(new TextDecoder().decode(stateInfo));
|
|
2588
|
+
}
|
|
2589
|
+
catch (e) {
|
|
2590
|
+
console.log(e);
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2576
2593
|
await this.syncChain(lastBlock);
|
|
2577
2594
|
this.machine.states.info = stateInfo;
|
|
2578
2595
|
}
|