@leofcoin/chain 1.9.13 → 1.9.15
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/{browser-DTwbEd2v-BvEtTVTB.js → browser-8BFql6K9-BMRX6B2u.js} +3 -1
- package/exports/browser/{browser-AkMNdace-11JEjCcV.js → browser-FVp_QbaL-zB8FF4EN.js} +3 -1
- package/exports/browser/chain.js +112 -73
- package/exports/browser/client-lPe0SUWx-DR-mCTBz.js +2164 -0
- package/exports/browser/{index-C8MlQb3B-Cb0OaBTu.js → index-D6qd-AUn-CCzkkXys.js} +3 -1
- package/exports/browser/{messages-skO3uGkB-D-Ej3W9s.js → messages-BfDvXW-x-C-CI69S2.js} +2 -2
- package/exports/browser/{node-browser-Oq89xLSU.js → node-browser-y2adT6_R.js} +8370 -26
- package/exports/browser/node-browser.js +2 -2
- package/exports/chain.js +112 -73
- package/package.json +4 -4
- package/exports/browser/client-B5W9RVIn-DHAPaCMU.js +0 -1047
- package/exports/browser/identity-B8_RBemH-Dq17MYzU.js +0 -17530
- package/exports/browser/index-avzvc6cK-CDbEoIOc.js +0 -7595
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as getDefaultExportFromCjs } from './node-browser-y2adT6_R.js';
|
|
2
|
+
import 'crypto';
|
|
3
|
+
import './constants-V2VjIc2r.js';
|
|
2
4
|
|
|
3
5
|
function _mergeNamespaces$1(n, m) {
|
|
4
6
|
m.forEach(function (e) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as getDefaultExportFromCjs } from './node-browser-y2adT6_R.js';
|
|
2
|
+
import 'crypto';
|
|
3
|
+
import './constants-V2VjIc2r.js';
|
|
2
4
|
|
|
3
5
|
function _mergeNamespaces$1(n, m) {
|
|
4
6
|
m.forEach(function (e) {
|
package/exports/browser/chain.js
CHANGED
|
@@ -6116,22 +6116,22 @@ class Chain extends VersionControl {
|
|
|
6116
6116
|
#sleep(ms) {
|
|
6117
6117
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
6118
6118
|
}
|
|
6119
|
-
async #recordPeerFailure(
|
|
6120
|
-
if (!this.#peerReputations.has(
|
|
6121
|
-
this.#peerReputations.set(
|
|
6119
|
+
async #recordPeerFailure(peerId, reason) {
|
|
6120
|
+
if (!this.#peerReputations.has(peerId)) {
|
|
6121
|
+
this.#peerReputations.set(peerId, { score: 0, failures: [] });
|
|
6122
6122
|
}
|
|
6123
|
-
const rep = this.#peerReputations.get(
|
|
6123
|
+
const rep = this.#peerReputations.get(peerId);
|
|
6124
6124
|
rep.score -= 1;
|
|
6125
6125
|
rep.failures.push(`${Date.now()}: ${reason}`);
|
|
6126
6126
|
if (rep.failures.length > this.#maxPeerFailures) {
|
|
6127
6127
|
rep.failures.shift();
|
|
6128
6128
|
}
|
|
6129
6129
|
if (rep.score < this.#minPeerScore) {
|
|
6130
|
-
console.warn(`[peer-ban] Peer ${
|
|
6130
|
+
console.warn(`[peer-ban] Peer ${peerId} banned after ${rep.failures.length} failures`);
|
|
6131
6131
|
try {
|
|
6132
|
-
await globalThis.peernet.disconnect(
|
|
6132
|
+
await globalThis.peernet.disconnect(peerId);
|
|
6133
6133
|
} catch (e) {
|
|
6134
|
-
debug(`Failed to disconnect peer ${
|
|
6134
|
+
debug(`Failed to disconnect peer ${peerId}`);
|
|
6135
6135
|
}
|
|
6136
6136
|
}
|
|
6137
6137
|
}
|
|
@@ -6251,8 +6251,8 @@ class Chain extends VersionControl {
|
|
|
6251
6251
|
const start = Date.now();
|
|
6252
6252
|
try {
|
|
6253
6253
|
await this.#createBlock();
|
|
6254
|
-
} catch (
|
|
6255
|
-
console.error(
|
|
6254
|
+
} catch (error) {
|
|
6255
|
+
console.error(error);
|
|
6256
6256
|
}
|
|
6257
6257
|
const end = Date.now();
|
|
6258
6258
|
console.log((end - start) / 1e3 + " s");
|
|
@@ -6302,6 +6302,36 @@ class Chain extends VersionControl {
|
|
|
6302
6302
|
console.log("init");
|
|
6303
6303
|
await super.init();
|
|
6304
6304
|
console.log("super init done");
|
|
6305
|
+
const peernetAny = globalThis.peernet;
|
|
6306
|
+
if (typeof peernetAny.removePeer === "function" && !peernetAny.__chainRemovePeerGuardInstalled) {
|
|
6307
|
+
const originalRemovePeer = peernetAny.removePeer.bind(peernetAny);
|
|
6308
|
+
peernetAny.removePeer = async (peer) => {
|
|
6309
|
+
if (!peer || typeof peer !== "object") {
|
|
6310
|
+
debug("removePeer called with invalid peer (ignored)");
|
|
6311
|
+
return;
|
|
6312
|
+
}
|
|
6313
|
+
const peerId = peer?.id || peer?.peerId;
|
|
6314
|
+
if (!peerId || typeof peerId !== "string") {
|
|
6315
|
+
debug("removePeer called with peer missing id (ignored)");
|
|
6316
|
+
return;
|
|
6317
|
+
}
|
|
6318
|
+
const trackedPeers = Object.values(peernetAny.connections || {});
|
|
6319
|
+
const isStillTracked = trackedPeers.some((trackedPeer) => {
|
|
6320
|
+
const trackedId = trackedPeer?.id || trackedPeer?.peerId;
|
|
6321
|
+
return trackedPeer === peer || trackedId === peerId;
|
|
6322
|
+
});
|
|
6323
|
+
if (!isStillTracked) {
|
|
6324
|
+
debug(`removePeer called for unknown peer ${peerId} (ignored)`);
|
|
6325
|
+
return;
|
|
6326
|
+
}
|
|
6327
|
+
try {
|
|
6328
|
+
return await originalRemovePeer(peer);
|
|
6329
|
+
} catch (error) {
|
|
6330
|
+
debug("removePeer failed (ignored):", error?.message ?? error);
|
|
6331
|
+
}
|
|
6332
|
+
};
|
|
6333
|
+
peernetAny.__chainRemovePeerGuardInstalled = true;
|
|
6334
|
+
}
|
|
6305
6335
|
this.#connectionMonitor.start(this.version);
|
|
6306
6336
|
await globalThis.peernet.addRequestHandler("bw-request-message", () => {
|
|
6307
6337
|
const bw = globalThis.peernet.client?.bw || { up: 0, down: 0 };
|
|
@@ -6309,9 +6339,11 @@ class Chain extends VersionControl {
|
|
|
6309
6339
|
});
|
|
6310
6340
|
await globalThis.peernet.addRequestHandler("transactionPool", this.#transactionPoolHandler.bind(this));
|
|
6311
6341
|
await globalThis.peernet.addRequestHandler("version", this.#versionHandler.bind(this));
|
|
6312
|
-
await globalThis.peernet.addRequestHandler("stateInfo", () => {
|
|
6342
|
+
await globalThis.peernet.addRequestHandler("stateInfo", async () => {
|
|
6343
|
+
const lastblock = await this.lastBlock || { index: 0, hash: "0x0", previousHash: "0x0" };
|
|
6344
|
+
const values = this.machine?.states?.info || {};
|
|
6313
6345
|
return new globalThis.peernet.protos["peernet-response"]({
|
|
6314
|
-
response: new StateMessage(
|
|
6346
|
+
response: new StateMessage({ lastblock, values }).encoded
|
|
6315
6347
|
});
|
|
6316
6348
|
});
|
|
6317
6349
|
globalThis.peernet.subscribe("add-block", this.#addBlock.bind(this));
|
|
@@ -6367,10 +6399,10 @@ class Chain extends VersionControl {
|
|
|
6367
6399
|
console.warn(`Deprecated: ${response.decoded.response} is not an Uint8Array`);
|
|
6368
6400
|
}
|
|
6369
6401
|
return response.decoded.response;
|
|
6370
|
-
} catch (
|
|
6371
|
-
const
|
|
6372
|
-
debug(`peernet request failed: ${request} -> ${
|
|
6373
|
-
throw
|
|
6402
|
+
} catch (error) {
|
|
6403
|
+
const peerId = peer?.peerId || peer?.id || peer?.address || "unknown";
|
|
6404
|
+
debug(`peernet request failed: ${request} -> ${peerId}:`, error?.message ?? error);
|
|
6405
|
+
throw error;
|
|
6374
6406
|
}
|
|
6375
6407
|
}
|
|
6376
6408
|
async #decodeKnownBlocksResponse(response) {
|
|
@@ -6434,8 +6466,8 @@ class Chain extends VersionControl {
|
|
|
6434
6466
|
let txData;
|
|
6435
6467
|
try {
|
|
6436
6468
|
txData = await globalThis.peernet.get(key, "transaction");
|
|
6437
|
-
} catch (
|
|
6438
|
-
debug(`Failed to get transaction ${key}:`,
|
|
6469
|
+
} catch (error) {
|
|
6470
|
+
debug(`Failed to get transaction ${key}:`, error?.message ?? error);
|
|
6439
6471
|
}
|
|
6440
6472
|
if (txData !== void 0) {
|
|
6441
6473
|
transactionsToGet.push(transactionPoolStore.put(key, txData));
|
|
@@ -6444,13 +6476,23 @@ class Chain extends VersionControl {
|
|
|
6444
6476
|
}
|
|
6445
6477
|
return Promise.all(transactionsToGet);
|
|
6446
6478
|
}
|
|
6447
|
-
async #peerConnected(
|
|
6448
|
-
debug(`peer connected: ${
|
|
6449
|
-
const peer = peernet.getConnection(
|
|
6479
|
+
async #peerConnected(peerId) {
|
|
6480
|
+
debug(`peer connected: ${peerId}`);
|
|
6481
|
+
const peer = peernet.getConnection(peerId);
|
|
6450
6482
|
if (!peer) {
|
|
6451
|
-
debug(`peer not found: ${
|
|
6483
|
+
debug(`peer not found: ${peerId}`);
|
|
6452
6484
|
return;
|
|
6453
6485
|
}
|
|
6486
|
+
const peerAny = peer;
|
|
6487
|
+
if (typeof peerAny.on === "function" && !peerAny.__chainErrorListenerInstalled) {
|
|
6488
|
+
peerAny.on("error", async (error) => {
|
|
6489
|
+
const reason = error?.message ?? String(error);
|
|
6490
|
+
const peerName = peerAny?.peerId || peerAny?.id || peerAny?.address || peerId || "unknown";
|
|
6491
|
+
debug(`peer error: ${peerName}:`, reason);
|
|
6492
|
+
await this.#recordPeerFailure(peerId, `peer error: ${reason}`);
|
|
6493
|
+
});
|
|
6494
|
+
peerAny.__chainErrorListenerInstalled = true;
|
|
6495
|
+
}
|
|
6454
6496
|
if (!peer.version) {
|
|
6455
6497
|
try {
|
|
6456
6498
|
let versionResponse = await this.#makeRequest(peer, "version");
|
|
@@ -6463,13 +6505,13 @@ class Chain extends VersionControl {
|
|
|
6463
6505
|
peer.version = versionResponse.version;
|
|
6464
6506
|
}
|
|
6465
6507
|
if (!peer.version || typeof peer.version !== "string") {
|
|
6466
|
-
const reason = `invalid version response from peer ${
|
|
6508
|
+
const reason = `invalid version response from peer ${peerId}`;
|
|
6467
6509
|
debug(reason);
|
|
6468
|
-
await this.#recordPeerFailure(
|
|
6510
|
+
await this.#recordPeerFailure(peerId, reason);
|
|
6469
6511
|
return;
|
|
6470
6512
|
}
|
|
6471
|
-
} catch (
|
|
6472
|
-
debug(`failed to request version from peer ${
|
|
6513
|
+
} catch (error) {
|
|
6514
|
+
debug(`failed to request version from peer ${peerId}:`, error?.message ?? error);
|
|
6473
6515
|
return;
|
|
6474
6516
|
}
|
|
6475
6517
|
}
|
|
@@ -6477,7 +6519,7 @@ class Chain extends VersionControl {
|
|
|
6477
6519
|
if (!this.isVersionCompatible(peer.version)) {
|
|
6478
6520
|
const mismatchReason = `incompatible peer version ${peer.version} (local: ${this.version})`;
|
|
6479
6521
|
console.error(`[chain] ${mismatchReason}`);
|
|
6480
|
-
await this.#recordPeerFailure(
|
|
6522
|
+
await this.#recordPeerFailure(peerId, mismatchReason);
|
|
6481
6523
|
return;
|
|
6482
6524
|
}
|
|
6483
6525
|
let lastBlock;
|
|
@@ -6487,22 +6529,22 @@ class Chain extends VersionControl {
|
|
|
6487
6529
|
const lastBlockRaw = await this.#makeRequest(peer, "lastBlock");
|
|
6488
6530
|
console.log(new LastBlockMessage(lastBlockRaw));
|
|
6489
6531
|
lastBlock = new LastBlockMessage(lastBlockRaw).decoded;
|
|
6490
|
-
} catch (
|
|
6491
|
-
const
|
|
6492
|
-
debug(`lastBlock request failed: ${
|
|
6493
|
-
await this.#recordPeerFailure(
|
|
6532
|
+
} catch (error) {
|
|
6533
|
+
const peerName = peer?.peerId || peer?.id || peer?.address || peerId || "unknown";
|
|
6534
|
+
debug(`lastBlock request failed: ${peerName}:`, error?.message ?? error);
|
|
6535
|
+
await this.#recordPeerFailure(peerId, `lastBlock request failed: ${error?.message ?? error}`);
|
|
6494
6536
|
return;
|
|
6495
6537
|
}
|
|
6496
6538
|
const localBlock = await this.lastBlock;
|
|
6497
6539
|
const MAX_SYNC_AHEAD = 1e5;
|
|
6498
6540
|
if (lastBlock?.index > BigInt(localBlock?.index ?? 0) + BigInt(MAX_SYNC_AHEAD)) {
|
|
6499
|
-
const
|
|
6500
|
-
debug(`Peer ${
|
|
6501
|
-
await this.#recordPeerFailure(
|
|
6541
|
+
const peerName = peer?.peerId || peer?.id || peer?.address || peerId || "unknown";
|
|
6542
|
+
debug(`Peer ${peerName} claims unreasonable block height ${lastBlock.index} (local: ${localBlock?.index ?? 0})`);
|
|
6543
|
+
await this.#recordPeerFailure(peerId, `unreasonable lastBlock index: ${lastBlock.index}`);
|
|
6502
6544
|
return;
|
|
6503
6545
|
}
|
|
6504
6546
|
if (!lastBlock || !lastBlock.hash || lastBlock.hash === "0x0") {
|
|
6505
|
-
debug(`peer has no lastBlock: ${
|
|
6547
|
+
debug(`peer has no lastBlock: ${peerId}`);
|
|
6506
6548
|
return;
|
|
6507
6549
|
}
|
|
6508
6550
|
const higherThenCurrentLocal = !localBlock?.index ? true : lastBlock.index > localBlock.index;
|
|
@@ -6513,7 +6555,7 @@ class Chain extends VersionControl {
|
|
|
6513
6555
|
const knownBlocksResponse = await this.#decodeKnownBlocksResponse(knownBlocksRaw);
|
|
6514
6556
|
if (!knownBlocksResponse) {
|
|
6515
6557
|
debug(
|
|
6516
|
-
`knownBlocks decode failed for peer ${
|
|
6558
|
+
`knownBlocks decode failed for peer ${peerId} (non-fatal), continuing sync without prefilled wantList`
|
|
6517
6559
|
);
|
|
6518
6560
|
} else {
|
|
6519
6561
|
const MAX_WANTLIST_SIZE = 1e3;
|
|
@@ -6524,11 +6566,11 @@ class Chain extends VersionControl {
|
|
|
6524
6566
|
}
|
|
6525
6567
|
}
|
|
6526
6568
|
}
|
|
6527
|
-
} catch (
|
|
6528
|
-
const
|
|
6569
|
+
} catch (error) {
|
|
6570
|
+
const peerName = peer?.peerId || peer?.id || peer?.address || peerId || "unknown";
|
|
6529
6571
|
debug(
|
|
6530
|
-
`knownBlocks request failed: ${
|
|
6531
|
-
|
|
6572
|
+
`knownBlocks request failed: ${peerName} (non-fatal), continuing sync without prefilled wantList:`,
|
|
6573
|
+
error?.message ?? error
|
|
6532
6574
|
);
|
|
6533
6575
|
}
|
|
6534
6576
|
}
|
|
@@ -6545,28 +6587,29 @@ class Chain extends VersionControl {
|
|
|
6545
6587
|
try {
|
|
6546
6588
|
const peerTransactionPool = higherThenCurrentLocal && await this.getPeerTransactionPool(peer) || [];
|
|
6547
6589
|
if (this.#participating && peerTransactionPool.length > 0) return this.#runEpoch();
|
|
6548
|
-
} catch (
|
|
6549
|
-
const
|
|
6550
|
-
debug(`transactionPool request failed: ${
|
|
6590
|
+
} catch (error) {
|
|
6591
|
+
const peerName = peer?.peerId || peer?.id || peer?.address || peerId || "unknown";
|
|
6592
|
+
debug(`transactionPool request failed: ${peerName}:`, error?.message ?? error);
|
|
6551
6593
|
}
|
|
6552
6594
|
}, 3e3);
|
|
6553
6595
|
try {
|
|
6554
6596
|
let stateInfo = await this.#makeRequest(peer, "stateInfo");
|
|
6555
6597
|
if (stateInfo instanceof Uint8Array) {
|
|
6556
|
-
|
|
6598
|
+
const decodedStateInfo = new StateMessage(stateInfo).decoded;
|
|
6599
|
+
stateInfo = decodedStateInfo?.values ?? decodedStateInfo;
|
|
6557
6600
|
}
|
|
6558
6601
|
debug(
|
|
6559
|
-
`sync start with peer ${
|
|
6602
|
+
`sync start with peer ${peerId}: local=${localBlock?.index ?? -1} remote=${lastBlock?.index ?? -1} hash=${lastBlock?.hash}`
|
|
6560
6603
|
);
|
|
6561
6604
|
await this.syncChain(lastBlock);
|
|
6562
6605
|
debug(
|
|
6563
|
-
`sync finished with peer ${
|
|
6606
|
+
`sync finished with peer ${peerId}: state=${this.syncState} localNow=${(await this.lastBlock)?.index ?? -1}`
|
|
6564
6607
|
);
|
|
6565
6608
|
this.machine.states.info = stateInfo;
|
|
6566
|
-
} catch (
|
|
6567
|
-
const
|
|
6568
|
-
debug(`stateInfo/syncChain failed: ${
|
|
6569
|
-
await this.#recordPeerFailure(
|
|
6609
|
+
} catch (error) {
|
|
6610
|
+
const peerName = peer?.peerId || peer?.id || peer?.address || peerId || "unknown";
|
|
6611
|
+
debug(`stateInfo/syncChain failed: ${peerName}:`, error?.message ?? error);
|
|
6612
|
+
await this.#recordPeerFailure(peerId, `stateInfo/syncChain failed: ${error?.message ?? error}`);
|
|
6570
6613
|
return;
|
|
6571
6614
|
}
|
|
6572
6615
|
}
|
|
@@ -6582,19 +6625,16 @@ class Chain extends VersionControl {
|
|
|
6582
6625
|
try {
|
|
6583
6626
|
let result = await this.machine.execute(to, method, params);
|
|
6584
6627
|
globalThis.pubsub.publish(`transaction.completed.${hash}`, { status: "fulfilled", hash });
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
error?.message ?? error
|
|
6588
|
-
);
|
|
6589
|
-
} catch (error2) {
|
|
6628
|
+
return result || "no state change";
|
|
6629
|
+
} catch (error) {
|
|
6590
6630
|
await transactionPoolStore.delete(hash);
|
|
6591
6631
|
try {
|
|
6592
6632
|
globalThis.peernet.publish("invalid-transaction", hash);
|
|
6593
6633
|
} catch (publishError) {
|
|
6594
6634
|
debug("peernet publish failed: invalid-transaction", publishError?.message ?? publishError);
|
|
6595
6635
|
}
|
|
6596
|
-
globalThis.pubsub.publish(`transaction.completed.${hash}`, { status: "fail", hash, error
|
|
6597
|
-
throw { error
|
|
6636
|
+
globalThis.pubsub.publish(`transaction.completed.${hash}`, { status: "fail", hash, error });
|
|
6637
|
+
throw { error, hash, from, to, params, nonce };
|
|
6598
6638
|
}
|
|
6599
6639
|
}
|
|
6600
6640
|
async #addBlock(block) {
|
|
@@ -6605,7 +6645,6 @@ class Chain extends VersionControl {
|
|
|
6605
6645
|
const existingBlockAtHeight = this.#blocks[blockIndex];
|
|
6606
6646
|
if (existingBlockAtHeight) {
|
|
6607
6647
|
if (existingBlockAtHeight.hash !== hash) {
|
|
6608
|
-
debug(`knownBlocks decode failed for peer ${peerId} (non-fatal), continuing sync without prefilled wantList`);
|
|
6609
6648
|
console.error(` Local: ${existingBlockAtHeight.hash}`);
|
|
6610
6649
|
console.error(` Remote: ${hash}`);
|
|
6611
6650
|
throw new Error(`Block conflict detected at index ${blockIndex}`);
|
|
@@ -6713,10 +6752,10 @@ class Chain extends VersionControl {
|
|
|
6713
6752
|
await this.updateState(blockMessage);
|
|
6714
6753
|
}
|
|
6715
6754
|
globalThis.pubsub.publish("block-processed", blockMessage.decoded);
|
|
6716
|
-
} catch (
|
|
6717
|
-
console.log(
|
|
6755
|
+
} catch (error) {
|
|
6756
|
+
console.log(error.hash);
|
|
6718
6757
|
console.log("errrrr");
|
|
6719
|
-
await transactionPoolStore.delete(
|
|
6758
|
+
await transactionPoolStore.delete(error.hash);
|
|
6720
6759
|
}
|
|
6721
6760
|
}
|
|
6722
6761
|
async participate(address) {
|
|
@@ -6734,12 +6773,12 @@ class Chain extends VersionControl {
|
|
|
6734
6773
|
const transaction = await signTransaction(rawTransaction, globalThis.peernet.identity);
|
|
6735
6774
|
try {
|
|
6736
6775
|
await this.sendTransaction(transaction);
|
|
6737
|
-
} catch (
|
|
6738
|
-
console.error(
|
|
6776
|
+
} catch (error) {
|
|
6777
|
+
console.error(error);
|
|
6739
6778
|
}
|
|
6740
6779
|
}
|
|
6741
|
-
} catch (
|
|
6742
|
-
debug("Error in participate:",
|
|
6780
|
+
} catch (error) {
|
|
6781
|
+
debug("Error in participate:", error.message);
|
|
6743
6782
|
}
|
|
6744
6783
|
if (await this.hasTransactionToHandle() && !this.#runningEpoch && this.#participating) await this.#runEpoch();
|
|
6745
6784
|
}
|
|
@@ -6836,9 +6875,9 @@ class Chain extends VersionControl {
|
|
|
6836
6875
|
address: validator,
|
|
6837
6876
|
bw: bw.up + bw.down
|
|
6838
6877
|
};
|
|
6839
|
-
} catch (
|
|
6840
|
-
const
|
|
6841
|
-
debug(`bw request failed: ${
|
|
6878
|
+
} catch (error) {
|
|
6879
|
+
const peerId = peer?.peerId || peer?.id || peer?.address || "unknown";
|
|
6880
|
+
debug(`bw request failed: ${peerId}:`, error?.message ?? error);
|
|
6842
6881
|
return null;
|
|
6843
6882
|
}
|
|
6844
6883
|
} else if (globalThis.peernet.selectedAccount === validator) {
|
|
@@ -6856,8 +6895,8 @@ class Chain extends VersionControl {
|
|
|
6856
6895
|
}
|
|
6857
6896
|
}
|
|
6858
6897
|
};
|
|
6859
|
-
finalizeBWAndBroadcast().catch((
|
|
6860
|
-
debug(`background BW finalization failed:`,
|
|
6898
|
+
finalizeBWAndBroadcast().catch((error) => {
|
|
6899
|
+
debug(`background BW finalization failed:`, error?.message ?? error);
|
|
6861
6900
|
});
|
|
6862
6901
|
block.validators = block.validators.map((validator) => {
|
|
6863
6902
|
validator.reward = block.fees;
|
|
@@ -6922,8 +6961,8 @@ class Chain extends VersionControl {
|
|
|
6922
6961
|
debug("peernet publish failed: consensus:propose", publishError?.message ?? publishError);
|
|
6923
6962
|
}
|
|
6924
6963
|
await this.#castVote("prevote", hash, block.index, this.#consensusRound);
|
|
6925
|
-
} catch (
|
|
6926
|
-
console.log(
|
|
6964
|
+
} catch (error) {
|
|
6965
|
+
console.log(error);
|
|
6927
6966
|
throw new Error(`invalid block ${block}`);
|
|
6928
6967
|
}
|
|
6929
6968
|
}
|
|
@@ -7054,8 +7093,8 @@ class Chain extends VersionControl {
|
|
|
7054
7093
|
if (globalThis.peernet && globalThis.peernet.start) {
|
|
7055
7094
|
await globalThis.peernet.start();
|
|
7056
7095
|
}
|
|
7057
|
-
} catch (
|
|
7058
|
-
console.warn("Failed to reconnect to peers:",
|
|
7096
|
+
} catch (error) {
|
|
7097
|
+
console.warn("Failed to reconnect to peers:", error.message);
|
|
7059
7098
|
}
|
|
7060
7099
|
}
|
|
7061
7100
|
}
|