@bsv/wallet-toolbox 1.6.15 → 1.6.16

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/docs/client.md CHANGED
@@ -9422,130 +9422,142 @@ export class Chaintracks implements ChaintracksManagementApi {
9422
9422
  const cdnSyncRepeatMsecs = 24 * 60 * 60 * 1000;
9423
9423
  const syncCheckRepeatMsecs = 30 * 60 * 1000;
9424
9424
  while (!this.stopMainThread) {
9425
- const now = Date.now();
9426
- lastSyncCheck = now;
9427
- const presentHeight = await this.getPresentHeight();
9428
- const before = await this.storage.getAvailableHeightRanges();
9429
- let skipBulkSync = !before.live.isEmpty && before.live.maxHeight >= presentHeight - this.addLiveRecursionLimit / 2;
9430
- if (skipBulkSync && now - lastSyncCheck > cdnSyncRepeatMsecs) {
9431
- skipBulkSync = false;
9432
- }
9433
- this.log(`Chaintracks Update Services: Bulk Header Sync Review
9425
+ try {
9426
+ const now = Date.now();
9427
+ lastSyncCheck = now;
9428
+ const presentHeight = await this.getPresentHeight();
9429
+ const before = await this.storage.getAvailableHeightRanges();
9430
+ let skipBulkSync = !before.live.isEmpty && before.live.maxHeight >= presentHeight - this.addLiveRecursionLimit / 2;
9431
+ if (skipBulkSync && now - lastSyncCheck > cdnSyncRepeatMsecs) {
9432
+ skipBulkSync = false;
9433
+ }
9434
+ this.log(`Chaintracks Update Services: Bulk Header Sync Review
9434
9435
  presentHeight=${presentHeight} addLiveRecursionLimit=${this.addLiveRecursionLimit}
9435
9436
  Before synchronize: bulk ${before.bulk}, live ${before.live}
9436
9437
  ${skipBulkSync ? "Skipping" : "Starting"} syncBulkStorage.
9437
9438
  `);
9438
- if (!skipBulkSync) {
9439
- lastBulkSync = now;
9440
- if (this.available)
9441
- await this.syncBulkStorage(presentHeight, before);
9442
- else
9443
- await this.syncBulkStorageNoLock(presentHeight, before);
9444
- }
9445
- let count = 0;
9446
- let liveHeaderDupes = 0;
9447
- let needSyncCheck = false;
9448
- for (; !needSyncCheck && !this.stopMainThread;) {
9449
- let header = this.liveHeaders.shift();
9450
- if (header) {
9451
- let recursions = this.addLiveRecursionLimit;
9452
- for (; !needSyncCheck && !this.stopMainThread;) {
9453
- const ihr = await this.addLiveHeader(header);
9454
- if (this.invalidInsertHeaderResult(ihr)) {
9455
- this.log(`Ignoring liveHeader ${header.height} ${header.hash} due to invalid insert result.`);
9456
- needSyncCheck = true;
9457
- }
9458
- else if (ihr.noPrev) {
9459
- if (recursions-- <= 0) {
9460
- this.log(`Ignoring liveHeader ${header.height} ${header.hash} addLiveRecursionLimit=${this.addLiveRecursionLimit} exceeded.`);
9439
+ if (!skipBulkSync) {
9440
+ lastBulkSync = now;
9441
+ if (this.available)
9442
+ await this.syncBulkStorage(presentHeight, before);
9443
+ else
9444
+ await this.syncBulkStorageNoLock(presentHeight, before);
9445
+ }
9446
+ let count = 0;
9447
+ let liveHeaderDupes = 0;
9448
+ let needSyncCheck = false;
9449
+ for (; !needSyncCheck && !this.stopMainThread;) {
9450
+ let header = this.liveHeaders.shift();
9451
+ if (header) {
9452
+ let recursions = this.addLiveRecursionLimit;
9453
+ for (; !needSyncCheck && !this.stopMainThread;) {
9454
+ const ihr = await this.addLiveHeader(header);
9455
+ if (this.invalidInsertHeaderResult(ihr)) {
9456
+ this.log(`Ignoring liveHeader ${header.height} ${header.hash} due to invalid insert result.`);
9461
9457
  needSyncCheck = true;
9462
9458
  }
9463
- else {
9464
- const hash = header.previousHash;
9465
- const prevHeader = await this.getMissingBlockHeader(hash);
9466
- if (!prevHeader) {
9467
- this.log(`Ignoring liveHeader ${header.height} ${header.hash} failed to find previous header by hash ${asString(hash)}`);
9459
+ else if (ihr.noPrev) {
9460
+ if (recursions-- <= 0) {
9461
+ this.log(`Ignoring liveHeader ${header.height} ${header.hash} addLiveRecursionLimit=${this.addLiveRecursionLimit} exceeded.`);
9468
9462
  needSyncCheck = true;
9469
9463
  }
9470
9464
  else {
9471
- this.liveHeaders.unshift(header);
9472
- header = prevHeader;
9465
+ const hash = header.previousHash;
9466
+ const prevHeader = await this.getMissingBlockHeader(hash);
9467
+ if (!prevHeader) {
9468
+ this.log(`Ignoring liveHeader ${header.height} ${header.hash} failed to find previous header by hash ${asString(hash)}`);
9469
+ needSyncCheck = true;
9470
+ }
9471
+ else {
9472
+ this.liveHeaders.unshift(header);
9473
+ header = prevHeader;
9474
+ }
9473
9475
  }
9474
9476
  }
9475
- }
9476
- else {
9477
- if (this.subscriberCallbacksEnabled)
9478
- this.log(`addLiveHeader ${header.height}${ihr.added ? " added" : ""}${ihr.dupe ? " dupe" : ""}${ihr.isActiveTip ? " isActiveTip" : ""}${ihr.reorgDepth ? " reorg depth " + ihr.reorgDepth : ""}${ihr.noPrev ? " noPrev" : ""}${ihr.noActiveAncestor || ihr.noTip || ihr.badPrev ? " error" : ""}`);
9479
- if (ihr.dupe) {
9480
- liveHeaderDupes++;
9481
- }
9482
- if (ihr.added) {
9483
- count++;
9484
- }
9485
- break;
9486
- }
9487
- }
9488
- }
9489
- else {
9490
- const bheader = this.baseHeaders.shift();
9491
- if (bheader) {
9492
- const prev = await this.storage.findLiveHeaderForBlockHash(bheader.previousHash);
9493
- if (!prev) {
9494
- this.log(`Ignoring header with unknown previousHash ${bheader.previousHash} in live storage.`);
9495
- }
9496
- else {
9497
- const header: BlockHeader = {
9498
- ...bheader,
9499
- height: prev.height + 1,
9500
- hash: blockHash(bheader)
9501
- };
9502
- const ihr = await this.addLiveHeader(header);
9503
- if (this.invalidInsertHeaderResult(ihr)) {
9504
- this.log(`Ignoring invalid baseHeader ${header.height} ${header.hash}.`);
9505
- }
9506
9477
  else {
9507
9478
  if (this.subscriberCallbacksEnabled)
9508
- this.log(`addBaseHeader ${header.height}${ihr.added ? " added" : ""}${ihr.dupe ? " dupe" : ""}${ihr.isActiveTip ? " isActiveTip" : ""}${ihr.reorgDepth ? " reorg depth " + ihr.reorgDepth : ""}${ihr.noPrev ? " noPrev" : ""}${ihr.noActiveAncestor || ihr.noTip || ihr.badPrev ? " error" : ""}`);
9479
+ this.log(`addLiveHeader ${header.height}${ihr.added ? " added" : ""}${ihr.dupe ? " dupe" : ""}${ihr.isActiveTip ? " isActiveTip" : ""}${ihr.reorgDepth ? " reorg depth " + ihr.reorgDepth : ""}${ihr.noPrev ? " noPrev" : ""}${ihr.noActiveAncestor || ihr.noTip || ihr.badPrev ? " error" : ""}`);
9480
+ if (ihr.dupe) {
9481
+ liveHeaderDupes++;
9482
+ }
9509
9483
  if (ihr.added) {
9510
9484
  count++;
9511
9485
  }
9486
+ break;
9512
9487
  }
9513
9488
  }
9514
9489
  }
9515
9490
  else {
9516
- if (count > 0) {
9517
- if (liveHeaderDupes > 0) {
9518
- this.log(`${liveHeaderDupes} duplicate headers ignored.`);
9519
- liveHeaderDupes = 0;
9491
+ const bheader = this.baseHeaders.shift();
9492
+ if (bheader) {
9493
+ const prev = await this.storage.findLiveHeaderForBlockHash(bheader.previousHash);
9494
+ if (!prev) {
9495
+ this.log(`Ignoring header with unknown previousHash ${bheader.previousHash} in live storage.`);
9496
+ }
9497
+ else {
9498
+ const header: BlockHeader = {
9499
+ ...bheader,
9500
+ height: prev.height + 1,
9501
+ hash: blockHash(bheader)
9502
+ };
9503
+ const ihr = await this.addLiveHeader(header);
9504
+ if (this.invalidInsertHeaderResult(ihr)) {
9505
+ this.log(`Ignoring invalid baseHeader ${header.height} ${header.hash}.`);
9506
+ }
9507
+ else {
9508
+ if (this.subscriberCallbacksEnabled)
9509
+ this.log(`addBaseHeader ${header.height}${ihr.added ? " added" : ""}${ihr.dupe ? " dupe" : ""}${ihr.isActiveTip ? " isActiveTip" : ""}${ihr.reorgDepth ? " reorg depth " + ihr.reorgDepth : ""}${ihr.noPrev ? " noPrev" : ""}${ihr.noActiveAncestor || ihr.noTip || ihr.badPrev ? " error" : ""}`);
9510
+ if (ihr.added) {
9511
+ count++;
9512
+ }
9513
+ }
9520
9514
  }
9521
- const updated = await this.storage.getAvailableHeightRanges();
9522
- this.log(`After adding ${count} live headers
9515
+ }
9516
+ else {
9517
+ if (count > 0) {
9518
+ if (liveHeaderDupes > 0) {
9519
+ this.log(`${liveHeaderDupes} duplicate headers ignored.`);
9520
+ liveHeaderDupes = 0;
9521
+ }
9522
+ const updated = await this.storage.getAvailableHeightRanges();
9523
+ this.log(`After adding ${count} live headers
9523
9524
  After live: bulk ${updated.bulk}, live ${updated.live}
9524
9525
  `);
9525
- count = 0;
9526
- }
9527
- if (!this.subscriberCallbacksEnabled) {
9528
- const live = await this.storage.findLiveHeightRange();
9529
- if (!live.isEmpty) {
9530
- this.subscriberCallbacksEnabled = true;
9531
- this.log(`listening at height of ${live.maxHeight}`);
9526
+ count = 0;
9532
9527
  }
9528
+ if (!this.subscriberCallbacksEnabled) {
9529
+ const live = await this.storage.findLiveHeightRange();
9530
+ if (!live.isEmpty) {
9531
+ this.subscriberCallbacksEnabled = true;
9532
+ this.log(`listening at height of ${live.maxHeight}`);
9533
+ }
9534
+ }
9535
+ if (!this.available) {
9536
+ this.available = true;
9537
+ }
9538
+ needSyncCheck = Date.now() - lastSyncCheck > syncCheckRepeatMsecs;
9539
+ if (!needSyncCheck)
9540
+ await wait(1000);
9533
9541
  }
9534
- if (!this.available) {
9535
- this.available = true;
9536
- }
9537
- needSyncCheck = Date.now() - lastSyncCheck > syncCheckRepeatMsecs;
9538
- if (!needSyncCheck)
9539
- await wait(1000);
9540
9542
  }
9541
9543
  }
9542
9544
  }
9545
+ catch (eu: unknown) {
9546
+ const e = WalletError.fromUnknown(eu);
9547
+ if (!this.available) {
9548
+ this.startupError = e;
9549
+ this.stopMainThread = true;
9550
+ }
9551
+ else {
9552
+ this.log(`Error occurred during chaintracks main thread processing: ${e.stack || e.message}`);
9553
+ }
9554
+ }
9543
9555
  }
9544
9556
  }
9545
9557
  }
9546
9558
  ```
9547
9559
 
9548
- See also: [BaseBlockHeader](./client.md#interface-baseblockheader), [BlockHeader](./client.md#interface-blockheader), [Chain](./client.md#type-chain), [ChaintracksFsApi](./services.md#interface-chaintracksfsapi), [ChaintracksInfoApi](./services.md#interface-chaintracksinfoapi), [ChaintracksManagementApi](./services.md#interface-chaintracksmanagementapi), [ChaintracksOptions](./services.md#interface-chaintracksoptions), [HeaderListener](./services.md#type-headerlistener), [HeightRange](./services.md#class-heightrange), [HeightRanges](./services.md#interface-heightranges), [LiveBlockHeader](./services.md#interface-liveblockheader), [ReorgListener](./services.md#type-reorglistener), [Services](./services.md#class-services), [asString](./client.md#function-asstring), [blockHash](./services.md#function-blockhash), [wait](./client.md#function-wait)
9560
+ See also: [BaseBlockHeader](./client.md#interface-baseblockheader), [BlockHeader](./client.md#interface-blockheader), [Chain](./client.md#type-chain), [ChaintracksFsApi](./services.md#interface-chaintracksfsapi), [ChaintracksInfoApi](./services.md#interface-chaintracksinfoapi), [ChaintracksManagementApi](./services.md#interface-chaintracksmanagementapi), [ChaintracksOptions](./services.md#interface-chaintracksoptions), [HeaderListener](./services.md#type-headerlistener), [HeightRange](./services.md#class-heightrange), [HeightRanges](./services.md#interface-heightranges), [LiveBlockHeader](./services.md#interface-liveblockheader), [ReorgListener](./services.md#type-reorglistener), [Services](./services.md#class-services), [WalletError](./client.md#class-walleterror), [asString](./client.md#function-asstring), [blockHash](./services.md#function-blockhash), [wait](./client.md#function-wait)
9549
9561
 
9550
9562
  ###### Method addHeader
9551
9563
 
package/docs/services.md CHANGED
@@ -3499,130 +3499,142 @@ export class Chaintracks implements ChaintracksManagementApi {
3499
3499
  const cdnSyncRepeatMsecs = 24 * 60 * 60 * 1000;
3500
3500
  const syncCheckRepeatMsecs = 30 * 60 * 1000;
3501
3501
  while (!this.stopMainThread) {
3502
- const now = Date.now();
3503
- lastSyncCheck = now;
3504
- const presentHeight = await this.getPresentHeight();
3505
- const before = await this.storage.getAvailableHeightRanges();
3506
- let skipBulkSync = !before.live.isEmpty && before.live.maxHeight >= presentHeight - this.addLiveRecursionLimit / 2;
3507
- if (skipBulkSync && now - lastSyncCheck > cdnSyncRepeatMsecs) {
3508
- skipBulkSync = false;
3509
- }
3510
- this.log(`Chaintracks Update Services: Bulk Header Sync Review
3502
+ try {
3503
+ const now = Date.now();
3504
+ lastSyncCheck = now;
3505
+ const presentHeight = await this.getPresentHeight();
3506
+ const before = await this.storage.getAvailableHeightRanges();
3507
+ let skipBulkSync = !before.live.isEmpty && before.live.maxHeight >= presentHeight - this.addLiveRecursionLimit / 2;
3508
+ if (skipBulkSync && now - lastSyncCheck > cdnSyncRepeatMsecs) {
3509
+ skipBulkSync = false;
3510
+ }
3511
+ this.log(`Chaintracks Update Services: Bulk Header Sync Review
3511
3512
  presentHeight=${presentHeight} addLiveRecursionLimit=${this.addLiveRecursionLimit}
3512
3513
  Before synchronize: bulk ${before.bulk}, live ${before.live}
3513
3514
  ${skipBulkSync ? "Skipping" : "Starting"} syncBulkStorage.
3514
3515
  `);
3515
- if (!skipBulkSync) {
3516
- lastBulkSync = now;
3517
- if (this.available)
3518
- await this.syncBulkStorage(presentHeight, before);
3519
- else
3520
- await this.syncBulkStorageNoLock(presentHeight, before);
3521
- }
3522
- let count = 0;
3523
- let liveHeaderDupes = 0;
3524
- let needSyncCheck = false;
3525
- for (; !needSyncCheck && !this.stopMainThread;) {
3526
- let header = this.liveHeaders.shift();
3527
- if (header) {
3528
- let recursions = this.addLiveRecursionLimit;
3529
- for (; !needSyncCheck && !this.stopMainThread;) {
3530
- const ihr = await this.addLiveHeader(header);
3531
- if (this.invalidInsertHeaderResult(ihr)) {
3532
- this.log(`Ignoring liveHeader ${header.height} ${header.hash} due to invalid insert result.`);
3533
- needSyncCheck = true;
3534
- }
3535
- else if (ihr.noPrev) {
3536
- if (recursions-- <= 0) {
3537
- this.log(`Ignoring liveHeader ${header.height} ${header.hash} addLiveRecursionLimit=${this.addLiveRecursionLimit} exceeded.`);
3516
+ if (!skipBulkSync) {
3517
+ lastBulkSync = now;
3518
+ if (this.available)
3519
+ await this.syncBulkStorage(presentHeight, before);
3520
+ else
3521
+ await this.syncBulkStorageNoLock(presentHeight, before);
3522
+ }
3523
+ let count = 0;
3524
+ let liveHeaderDupes = 0;
3525
+ let needSyncCheck = false;
3526
+ for (; !needSyncCheck && !this.stopMainThread;) {
3527
+ let header = this.liveHeaders.shift();
3528
+ if (header) {
3529
+ let recursions = this.addLiveRecursionLimit;
3530
+ for (; !needSyncCheck && !this.stopMainThread;) {
3531
+ const ihr = await this.addLiveHeader(header);
3532
+ if (this.invalidInsertHeaderResult(ihr)) {
3533
+ this.log(`Ignoring liveHeader ${header.height} ${header.hash} due to invalid insert result.`);
3538
3534
  needSyncCheck = true;
3539
3535
  }
3540
- else {
3541
- const hash = header.previousHash;
3542
- const prevHeader = await this.getMissingBlockHeader(hash);
3543
- if (!prevHeader) {
3544
- this.log(`Ignoring liveHeader ${header.height} ${header.hash} failed to find previous header by hash ${asString(hash)}`);
3536
+ else if (ihr.noPrev) {
3537
+ if (recursions-- <= 0) {
3538
+ this.log(`Ignoring liveHeader ${header.height} ${header.hash} addLiveRecursionLimit=${this.addLiveRecursionLimit} exceeded.`);
3545
3539
  needSyncCheck = true;
3546
3540
  }
3547
3541
  else {
3548
- this.liveHeaders.unshift(header);
3549
- header = prevHeader;
3542
+ const hash = header.previousHash;
3543
+ const prevHeader = await this.getMissingBlockHeader(hash);
3544
+ if (!prevHeader) {
3545
+ this.log(`Ignoring liveHeader ${header.height} ${header.hash} failed to find previous header by hash ${asString(hash)}`);
3546
+ needSyncCheck = true;
3547
+ }
3548
+ else {
3549
+ this.liveHeaders.unshift(header);
3550
+ header = prevHeader;
3551
+ }
3550
3552
  }
3551
3553
  }
3552
- }
3553
- else {
3554
- if (this.subscriberCallbacksEnabled)
3555
- this.log(`addLiveHeader ${header.height}${ihr.added ? " added" : ""}${ihr.dupe ? " dupe" : ""}${ihr.isActiveTip ? " isActiveTip" : ""}${ihr.reorgDepth ? " reorg depth " + ihr.reorgDepth : ""}${ihr.noPrev ? " noPrev" : ""}${ihr.noActiveAncestor || ihr.noTip || ihr.badPrev ? " error" : ""}`);
3556
- if (ihr.dupe) {
3557
- liveHeaderDupes++;
3558
- }
3559
- if (ihr.added) {
3560
- count++;
3561
- }
3562
- break;
3563
- }
3564
- }
3565
- }
3566
- else {
3567
- const bheader = this.baseHeaders.shift();
3568
- if (bheader) {
3569
- const prev = await this.storage.findLiveHeaderForBlockHash(bheader.previousHash);
3570
- if (!prev) {
3571
- this.log(`Ignoring header with unknown previousHash ${bheader.previousHash} in live storage.`);
3572
- }
3573
- else {
3574
- const header: BlockHeader = {
3575
- ...bheader,
3576
- height: prev.height + 1,
3577
- hash: blockHash(bheader)
3578
- };
3579
- const ihr = await this.addLiveHeader(header);
3580
- if (this.invalidInsertHeaderResult(ihr)) {
3581
- this.log(`Ignoring invalid baseHeader ${header.height} ${header.hash}.`);
3582
- }
3583
3554
  else {
3584
3555
  if (this.subscriberCallbacksEnabled)
3585
- this.log(`addBaseHeader ${header.height}${ihr.added ? " added" : ""}${ihr.dupe ? " dupe" : ""}${ihr.isActiveTip ? " isActiveTip" : ""}${ihr.reorgDepth ? " reorg depth " + ihr.reorgDepth : ""}${ihr.noPrev ? " noPrev" : ""}${ihr.noActiveAncestor || ihr.noTip || ihr.badPrev ? " error" : ""}`);
3556
+ this.log(`addLiveHeader ${header.height}${ihr.added ? " added" : ""}${ihr.dupe ? " dupe" : ""}${ihr.isActiveTip ? " isActiveTip" : ""}${ihr.reorgDepth ? " reorg depth " + ihr.reorgDepth : ""}${ihr.noPrev ? " noPrev" : ""}${ihr.noActiveAncestor || ihr.noTip || ihr.badPrev ? " error" : ""}`);
3557
+ if (ihr.dupe) {
3558
+ liveHeaderDupes++;
3559
+ }
3586
3560
  if (ihr.added) {
3587
3561
  count++;
3588
3562
  }
3563
+ break;
3589
3564
  }
3590
3565
  }
3591
3566
  }
3592
3567
  else {
3593
- if (count > 0) {
3594
- if (liveHeaderDupes > 0) {
3595
- this.log(`${liveHeaderDupes} duplicate headers ignored.`);
3596
- liveHeaderDupes = 0;
3568
+ const bheader = this.baseHeaders.shift();
3569
+ if (bheader) {
3570
+ const prev = await this.storage.findLiveHeaderForBlockHash(bheader.previousHash);
3571
+ if (!prev) {
3572
+ this.log(`Ignoring header with unknown previousHash ${bheader.previousHash} in live storage.`);
3573
+ }
3574
+ else {
3575
+ const header: BlockHeader = {
3576
+ ...bheader,
3577
+ height: prev.height + 1,
3578
+ hash: blockHash(bheader)
3579
+ };
3580
+ const ihr = await this.addLiveHeader(header);
3581
+ if (this.invalidInsertHeaderResult(ihr)) {
3582
+ this.log(`Ignoring invalid baseHeader ${header.height} ${header.hash}.`);
3583
+ }
3584
+ else {
3585
+ if (this.subscriberCallbacksEnabled)
3586
+ this.log(`addBaseHeader ${header.height}${ihr.added ? " added" : ""}${ihr.dupe ? " dupe" : ""}${ihr.isActiveTip ? " isActiveTip" : ""}${ihr.reorgDepth ? " reorg depth " + ihr.reorgDepth : ""}${ihr.noPrev ? " noPrev" : ""}${ihr.noActiveAncestor || ihr.noTip || ihr.badPrev ? " error" : ""}`);
3587
+ if (ihr.added) {
3588
+ count++;
3589
+ }
3590
+ }
3597
3591
  }
3598
- const updated = await this.storage.getAvailableHeightRanges();
3599
- this.log(`After adding ${count} live headers
3592
+ }
3593
+ else {
3594
+ if (count > 0) {
3595
+ if (liveHeaderDupes > 0) {
3596
+ this.log(`${liveHeaderDupes} duplicate headers ignored.`);
3597
+ liveHeaderDupes = 0;
3598
+ }
3599
+ const updated = await this.storage.getAvailableHeightRanges();
3600
+ this.log(`After adding ${count} live headers
3600
3601
  After live: bulk ${updated.bulk}, live ${updated.live}
3601
3602
  `);
3602
- count = 0;
3603
- }
3604
- if (!this.subscriberCallbacksEnabled) {
3605
- const live = await this.storage.findLiveHeightRange();
3606
- if (!live.isEmpty) {
3607
- this.subscriberCallbacksEnabled = true;
3608
- this.log(`listening at height of ${live.maxHeight}`);
3603
+ count = 0;
3609
3604
  }
3605
+ if (!this.subscriberCallbacksEnabled) {
3606
+ const live = await this.storage.findLiveHeightRange();
3607
+ if (!live.isEmpty) {
3608
+ this.subscriberCallbacksEnabled = true;
3609
+ this.log(`listening at height of ${live.maxHeight}`);
3610
+ }
3611
+ }
3612
+ if (!this.available) {
3613
+ this.available = true;
3614
+ }
3615
+ needSyncCheck = Date.now() - lastSyncCheck > syncCheckRepeatMsecs;
3616
+ if (!needSyncCheck)
3617
+ await wait(1000);
3610
3618
  }
3611
- if (!this.available) {
3612
- this.available = true;
3613
- }
3614
- needSyncCheck = Date.now() - lastSyncCheck > syncCheckRepeatMsecs;
3615
- if (!needSyncCheck)
3616
- await wait(1000);
3617
3619
  }
3618
3620
  }
3619
3621
  }
3622
+ catch (eu: unknown) {
3623
+ const e = WalletError.fromUnknown(eu);
3624
+ if (!this.available) {
3625
+ this.startupError = e;
3626
+ this.stopMainThread = true;
3627
+ }
3628
+ else {
3629
+ this.log(`Error occurred during chaintracks main thread processing: ${e.stack || e.message}`);
3630
+ }
3631
+ }
3620
3632
  }
3621
3633
  }
3622
3634
  }
3623
3635
  ```
3624
3636
 
3625
- See also: [BaseBlockHeader](./client.md#interface-baseblockheader), [BlockHeader](./client.md#interface-blockheader), [Chain](./client.md#type-chain), [ChaintracksFsApi](./services.md#interface-chaintracksfsapi), [ChaintracksInfoApi](./services.md#interface-chaintracksinfoapi), [ChaintracksManagementApi](./services.md#interface-chaintracksmanagementapi), [ChaintracksOptions](./services.md#interface-chaintracksoptions), [HeaderListener](./services.md#type-headerlistener), [HeightRange](./services.md#class-heightrange), [HeightRanges](./services.md#interface-heightranges), [LiveBlockHeader](./services.md#interface-liveblockheader), [ReorgListener](./services.md#type-reorglistener), [Services](./services.md#class-services), [asString](./client.md#function-asstring), [blockHash](./services.md#function-blockhash), [wait](./client.md#function-wait)
3637
+ See also: [BaseBlockHeader](./client.md#interface-baseblockheader), [BlockHeader](./client.md#interface-blockheader), [Chain](./client.md#type-chain), [ChaintracksFsApi](./services.md#interface-chaintracksfsapi), [ChaintracksInfoApi](./services.md#interface-chaintracksinfoapi), [ChaintracksManagementApi](./services.md#interface-chaintracksmanagementapi), [ChaintracksOptions](./services.md#interface-chaintracksoptions), [HeaderListener](./services.md#type-headerlistener), [HeightRange](./services.md#class-heightrange), [HeightRanges](./services.md#interface-heightranges), [LiveBlockHeader](./services.md#interface-liveblockheader), [ReorgListener](./services.md#type-reorglistener), [Services](./services.md#class-services), [WalletError](./client.md#class-walleterror), [asString](./client.md#function-asstring), [blockHash](./services.md#function-blockhash), [wait](./client.md#function-wait)
3626
3638
 
3627
3639
  ###### Method addHeader
3628
3640