@leofcoin/chain 1.5.28 → 1.5.29
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 +7 -3
- package/exports/chain.js +7 -3
- package/exports/state.d.ts +0 -1
- package/package.json +1 -1
package/exports/browser/chain.js
CHANGED
|
@@ -1417,10 +1417,11 @@ class State extends Contract {
|
|
|
1417
1417
|
// console.log(e);
|
|
1418
1418
|
}
|
|
1419
1419
|
}
|
|
1420
|
-
destroyResolveJob() { }
|
|
1421
1420
|
async syncChain(lastBlock) {
|
|
1421
|
+
console.log('check if can sync');
|
|
1422
1422
|
if (!this.shouldSync)
|
|
1423
1423
|
return;
|
|
1424
|
+
console.log('starting sync');
|
|
1424
1425
|
this.#syncState = 'syncing';
|
|
1425
1426
|
this.#chainSyncing = true;
|
|
1426
1427
|
try {
|
|
@@ -1630,7 +1631,7 @@ class State extends Contract {
|
|
|
1630
1631
|
if (this.#resolveErrored ||
|
|
1631
1632
|
this.#syncState === 'errored' ||
|
|
1632
1633
|
this.#syncState === 'connectionless' ||
|
|
1633
|
-
|
|
1634
|
+
this.#lastResolvedTime + this.resolveTimeout > Date.now())
|
|
1634
1635
|
return true;
|
|
1635
1636
|
return false;
|
|
1636
1637
|
}
|
|
@@ -1833,11 +1834,14 @@ class Chain extends VersionControl {
|
|
|
1833
1834
|
async #peerConnected(peer) {
|
|
1834
1835
|
// todo handle version changes
|
|
1835
1836
|
// for now just do nothing if version doesn't match
|
|
1837
|
+
console.log(`${peer.version}, ${this.version}`);
|
|
1836
1838
|
if (!peer.version || peer.version !== this.version)
|
|
1837
1839
|
return;
|
|
1838
1840
|
const lastBlock = await this.#makeRequest(peer, 'lastBlock');
|
|
1839
|
-
|
|
1841
|
+
console.log(lastBlock);
|
|
1842
|
+
const higherThenCurrentLocal = !this.lastBlock?.index ? true : lastBlock.index > this.lastBlock?.index;
|
|
1840
1843
|
const peerTransactionPool = (higherThenCurrentLocal && (await this.getPeerTransactionPool(peer))) || [];
|
|
1844
|
+
console.log(this.lastBlock);
|
|
1841
1845
|
if (Object.keys(lastBlock).length > 0) {
|
|
1842
1846
|
if (!this.lastBlock || higherThenCurrentLocal) {
|
|
1843
1847
|
this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
|
package/exports/chain.js
CHANGED
|
@@ -853,10 +853,11 @@ class State extends Contract {
|
|
|
853
853
|
// console.log(e);
|
|
854
854
|
}
|
|
855
855
|
}
|
|
856
|
-
destroyResolveJob() { }
|
|
857
856
|
async syncChain(lastBlock) {
|
|
857
|
+
console.log('check if can sync');
|
|
858
858
|
if (!this.shouldSync)
|
|
859
859
|
return;
|
|
860
|
+
console.log('starting sync');
|
|
860
861
|
this.#syncState = 'syncing';
|
|
861
862
|
this.#chainSyncing = true;
|
|
862
863
|
try {
|
|
@@ -1066,7 +1067,7 @@ class State extends Contract {
|
|
|
1066
1067
|
if (this.#resolveErrored ||
|
|
1067
1068
|
this.#syncState === 'errored' ||
|
|
1068
1069
|
this.#syncState === 'connectionless' ||
|
|
1069
|
-
|
|
1070
|
+
this.#lastResolvedTime + this.resolveTimeout > Date.now())
|
|
1070
1071
|
return true;
|
|
1071
1072
|
return false;
|
|
1072
1073
|
}
|
|
@@ -1269,11 +1270,14 @@ class Chain extends VersionControl {
|
|
|
1269
1270
|
async #peerConnected(peer) {
|
|
1270
1271
|
// todo handle version changes
|
|
1271
1272
|
// for now just do nothing if version doesn't match
|
|
1273
|
+
console.log(`${peer.version}, ${this.version}`);
|
|
1272
1274
|
if (!peer.version || peer.version !== this.version)
|
|
1273
1275
|
return;
|
|
1274
1276
|
const lastBlock = await this.#makeRequest(peer, 'lastBlock');
|
|
1275
|
-
|
|
1277
|
+
console.log(lastBlock);
|
|
1278
|
+
const higherThenCurrentLocal = !this.lastBlock?.index ? true : lastBlock.index > this.lastBlock?.index;
|
|
1276
1279
|
const peerTransactionPool = (higherThenCurrentLocal && (await this.getPeerTransactionPool(peer))) || [];
|
|
1280
|
+
console.log(this.lastBlock);
|
|
1277
1281
|
if (Object.keys(lastBlock).length > 0) {
|
|
1278
1282
|
if (!this.lastBlock || higherThenCurrentLocal) {
|
|
1279
1283
|
this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
|
package/exports/state.d.ts
CHANGED
|
@@ -42,7 +42,6 @@ export default class State extends Contract {
|
|
|
42
42
|
resolveBlock(hash: any): any;
|
|
43
43
|
resolveBlocks(): Promise<any>;
|
|
44
44
|
restoreChain(): any;
|
|
45
|
-
destroyResolveJob(): void;
|
|
46
45
|
syncChain(lastBlock?: any): Promise<SyncState>;
|
|
47
46
|
promiseRequests(promises: any): Promise<unknown>;
|
|
48
47
|
get canSync(): boolean;
|