@leofcoin/chain 1.7.127 → 1.7.129
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 +5 -10
- package/exports/chain.js +5 -10
- package/package.json +1 -1
package/exports/browser/chain.js
CHANGED
|
@@ -4876,17 +4876,11 @@ class State extends Contract {
|
|
|
4876
4876
|
let block = await globalThis.peernet.get(hash, 'block');
|
|
4877
4877
|
if (block !== undefined) {
|
|
4878
4878
|
block = await new BlockMessage(block);
|
|
4879
|
-
const computedHash = await block.hash();
|
|
4880
|
-
if (computedHash !== hash) {
|
|
4881
|
-
throw new ResolveError(`block hash mismatch for ${hash}`, {
|
|
4882
|
-
cause: new Error('hash does not match payload')
|
|
4883
|
-
});
|
|
4884
|
-
}
|
|
4885
4879
|
const { index } = block.decoded;
|
|
4886
|
-
if (this.#blocks[index] && this.#blocks[index].hash !==
|
|
4887
|
-
throw
|
|
4888
|
-
if (!(await globalThis.peernet.has(
|
|
4889
|
-
await globalThis.peernet.put(
|
|
4880
|
+
if (this.#blocks[index] && this.#blocks[index].hash !== block.hash)
|
|
4881
|
+
throw `invalid block ${hash} @${index}`;
|
|
4882
|
+
if (!(await globalThis.peernet.has(hash)))
|
|
4883
|
+
await globalThis.peernet.put(hash, block.encoded, 'block');
|
|
4890
4884
|
}
|
|
4891
4885
|
return block;
|
|
4892
4886
|
}
|
|
@@ -5131,6 +5125,7 @@ class State extends Contract {
|
|
|
5131
5125
|
}
|
|
5132
5126
|
// @ts-ignore
|
|
5133
5127
|
promises = await this.promiseRequests(promises);
|
|
5128
|
+
console.log({ promises });
|
|
5134
5129
|
let latest = { index: 0, hash: '0x0', previousHash: '0x0' };
|
|
5135
5130
|
promises = promises.sort((a, b) => b.index - a.index);
|
|
5136
5131
|
if (promises.length > 0)
|
package/exports/chain.js
CHANGED
|
@@ -1003,17 +1003,11 @@ class State extends Contract {
|
|
|
1003
1003
|
let block = await globalThis.peernet.get(hash, 'block');
|
|
1004
1004
|
if (block !== undefined) {
|
|
1005
1005
|
block = await new BlockMessage(block);
|
|
1006
|
-
const computedHash = await block.hash();
|
|
1007
|
-
if (computedHash !== hash) {
|
|
1008
|
-
throw new ResolveError(`block hash mismatch for ${hash}`, {
|
|
1009
|
-
cause: new Error('hash does not match payload')
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
1006
|
const { index } = block.decoded;
|
|
1013
|
-
if (this.#blocks[index] && this.#blocks[index].hash !==
|
|
1014
|
-
throw
|
|
1015
|
-
if (!(await globalThis.peernet.has(
|
|
1016
|
-
await globalThis.peernet.put(
|
|
1007
|
+
if (this.#blocks[index] && this.#blocks[index].hash !== block.hash)
|
|
1008
|
+
throw `invalid block ${hash} @${index}`;
|
|
1009
|
+
if (!(await globalThis.peernet.has(hash)))
|
|
1010
|
+
await globalThis.peernet.put(hash, block.encoded, 'block');
|
|
1017
1011
|
}
|
|
1018
1012
|
return block;
|
|
1019
1013
|
}
|
|
@@ -1258,6 +1252,7 @@ class State extends Contract {
|
|
|
1258
1252
|
}
|
|
1259
1253
|
// @ts-ignore
|
|
1260
1254
|
promises = await this.promiseRequests(promises);
|
|
1255
|
+
console.log({ promises });
|
|
1261
1256
|
let latest = { index: 0, hash: '0x0', previousHash: '0x0' };
|
|
1262
1257
|
promises = promises.sort((a, b) => b.index - a.index);
|
|
1263
1258
|
if (promises.length > 0)
|