@bsv/wallet-toolbox-client 2.1.24 → 2.1.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/out/src/CWIStyleWalletManager.d.ts +33 -7
- package/out/src/CWIStyleWalletManager.d.ts.map +1 -1
- package/out/src/CWIStyleWalletManager.js +281 -313
- package/out/src/CWIStyleWalletManager.js.map +1 -1
- package/out/src/SetupClient.d.ts +6 -6
- package/out/src/SetupClient.d.ts.map +1 -1
- package/out/src/SetupClient.js +5 -5
- package/out/src/SetupClient.js.map +1 -1
- package/out/src/SetupWallet.d.ts.map +1 -1
- package/out/src/SimpleWalletManager.d.ts +12 -2
- package/out/src/SimpleWalletManager.d.ts.map +1 -1
- package/out/src/SimpleWalletManager.js +46 -30
- package/out/src/SimpleWalletManager.js.map +1 -1
- package/out/src/Wallet.d.ts +1 -1
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +102 -100
- package/out/src/Wallet.js.map +1 -1
- package/out/src/WalletAuthenticationManager.d.ts +1 -1
- package/out/src/WalletAuthenticationManager.d.ts.map +1 -1
- package/out/src/WalletAuthenticationManager.js +3 -3
- package/out/src/WalletAuthenticationManager.js.map +1 -1
- package/out/src/WalletLogger.d.ts.map +1 -1
- package/out/src/WalletLogger.js +16 -8
- package/out/src/WalletLogger.js.map +1 -1
- package/out/src/WalletPermissionsManager.d.ts +89 -18
- package/out/src/WalletPermissionsManager.d.ts.map +1 -1
- package/out/src/WalletPermissionsManager.js +656 -870
- package/out/src/WalletPermissionsManager.js.map +1 -1
- package/out/src/WalletSettingsManager.d.ts +2 -2
- package/out/src/WalletSettingsManager.d.ts.map +1 -1
- package/out/src/WalletSettingsManager.js.map +1 -1
- package/out/src/fundWalletP2PKH.d.ts +2 -2
- package/out/src/fundWalletP2PKH.d.ts.map +1 -1
- package/out/src/fundWalletP2PKH.js +11 -10
- package/out/src/fundWalletP2PKH.js.map +1 -1
- package/out/src/mockchain/MockChainMigrations.d.ts +3 -3
- package/out/src/mockchain/MockChainMigrations.d.ts.map +1 -1
- package/out/src/mockchain/MockChainMigrations.js.map +1 -1
- package/out/src/mockchain/MockChainStorage.d.ts.map +1 -1
- package/out/src/mockchain/MockChainStorage.js +5 -5
- package/out/src/mockchain/MockChainStorage.js.map +1 -1
- package/out/src/mockchain/MockChainTracker.d.ts.map +1 -1
- package/out/src/mockchain/MockChainTracker.js +10 -10
- package/out/src/mockchain/MockChainTracker.js.map +1 -1
- package/out/src/mockchain/MockMiner.d.ts.map +1 -1
- package/out/src/mockchain/MockMiner.js +3 -3
- package/out/src/mockchain/MockMiner.js.map +1 -1
- package/out/src/mockchain/MockServices.d.ts +9 -0
- package/out/src/mockchain/MockServices.d.ts.map +1 -1
- package/out/src/mockchain/MockServices.js +195 -238
- package/out/src/mockchain/MockServices.js.map +1 -1
- package/out/src/mockchain/merkleTree.d.ts.map +1 -1
- package/out/src/mockchain/merkleTree.js +21 -12
- package/out/src/mockchain/merkleTree.js.map +1 -1
- package/out/src/monitor/Monitor.d.ts +17 -0
- package/out/src/monitor/Monitor.d.ts.map +1 -1
- package/out/src/monitor/Monitor.js +56 -75
- package/out/src/monitor/Monitor.js.map +1 -1
- package/out/src/monitor/tasks/TaskArcSSE.d.ts +2 -2
- package/out/src/monitor/tasks/TaskArcSSE.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskArcSSE.js +10 -23
- package/out/src/monitor/tasks/TaskArcSSE.js.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +2 -2
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.js +28 -16
- package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
- package/out/src/monitor/tasks/TaskCheckNoSends.d.ts +1 -1
- package/out/src/monitor/tasks/TaskCheckNoSends.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskCheckNoSends.js +1 -2
- package/out/src/monitor/tasks/TaskCheckNoSends.js.map +1 -1
- package/out/src/monitor/tasks/TaskClock.d.ts +1 -1
- package/out/src/monitor/tasks/TaskClock.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskClock.js +0 -1
- package/out/src/monitor/tasks/TaskClock.js.map +1 -1
- package/out/src/monitor/tasks/TaskFailAbandoned.d.ts +1 -1
- package/out/src/monitor/tasks/TaskFailAbandoned.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskFailAbandoned.js.map +1 -1
- package/out/src/monitor/tasks/TaskMineBlock.d.ts +1 -1
- package/out/src/monitor/tasks/TaskMineBlock.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskMineBlock.js.map +1 -1
- package/out/src/monitor/tasks/TaskMonitorCallHistory.d.ts +1 -1
- package/out/src/monitor/tasks/TaskMonitorCallHistory.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskMonitorCallHistory.js +1 -1
- package/out/src/monitor/tasks/TaskMonitorCallHistory.js.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.d.ts +2 -2
- package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.js +7 -5
- package/out/src/monitor/tasks/TaskNewHeader.js.map +1 -1
- package/out/src/monitor/tasks/TaskPurge.d.ts +1 -1
- package/out/src/monitor/tasks/TaskPurge.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskPurge.js.map +1 -1
- package/out/src/monitor/tasks/TaskReorg.d.ts +1 -1
- package/out/src/monitor/tasks/TaskReorg.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReorg.js +2 -2
- package/out/src/monitor/tasks/TaskReorg.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewDoubleSpends.d.ts +1 -1
- package/out/src/monitor/tasks/TaskReviewDoubleSpends.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewDoubleSpends.js +10 -10
- package/out/src/monitor/tasks/TaskReviewDoubleSpends.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewProvenTxs.d.ts +1 -1
- package/out/src/monitor/tasks/TaskReviewProvenTxs.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewProvenTxs.js +2 -2
- package/out/src/monitor/tasks/TaskReviewProvenTxs.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.d.ts +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewUtxos.d.ts +1 -1
- package/out/src/monitor/tasks/TaskReviewUtxos.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewUtxos.js.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.js +4 -5
- package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
- package/out/src/monitor/tasks/TaskUnFail.d.ts +1 -1
- package/out/src/monitor/tasks/TaskUnFail.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskUnFail.js +13 -15
- package/out/src/monitor/tasks/TaskUnFail.js.map +1 -1
- package/out/src/monitor/tasks/WalletMonitorTask.d.ts.map +1 -1
- package/out/src/monitor/tasks/WalletMonitorTask.js +3 -1
- package/out/src/monitor/tasks/WalletMonitorTask.js.map +1 -1
- package/out/src/sdk/CertOpsWallet.d.ts +3 -3
- package/out/src/sdk/CertOpsWallet.d.ts.map +1 -1
- package/out/src/sdk/PrivilegedKeyManager.d.ts +3 -3
- package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -1
- package/out/src/sdk/PrivilegedKeyManager.js +26 -21
- package/out/src/sdk/PrivilegedKeyManager.js.map +1 -1
- package/out/src/sdk/WERR_errors.d.ts.map +1 -1
- package/out/src/sdk/WERR_errors.js +5 -5
- package/out/src/sdk/WERR_errors.js.map +1 -1
- package/out/src/sdk/WalletError.d.ts +1 -1
- package/out/src/sdk/WalletError.d.ts.map +1 -1
- package/out/src/sdk/WalletError.js +10 -3
- package/out/src/sdk/WalletError.js.map +1 -1
- package/out/src/sdk/WalletErrorFromJson.d.ts.map +1 -1
- package/out/src/sdk/WalletErrorFromJson.js +1 -3
- package/out/src/sdk/WalletErrorFromJson.js.map +1 -1
- package/out/src/sdk/WalletServices.interfaces.d.ts +19 -19
- package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
- package/out/src/sdk/types.d.ts +4 -4
- package/out/src/sdk/types.d.ts.map +1 -1
- package/out/src/sdk/types.js +3 -3
- package/out/src/sdk/types.js.map +1 -1
- package/out/src/services/ServiceCollection.d.ts +6 -6
- package/out/src/services/ServiceCollection.d.ts.map +1 -1
- package/out/src/services/ServiceCollection.js +3 -4
- package/out/src/services/ServiceCollection.js.map +1 -1
- package/out/src/services/Services.d.ts +5 -0
- package/out/src/services/Services.d.ts.map +1 -1
- package/out/src/services/Services.js +174 -182
- package/out/src/services/Services.js.map +1 -1
- package/out/src/services/chaintracker/BHServiceClient.d.ts.map +1 -1
- package/out/src/services/chaintracker/BHServiceClient.js +7 -7
- package/out/src/services/chaintracker/BHServiceClient.js.map +1 -1
- package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts.map +1 -1
- package/out/src/services/chaintracker/ChaintracksChainTracker.js +5 -5
- package/out/src/services/chaintracker/ChaintracksChainTracker.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts +5 -3
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Api/BulkStorageApi.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts +20 -10
- package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Chaintracks.js +228 -221
- package/out/src/services/chaintracker/chaintracks/Chaintracks.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +9 -10
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.js +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts +1 -2
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js +3 -3
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js +3 -3
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.js +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js +2 -2
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts +2 -2
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js +6 -39
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts +3 -3
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.js +8 -6
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.js +9 -16
- package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js +34 -22
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js +31 -30
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts +2 -2
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js +11 -10
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts +6 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js +247 -227
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.js +8 -7
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js +35 -25
- package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.d.ts +5 -5
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.js +13 -11
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts +0 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/HeightRange.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/HeightRange.js +21 -13
- package/out/src/services/chaintracker/chaintracks/util/HeightRange.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts +2 -2
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts +1 -1
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js +28 -24
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.js +9 -10
- package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.js.map +1 -1
- package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -1
- package/out/src/services/createDefaultWalletServicesOptions.js +3 -3
- package/out/src/services/createDefaultWalletServicesOptions.js.map +1 -1
- package/out/src/services/providers/ARC.d.ts.map +1 -1
- package/out/src/services/providers/ARC.js +7 -14
- package/out/src/services/providers/ARC.js.map +1 -1
- package/out/src/services/providers/ArcSSEClient.d.ts.map +1 -1
- package/out/src/services/providers/ArcSSEClient.js +1 -1
- package/out/src/services/providers/ArcSSEClient.js.map +1 -1
- package/out/src/services/providers/Bitails.d.ts.map +1 -1
- package/out/src/services/providers/Bitails.js +17 -17
- package/out/src/services/providers/Bitails.js.map +1 -1
- package/out/src/services/providers/SdkWhatsOnChain.d.ts.map +1 -1
- package/out/src/services/providers/SdkWhatsOnChain.js.map +1 -1
- package/out/src/services/providers/WhatsOnChain.d.ts +2 -0
- package/out/src/services/providers/WhatsOnChain.d.ts.map +1 -1
- package/out/src/services/providers/WhatsOnChain.js +109 -233
- package/out/src/services/providers/WhatsOnChain.js.map +1 -1
- package/out/src/services/providers/exchangeRates.d.ts.map +1 -1
- package/out/src/services/providers/exchangeRates.js +3 -3
- package/out/src/services/providers/exchangeRates.js.map +1 -1
- package/out/src/services/providers/getBeefForTxid.d.ts +1 -1
- package/out/src/services/providers/getBeefForTxid.d.ts.map +1 -1
- package/out/src/services/providers/getBeefForTxid.js.map +1 -1
- package/out/src/services/providers/whatsOnChainHelpers.d.ts +68 -0
- package/out/src/services/providers/whatsOnChainHelpers.d.ts.map +1 -0
- package/out/src/services/providers/whatsOnChainHelpers.js +147 -0
- package/out/src/services/providers/whatsOnChainHelpers.js.map +1 -0
- package/out/src/signer/WalletSigner.d.ts.map +1 -1
- package/out/src/signer/WalletSigner.js.map +1 -1
- package/out/src/signer/methods/acquireDirectCertificate.js +1 -1
- package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.js +21 -13
- package/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
- package/out/src/signer/methods/completeSignedTransaction.d.ts.map +1 -1
- package/out/src/signer/methods/completeSignedTransaction.js +20 -21
- package/out/src/signer/methods/completeSignedTransaction.js.map +1 -1
- package/out/src/signer/methods/createAction.d.ts.map +1 -1
- package/out/src/signer/methods/createAction.js +8 -7
- package/out/src/signer/methods/createAction.js.map +1 -1
- package/out/src/signer/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/signer/methods/internalizeAction.js +8 -6
- package/out/src/signer/methods/internalizeAction.js.map +1 -1
- package/out/src/signer/methods/proveCertificate.js +1 -1
- package/out/src/signer/methods/signAction.d.ts.map +1 -1
- package/out/src/signer/methods/signAction.js +8 -10
- package/out/src/signer/methods/signAction.js.map +1 -1
- package/out/src/storage/StorageIdb.d.ts +16 -1
- package/out/src/storage/StorageIdb.d.ts.map +1 -1
- package/out/src/storage/StorageIdb.js +536 -1221
- package/out/src/storage/StorageIdb.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts +10 -0
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +152 -182
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/StorageReader.d.ts.map +1 -1
- package/out/src/storage/StorageReader.js +8 -7
- package/out/src/storage/StorageReader.js.map +1 -1
- package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
- package/out/src/storage/StorageReaderWriter.js +32 -32
- package/out/src/storage/StorageReaderWriter.js.map +1 -1
- package/out/src/storage/StorageSyncReader.d.ts.map +1 -1
- package/out/src/storage/StorageSyncReader.js +3 -3
- package/out/src/storage/StorageSyncReader.js.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts +3 -0
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.js +83 -73
- package/out/src/storage/WalletStorageManager.js.map +1 -1
- package/out/src/storage/idbHelpers.d.ts +42 -0
- package/out/src/storage/idbHelpers.d.ts.map +1 -0
- package/out/src/storage/idbHelpers.js +375 -0
- package/out/src/storage/idbHelpers.js.map +1 -0
- package/out/src/storage/methods/ListActionsSpecOp.d.ts +6 -1
- package/out/src/storage/methods/ListActionsSpecOp.d.ts.map +1 -1
- package/out/src/storage/methods/ListActionsSpecOp.js +28 -2
- package/out/src/storage/methods/ListActionsSpecOp.js.map +1 -1
- package/out/src/storage/methods/ListOutputsSpecOp.d.ts.map +1 -1
- package/out/src/storage/methods/ListOutputsSpecOp.js +8 -11
- package/out/src/storage/methods/ListOutputsSpecOp.js.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +83 -0
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js +224 -61
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
- package/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/out/src/storage/methods/createAction.js +230 -270
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/methods/generateChange.d.ts.map +1 -1
- package/out/src/storage/methods/generateChange.js +99 -80
- package/out/src/storage/methods/generateChange.js.map +1 -1
- package/out/src/storage/methods/getBeefForTransaction.js +15 -13
- package/out/src/storage/methods/getBeefForTransaction.js.map +1 -1
- package/out/src/storage/methods/getSyncChunk.d.ts.map +1 -1
- package/out/src/storage/methods/getSyncChunk.js +4 -3
- package/out/src/storage/methods/getSyncChunk.js.map +1 -1
- package/out/src/storage/methods/internalizeAction.js +41 -51
- package/out/src/storage/methods/internalizeAction.js.map +1 -1
- package/out/src/storage/methods/listActionsIdb.d.ts.map +1 -1
- package/out/src/storage/methods/listActionsIdb.js +85 -110
- package/out/src/storage/methods/listActionsIdb.js.map +1 -1
- package/out/src/storage/methods/listCertificates.d.ts +1 -1
- package/out/src/storage/methods/listCertificates.d.ts.map +1 -1
- package/out/src/storage/methods/listCertificates.js +7 -7
- package/out/src/storage/methods/listCertificates.js.map +1 -1
- package/out/src/storage/methods/listOutputsIdb.d.ts.map +1 -1
- package/out/src/storage/methods/listOutputsIdb.js +24 -27
- package/out/src/storage/methods/listOutputsIdb.js.map +1 -1
- package/out/src/storage/methods/offsetKey.d.ts +1 -1
- package/out/src/storage/methods/offsetKey.d.ts.map +1 -1
- package/out/src/storage/methods/offsetKey.js +3 -5
- package/out/src/storage/methods/offsetKey.js.map +1 -1
- package/out/src/storage/methods/processAction.d.ts +0 -11
- package/out/src/storage/methods/processAction.d.ts.map +1 -1
- package/out/src/storage/methods/processAction.js +90 -83
- package/out/src/storage/methods/processAction.js.map +1 -1
- package/out/src/storage/methods/purgeDataIdb.d.ts.map +1 -1
- package/out/src/storage/methods/purgeDataIdb.js +1 -1
- package/out/src/storage/methods/purgeDataIdb.js.map +1 -1
- package/out/src/storage/methods/reviewStatusIdb.d.ts +1 -1
- package/out/src/storage/methods/reviewStatusIdb.d.ts.map +1 -1
- package/out/src/storage/methods/reviewStatusIdb.js.map +1 -1
- package/out/src/storage/methods/utils.d.ts.map +1 -1
- package/out/src/storage/methods/utils.js +7 -1
- package/out/src/storage/methods/utils.js.map +1 -1
- package/out/src/storage/remoting/StorageClient.d.ts +4 -270
- package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClient.js +16 -423
- package/out/src/storage/remoting/StorageClient.js.map +1 -1
- package/out/src/storage/remoting/StorageClientBase.d.ts +289 -0
- package/out/src/storage/remoting/StorageClientBase.d.ts.map +1 -0
- package/out/src/storage/remoting/StorageClientBase.js +375 -0
- package/out/src/storage/remoting/StorageClientBase.js.map +1 -0
- package/out/src/storage/remoting/entityValidationHelpers.d.ts +29 -0
- package/out/src/storage/remoting/entityValidationHelpers.d.ts.map +1 -0
- package/out/src/storage/remoting/entityValidationHelpers.js +91 -0
- package/out/src/storage/remoting/entityValidationHelpers.js.map +1 -0
- package/out/src/storage/schema/StorageIdbSchema.d.ts +1 -1
- package/out/src/storage/schema/StorageIdbSchema.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityBase.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityBase.js.map +1 -1
- package/out/src/storage/schema/entities/EntityCertificate.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityCertificate.js +5 -4
- package/out/src/storage/schema/entities/EntityCertificate.js.map +1 -1
- package/out/src/storage/schema/entities/EntityCertificateField.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityCertificateField.js +5 -7
- package/out/src/storage/schema/entities/EntityCertificateField.js.map +1 -1
- package/out/src/storage/schema/entities/EntityCommission.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityCommission.js +6 -8
- package/out/src/storage/schema/entities/EntityCommission.js.map +1 -1
- package/out/src/storage/schema/entities/EntityOutput.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityOutput.js +21 -24
- package/out/src/storage/schema/entities/EntityOutput.js.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputBasket.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputBasket.js +6 -6
- package/out/src/storage/schema/entities/EntityOutputBasket.js.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputTag.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputTag.js +2 -2
- package/out/src/storage/schema/entities/EntityOutputTag.js.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputTagMap.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputTagMap.js +4 -6
- package/out/src/storage/schema/entities/EntityOutputTagMap.js.map +1 -1
- package/out/src/storage/schema/entities/EntityProvenTx.d.ts +3 -3
- package/out/src/storage/schema/entities/EntityProvenTx.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityProvenTx.js +22 -23
- package/out/src/storage/schema/entities/EntityProvenTx.js.map +1 -1
- package/out/src/storage/schema/entities/EntityProvenTxReq.d.ts +9 -0
- package/out/src/storage/schema/entities/EntityProvenTxReq.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityProvenTxReq.js +116 -68
- package/out/src/storage/schema/entities/EntityProvenTxReq.js.map +1 -1
- package/out/src/storage/schema/entities/EntitySyncState.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntitySyncState.js +19 -18
- package/out/src/storage/schema/entities/EntitySyncState.js.map +1 -1
- package/out/src/storage/schema/entities/EntityTransaction.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityTransaction.js +25 -26
- package/out/src/storage/schema/entities/EntityTransaction.js.map +1 -1
- package/out/src/storage/schema/entities/EntityTxLabel.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityTxLabel.js +2 -2
- package/out/src/storage/schema/entities/EntityTxLabel.js.map +1 -1
- package/out/src/storage/schema/entities/EntityTxLabelMap.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityTxLabelMap.js +4 -6
- package/out/src/storage/schema/entities/EntityTxLabelMap.js.map +1 -1
- package/out/src/storage/schema/entities/EntityUser.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityUser.js +3 -3
- package/out/src/storage/schema/entities/EntityUser.js.map +1 -1
- package/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -1
- package/out/src/storage/schema/entities/MergeEntity.js +6 -6
- package/out/src/storage/schema/entities/MergeEntity.js.map +1 -1
- package/out/src/storage/schema/tables/TableCertificate.d.ts +2 -1
- package/out/src/storage/schema/tables/TableCertificate.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableCertificateField.d.ts +1 -1
- package/out/src/storage/schema/tables/TableCertificateField.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableCommission.d.ts +1 -1
- package/out/src/storage/schema/tables/TableCommission.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableMonitorEvent.d.ts +1 -1
- package/out/src/storage/schema/tables/TableMonitorEvent.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableOutput.d.ts +3 -2
- package/out/src/storage/schema/tables/TableOutput.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableOutput.js +1 -1
- package/out/src/storage/schema/tables/TableOutput.js.map +1 -1
- package/out/src/storage/schema/tables/TableOutputBasket.d.ts +1 -1
- package/out/src/storage/schema/tables/TableOutputBasket.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableOutputTag.d.ts +1 -1
- package/out/src/storage/schema/tables/TableOutputTag.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableOutputTagMap.d.ts +1 -1
- package/out/src/storage/schema/tables/TableOutputTagMap.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableProvenTx.d.ts +1 -1
- package/out/src/storage/schema/tables/TableProvenTx.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableProvenTxReq.d.ts +24 -1
- package/out/src/storage/schema/tables/TableProvenTxReq.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableSettings.d.ts +1 -1
- package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableSyncState.d.ts +1 -1
- package/out/src/storage/schema/tables/TableSyncState.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableTransaction.d.ts +1 -1
- package/out/src/storage/schema/tables/TableTransaction.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableTxLabel.d.ts +1 -1
- package/out/src/storage/schema/tables/TableTxLabel.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableTxLabelMap.d.ts +1 -1
- package/out/src/storage/schema/tables/TableTxLabelMap.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableUser.d.ts +1 -1
- package/out/src/storage/schema/tables/TableUser.d.ts.map +1 -1
- package/out/src/storage/storageProviderHelpers.d.ts +34 -0
- package/out/src/storage/storageProviderHelpers.d.ts.map +1 -0
- package/out/src/storage/storageProviderHelpers.js +100 -0
- package/out/src/storage/storageProviderHelpers.js.map +1 -0
- package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -1
- package/out/src/utility/ScriptTemplateBRC29.js +2 -1
- package/out/src/utility/ScriptTemplateBRC29.js.map +1 -1
- package/out/src/utility/aggregateResults.d.ts +1 -1
- package/out/src/utility/aggregateResults.d.ts.map +1 -1
- package/out/src/utility/aggregateResults.js +2 -2
- package/out/src/utility/aggregateResults.js.map +1 -1
- package/out/src/utility/brc114ActionTimeLabels.d.ts +2 -2
- package/out/src/utility/brc114ActionTimeLabels.d.ts.map +1 -1
- package/out/src/utility/brc114ActionTimeLabels.js +16 -9
- package/out/src/utility/brc114ActionTimeLabels.js.map +1 -1
- package/out/src/utility/identityUtils.js +1 -1
- package/out/src/utility/identityUtils.js.map +1 -1
- package/out/src/utility/parseTxScriptOffsets.d.ts +4 -4
- package/out/src/utility/parseTxScriptOffsets.d.ts.map +1 -1
- package/out/src/utility/parseTxScriptOffsets.js.map +1 -1
- package/out/src/utility/stampLog.d.ts.map +1 -1
- package/out/src/utility/stampLog.js +7 -5
- package/out/src/utility/stampLog.js.map +1 -1
- package/out/src/utility/tscProofToMerklePath.d.ts.map +1 -1
- package/out/src/utility/tscProofToMerklePath.js +1 -1
- package/out/src/utility/tscProofToMerklePath.js.map +1 -1
- package/out/src/utility/utilityHelpers.d.ts +1 -2
- package/out/src/utility/utilityHelpers.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.js +10 -10
- package/out/src/utility/utilityHelpers.js.map +1 -1
- package/out/src/utility/utilityHelpers.noBuffer.d.ts +7 -3
- package/out/src/utility/utilityHelpers.noBuffer.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.noBuffer.js +3 -3
- package/out/src/utility/utilityHelpers.noBuffer.js.map +1 -1
- package/out/src/wab-client/WABClient.d.ts +1 -1
- package/out/src/wab-client/WABClient.d.ts.map +1 -1
- package/out/src/wab-client/WABClient.js +12 -12
- package/out/src/wab-client/WABClient.js.map +1 -1
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts.map +1 -1
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js +3 -3
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js.map +1 -1
- package/out/tsconfig.client.tsbuildinfo +1 -1
- package/package.json +7 -6
|
@@ -26,7 +26,7 @@ class Chaintracks {
|
|
|
26
26
|
this.log = () => { };
|
|
27
27
|
// Collection of all long running "threads": main thread (liveHeaders consumer / monitor) and each live header ingestor.
|
|
28
28
|
this.promises = [];
|
|
29
|
-
this.callbacks = { header:
|
|
29
|
+
this.callbacks = { header: {}, reorg: {} };
|
|
30
30
|
this.baseHeaders = [];
|
|
31
31
|
this.liveHeaders = [];
|
|
32
32
|
this.addLiveRecursionLimit = 11;
|
|
@@ -38,19 +38,21 @@ class Chaintracks {
|
|
|
38
38
|
this.lastPresentHeightMsecs = 0;
|
|
39
39
|
this.lastPresentHeightMaxAge = 60 * 1000; // 1 minute, in milliseconds
|
|
40
40
|
this.lock = new SingleWriterMultiReaderLock_1.SingleWriterMultiReaderLock();
|
|
41
|
-
if (
|
|
41
|
+
if (options.storage == null)
|
|
42
42
|
throw new Error('storage is required.');
|
|
43
|
-
if (!options.bulkIngestors || options.bulkIngestors.length < 1)
|
|
43
|
+
if (!options.bulkIngestors || options.bulkIngestors.length < 1) {
|
|
44
44
|
throw new Error('At least one bulk ingestor is required.');
|
|
45
|
-
|
|
45
|
+
}
|
|
46
|
+
if (!options.liveIngestors || options.liveIngestors.length < 1) {
|
|
46
47
|
throw new Error('At least one live ingestor is required.');
|
|
48
|
+
}
|
|
47
49
|
this.chain = options.chain;
|
|
48
50
|
this.readonly = options.readonly;
|
|
49
51
|
this.storage = options.storage;
|
|
50
52
|
this.bulkIngestors = options.bulkIngestors;
|
|
51
53
|
this.liveIngestors = options.liveIngestors;
|
|
52
54
|
this.addLiveRecursionLimit = options.addLiveRecursionLimit;
|
|
53
|
-
if (options.logging)
|
|
55
|
+
if (options.logging != null)
|
|
54
56
|
this.log = options.logging;
|
|
55
57
|
this.storage.log = this.log;
|
|
56
58
|
this.log(`New ChaintracksBase Instance Constructed ${options.chain}Net`);
|
|
@@ -78,7 +80,7 @@ class Chaintracks {
|
|
|
78
80
|
console.error(uerr);
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
|
-
const presentHeight = presentHeights.length ? Math.max(...presentHeights) : undefined;
|
|
83
|
+
const presentHeight = (presentHeights.length > 0) ? Math.max(...presentHeights) : undefined;
|
|
82
84
|
if (!presentHeight)
|
|
83
85
|
throw new Error('At least one bulk ingestor must implement getPresentHeight.');
|
|
84
86
|
this.lastPresentHeight = presentHeight;
|
|
@@ -101,9 +103,9 @@ class Chaintracks {
|
|
|
101
103
|
async unsubscribe(subscriptionId) {
|
|
102
104
|
let success = true;
|
|
103
105
|
if (this.callbacks.header[subscriptionId])
|
|
104
|
-
|
|
106
|
+
this.callbacks.header[subscriptionId] = null;
|
|
105
107
|
else if (this.callbacks.reorg[subscriptionId])
|
|
106
|
-
|
|
108
|
+
this.callbacks.reorg[subscriptionId] = null;
|
|
107
109
|
else
|
|
108
110
|
success = false;
|
|
109
111
|
return success;
|
|
@@ -148,15 +150,15 @@ class Chaintracks {
|
|
|
148
150
|
// Start mai loop to shift out liveHeaders...once sync'd, will set `available` true.
|
|
149
151
|
this.promises.push(this.mainThreadShiftLiveHeaders());
|
|
150
152
|
// Wait for the main thread to finish initial sync.
|
|
151
|
-
while (!this.available &&
|
|
153
|
+
while (!this.available && (this.startupError == null)) {
|
|
152
154
|
await (0, utilityHelpers_1.wait)(100);
|
|
153
155
|
}
|
|
154
|
-
if (this.startupError)
|
|
156
|
+
if (this.startupError != null)
|
|
155
157
|
throw this.startupError;
|
|
156
158
|
});
|
|
157
159
|
}
|
|
158
160
|
async startPromises() {
|
|
159
|
-
if (this.promises.length > 0 || this.stopMainThread
|
|
161
|
+
if (this.promises.length > 0 || !this.stopMainThread)
|
|
160
162
|
return;
|
|
161
163
|
}
|
|
162
164
|
async destroy() {
|
|
@@ -179,40 +181,39 @@ class Chaintracks {
|
|
|
179
181
|
});
|
|
180
182
|
}
|
|
181
183
|
async listening() {
|
|
182
|
-
return this.makeAvailable();
|
|
184
|
+
return await this.makeAvailable();
|
|
183
185
|
}
|
|
184
186
|
async isListening() {
|
|
185
187
|
return this.available;
|
|
186
188
|
}
|
|
187
189
|
async isSynchronized() {
|
|
188
190
|
await this.makeAvailable();
|
|
189
|
-
// TODO add synchronized flag... false while bulksyncing...
|
|
190
191
|
return true;
|
|
191
192
|
}
|
|
192
193
|
async findHeaderForHeight(height) {
|
|
193
194
|
await this.makeAvailable();
|
|
194
|
-
return this.lock.withReadLock(async () => this.findHeaderForHeightNoLock(height));
|
|
195
|
+
return await this.lock.withReadLock(async () => await this.findHeaderForHeightNoLock(height));
|
|
195
196
|
}
|
|
196
197
|
async findHeaderForHeightNoLock(height) {
|
|
197
198
|
return await this.storage.findHeaderForHeightOrUndefined(height);
|
|
198
199
|
}
|
|
199
200
|
async findHeaderForBlockHash(hash) {
|
|
200
201
|
await this.makeAvailable();
|
|
201
|
-
return this.lock.withReadLock(async () => this.findHeaderForBlockHashNoLock(hash));
|
|
202
|
+
return await this.lock.withReadLock(async () => await this.findHeaderForBlockHashNoLock(hash));
|
|
202
203
|
}
|
|
203
204
|
async findHeaderForBlockHashNoLock(hash) {
|
|
204
205
|
return (await this.storage.findLiveHeaderForBlockHash(hash)) || undefined;
|
|
205
206
|
}
|
|
206
207
|
async isValidRootForHeight(root, height) {
|
|
207
208
|
const r = await this.findHeaderForHeight(height);
|
|
208
|
-
if (
|
|
209
|
+
if (r == null)
|
|
209
210
|
return false;
|
|
210
211
|
const isValid = root === r.merkleRoot;
|
|
211
212
|
return isValid;
|
|
212
213
|
}
|
|
213
214
|
async getInfo() {
|
|
214
215
|
await this.makeAvailable();
|
|
215
|
-
return this.lock.withReadLock(async () => this.getInfoNoLock());
|
|
216
|
+
return await this.lock.withReadLock(async () => await this.getInfoNoLock());
|
|
216
217
|
}
|
|
217
218
|
async getInfoNoLock() {
|
|
218
219
|
const liveRange = await this.storage.findLiveHeightRange();
|
|
@@ -229,15 +230,15 @@ class Chaintracks {
|
|
|
229
230
|
}
|
|
230
231
|
async getHeaders(height, count) {
|
|
231
232
|
await this.makeAvailable();
|
|
232
|
-
return this.lock.withReadLock(async () => (0, utilityHelpers_noBuffer_1.asString)(await this.storage.getHeadersUint8Array(height, count)));
|
|
233
|
+
return await this.lock.withReadLock(async () => (0, utilityHelpers_noBuffer_1.asString)(await this.storage.getHeadersUint8Array(height, count)));
|
|
233
234
|
}
|
|
234
235
|
async findChainTipHeader() {
|
|
235
236
|
await this.makeAvailable();
|
|
236
|
-
return this.lock.withReadLock(async () => await this.storage.findChainTipHeader());
|
|
237
|
+
return await this.lock.withReadLock(async () => await this.storage.findChainTipHeader());
|
|
237
238
|
}
|
|
238
239
|
async findChainTipHash() {
|
|
239
240
|
await this.makeAvailable();
|
|
240
|
-
return this.lock.withReadLock(async () => await this.storage.findChainTipHash());
|
|
241
|
+
return await this.lock.withReadLock(async () => await this.storage.findChainTipHash());
|
|
241
242
|
}
|
|
242
243
|
async findLiveHeaderForBlockHash(hash) {
|
|
243
244
|
await this.makeAvailable();
|
|
@@ -255,7 +256,7 @@ class Chaintracks {
|
|
|
255
256
|
let h = await this.findChainTipHeader();
|
|
256
257
|
while (h.height > 0) {
|
|
257
258
|
const hp = await this.findHeaderForHeight(h.height - 1);
|
|
258
|
-
if (
|
|
259
|
+
if ((hp === null || hp === void 0 ? void 0 : hp.hash) !== h.previousHash)
|
|
259
260
|
throw new Error(`validation fails at height ${h.height}`);
|
|
260
261
|
h = hp;
|
|
261
262
|
if (10000 * Math.floor(h.height / 10000) === h.height)
|
|
@@ -281,46 +282,17 @@ class Chaintracks {
|
|
|
281
282
|
let after = before;
|
|
282
283
|
let added = HeightRange_1.HeightRange.empty;
|
|
283
284
|
const maxSyncRounds = Math.max(1, this.bulkIngestors.length * 2);
|
|
284
|
-
let
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
const beforeBulkMax = before.bulk.maxHeight;
|
|
292
|
-
const beforeLiveRange = HeightRange_1.HeightRange.from(newLiveHeaders);
|
|
293
|
-
const r = await bulk.synchronize(presentHeight, before, newLiveHeaders);
|
|
294
|
-
roundHadSuccess = true;
|
|
295
|
-
newLiveHeaders = r.liveHeaders;
|
|
296
|
-
after = await this.storage.getAvailableHeightRanges();
|
|
297
|
-
added = after.bulk.above(before.bulk);
|
|
298
|
-
const afterLiveRange = HeightRange_1.HeightRange.from(newLiveHeaders);
|
|
299
|
-
if (after.bulk.maxHeight > beforeBulkMax || afterLiveRange.maxHeight > beforeLiveRange.maxHeight) {
|
|
300
|
-
roundMadeProgress = true;
|
|
301
|
-
}
|
|
302
|
-
before = after;
|
|
303
|
-
this.log(`Bulk Ingestor: ${added.length} added with ${newLiveHeaders.length} live headers from ${bulk.constructor.name}`);
|
|
304
|
-
if (r.done) {
|
|
305
|
-
done = true;
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
catch (eu) {
|
|
310
|
-
const e = (bulkSyncError = WalletError_1.WalletError.fromUnknown(eu));
|
|
311
|
-
this.log(`bulk sync error: ${e.message}`);
|
|
312
|
-
if (!this.available)
|
|
313
|
-
// During initial startup, bulk ingestors must be available.
|
|
314
|
-
break;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
if (!this.available && bulkSyncError && !roundHadSuccess) {
|
|
318
|
-
this.startupError = bulkSyncError;
|
|
285
|
+
for (let round = 1; round <= maxSyncRounds; round++) {
|
|
286
|
+
const result = await this.runBulkSyncRound(before, presentHeight, newLiveHeaders);
|
|
287
|
+
after = result.after;
|
|
288
|
+
newLiveHeaders = result.newLiveHeaders;
|
|
289
|
+
added = after.bulk.above(before.bulk);
|
|
290
|
+
before = after;
|
|
291
|
+
if (this.startupError != null)
|
|
319
292
|
break;
|
|
320
|
-
|
|
321
|
-
if (done)
|
|
293
|
+
if (result.done)
|
|
322
294
|
break;
|
|
323
|
-
if (!
|
|
295
|
+
if (!result.madeProgress) {
|
|
324
296
|
this.log(`Bulk sync stalled after round ${round}. Deferring further bulk sync attempts to continue live header processing.`);
|
|
325
297
|
break;
|
|
326
298
|
}
|
|
@@ -328,7 +300,7 @@ class Chaintracks {
|
|
|
328
300
|
this.log(`Bulk sync paused after ${maxSyncRounds} rounds to avoid runaway retries. Will retry in a later sync cycle.`);
|
|
329
301
|
}
|
|
330
302
|
}
|
|
331
|
-
if (
|
|
303
|
+
if (this.startupError == null) {
|
|
332
304
|
this.liveHeaders.unshift(...newLiveHeaders);
|
|
333
305
|
added = after.bulk.above(initialRanges.bulk);
|
|
334
306
|
this.log(`syncBulkStorage done
|
|
@@ -339,10 +311,47 @@ class Chaintracks {
|
|
|
339
311
|
`);
|
|
340
312
|
}
|
|
341
313
|
}
|
|
314
|
+
async runBulkSyncRound(before, presentHeight, newLiveHeaders) {
|
|
315
|
+
let after = before;
|
|
316
|
+
let bulkSyncError;
|
|
317
|
+
let madeProgress = false;
|
|
318
|
+
let hadSuccess = false;
|
|
319
|
+
let done = false;
|
|
320
|
+
for (const bulk of this.bulkIngestors) {
|
|
321
|
+
try {
|
|
322
|
+
const beforeBulkMax = before.bulk.maxHeight;
|
|
323
|
+
const beforeLiveRange = HeightRange_1.HeightRange.from(newLiveHeaders);
|
|
324
|
+
const r = await bulk.synchronize(presentHeight, before, newLiveHeaders);
|
|
325
|
+
hadSuccess = true;
|
|
326
|
+
newLiveHeaders = r.liveHeaders;
|
|
327
|
+
after = await this.storage.getAvailableHeightRanges();
|
|
328
|
+
const added = after.bulk.above(before.bulk);
|
|
329
|
+
const afterLiveRange = HeightRange_1.HeightRange.from(newLiveHeaders);
|
|
330
|
+
if (after.bulk.maxHeight > beforeBulkMax || afterLiveRange.maxHeight > beforeLiveRange.maxHeight)
|
|
331
|
+
madeProgress = true;
|
|
332
|
+
before = after;
|
|
333
|
+
this.log(`Bulk Ingestor: ${added.length} added with ${newLiveHeaders.length} live headers from ${bulk.constructor.name}`);
|
|
334
|
+
if (r.done) {
|
|
335
|
+
done = true;
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
catch (error_) {
|
|
340
|
+
const e = (bulkSyncError = WalletError_1.WalletError.fromUnknown(error_));
|
|
341
|
+
this.log(`bulk sync error: ${e.message}`);
|
|
342
|
+
// During initial startup, bulk ingestors must be available.
|
|
343
|
+
if (!this.available)
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (!this.available && (bulkSyncError != null) && !hadSuccess)
|
|
348
|
+
this.startupError = bulkSyncError;
|
|
349
|
+
return { after, newLiveHeaders, done, madeProgress };
|
|
350
|
+
}
|
|
342
351
|
async getMissingBlockHeader(hash) {
|
|
343
352
|
for (const live of this.liveIngestors) {
|
|
344
353
|
const header = await live.getHeaderByHash(hash);
|
|
345
|
-
if (header)
|
|
354
|
+
if (header != null)
|
|
346
355
|
return header;
|
|
347
356
|
}
|
|
348
357
|
return undefined;
|
|
@@ -359,36 +368,36 @@ class Chaintracks {
|
|
|
359
368
|
if (this.invalidInsertHeaderResult(ihr))
|
|
360
369
|
return ihr;
|
|
361
370
|
if (this.subscriberCallbacksEnabled && ihr.added && ihr.isActiveTip) {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
371
|
+
this.notifyHeaderListeners(header);
|
|
372
|
+
if (ihr.reorgDepth > 0 && (ihr.priorTip != null)) {
|
|
373
|
+
this.notifyReorgListeners(ihr, header);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return ihr;
|
|
377
|
+
}
|
|
378
|
+
notifyHeaderListeners(header) {
|
|
379
|
+
for (const id in this.callbacks.header) {
|
|
380
|
+
const listener = this.callbacks.header[id];
|
|
381
|
+
if (listener != null) {
|
|
382
|
+
try {
|
|
383
|
+
listener(header);
|
|
372
384
|
}
|
|
385
|
+
catch ( /* ignore all errors thrown */_a) { /* ignore all errors thrown */ }
|
|
373
386
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
catch (_b) {
|
|
385
|
-
/* ignore all errors thrown */
|
|
386
|
-
}
|
|
387
|
-
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
notifyReorgListeners(ihr, header) {
|
|
390
|
+
const priorTip = { ...ihr.priorTip };
|
|
391
|
+
const deactivated = ihr.deactivatedHeaders.map(lbh => ({ ...lbh }));
|
|
392
|
+
for (const id in this.callbacks.reorg) {
|
|
393
|
+
const listener = this.callbacks.reorg[id];
|
|
394
|
+
if (listener != null) {
|
|
395
|
+
try {
|
|
396
|
+
listener(ihr.reorgDepth, priorTip, header, deactivated);
|
|
388
397
|
}
|
|
398
|
+
catch ( /* ignore all errors thrown */_a) { /* ignore all errors thrown */ }
|
|
389
399
|
}
|
|
390
400
|
}
|
|
391
|
-
return ihr;
|
|
392
401
|
}
|
|
393
402
|
/**
|
|
394
403
|
* Long running method terminated by setting `stopMainThread` false.
|
|
@@ -404,161 +413,159 @@ class Chaintracks {
|
|
|
404
413
|
*/
|
|
405
414
|
async mainThreadShiftLiveHeaders() {
|
|
406
415
|
this.stopMainThread = false;
|
|
407
|
-
let lastSyncCheck =
|
|
416
|
+
let lastSyncCheck = 0;
|
|
408
417
|
let lastBulkSync = Date.now();
|
|
409
418
|
const cdnSyncRepeatMsecs = 24 * 60 * 60 * 1000; // 24 hours
|
|
410
419
|
const syncCheckRepeatMsecs = 30 * 60 * 1000; // 30 minutes
|
|
411
420
|
while (!this.stopMainThread) {
|
|
412
421
|
try {
|
|
413
|
-
// Review the need for bulk sync...
|
|
414
422
|
const now = Date.now();
|
|
415
423
|
lastSyncCheck = now;
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
424
|
+
lastBulkSync = await this.runBulkSyncIfNeeded(now, lastBulkSync, cdnSyncRepeatMsecs);
|
|
425
|
+
await this.processLiveHeaderQueue(lastSyncCheck, syncCheckRepeatMsecs);
|
|
426
|
+
}
|
|
427
|
+
catch (error_) {
|
|
428
|
+
const e = WalletError_1.WalletError.fromUnknown(error_);
|
|
429
|
+
if (this.available) {
|
|
430
|
+
this.log(`Error occurred during chaintracks main thread processing: ${e.stack || e.message}`);
|
|
423
431
|
}
|
|
424
|
-
|
|
432
|
+
else {
|
|
433
|
+
this.startupError = e;
|
|
434
|
+
this.stopMainThread = true;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
/** Returns (potentially updated) lastBulkSync timestamp. */
|
|
440
|
+
async runBulkSyncIfNeeded(now, lastBulkSync, cdnSyncRepeatMsecs) {
|
|
441
|
+
const presentHeight = await this.getPresentHeight();
|
|
442
|
+
const before = await this.storage.getAvailableHeightRanges();
|
|
443
|
+
let skipBulkSync = !before.live.isEmpty && before.live.maxHeight >= presentHeight - this.addLiveRecursionLimit / 2;
|
|
444
|
+
// If we haven't re-synced in a long time, do it just to check for a CDN update.
|
|
445
|
+
if (skipBulkSync && now - lastBulkSync > cdnSyncRepeatMsecs)
|
|
446
|
+
skipBulkSync = false;
|
|
447
|
+
this.log(`Chaintracks Update Services: Bulk Header Sync Review
|
|
425
448
|
presentHeight=${presentHeight} addLiveRecursionLimit=${this.addLiveRecursionLimit}
|
|
426
449
|
Before synchronize: bulk ${before.bulk}, live ${before.live}
|
|
427
450
|
${skipBulkSync ? 'Skipping' : 'Starting'} syncBulkStorage.
|
|
428
451
|
`);
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
452
|
+
if (!skipBulkSync) {
|
|
453
|
+
// Once available, the initial write lock is released; take a new one to update bulk storage.
|
|
454
|
+
// While not yet available, the makeAvailable write lock is still held.
|
|
455
|
+
if (this.available)
|
|
456
|
+
await this.syncBulkStorage(presentHeight, before);
|
|
457
|
+
else
|
|
458
|
+
await this.syncBulkStorageNoLock(presentHeight, before);
|
|
459
|
+
if (this.startupError != null)
|
|
460
|
+
throw this.startupError;
|
|
461
|
+
return now;
|
|
462
|
+
}
|
|
463
|
+
return lastBulkSync;
|
|
464
|
+
}
|
|
465
|
+
async processLiveHeaderQueue(lastSyncCheck, syncCheckRepeatMsecs) {
|
|
466
|
+
let count = 0;
|
|
467
|
+
let liveHeaderDupes = 0;
|
|
468
|
+
let needSyncCheck = false;
|
|
469
|
+
while (!needSyncCheck && !this.stopMainThread) {
|
|
470
|
+
const liveHeader = this.liveHeaders.shift();
|
|
471
|
+
if (liveHeader != null) {
|
|
472
|
+
const result = await this.processOneLiveHeader(liveHeader);
|
|
473
|
+
if (result.needSyncCheck) {
|
|
474
|
+
needSyncCheck = true;
|
|
475
|
+
continue;
|
|
440
476
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
// Ignore this header...
|
|
460
|
-
this.log(`Ignoring liveHeader ${header.height} ${header.hash} addLiveRecursionLimit=${this.addLiveRecursionLimit} exceeded.`);
|
|
461
|
-
needSyncCheck = true;
|
|
462
|
-
}
|
|
463
|
-
else {
|
|
464
|
-
const hash = header.previousHash;
|
|
465
|
-
const prevHeader = await this.getMissingBlockHeader(hash);
|
|
466
|
-
if (!prevHeader) {
|
|
467
|
-
this.log(`Ignoring liveHeader ${header.height} ${header.hash} failed to find previous header by hash ${(0, utilityHelpers_noBuffer_1.asString)(hash)}`);
|
|
468
|
-
needSyncCheck = true;
|
|
469
|
-
}
|
|
470
|
-
else {
|
|
471
|
-
// Switch to trying to add prevHeader, unshifting current header to try it again after prevHeader exists.
|
|
472
|
-
this.liveHeaders.unshift(header);
|
|
473
|
-
header = prevHeader;
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
else {
|
|
478
|
-
if (this.subscriberCallbacksEnabled)
|
|
479
|
-
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' : ''}`);
|
|
480
|
-
if (ihr.dupe) {
|
|
481
|
-
liveHeaderDupes++;
|
|
482
|
-
}
|
|
483
|
-
// Header wasn't invalid and previous header is known. If it was successfully added, count it as a win.
|
|
484
|
-
if (ihr.added) {
|
|
485
|
-
count++;
|
|
486
|
-
}
|
|
487
|
-
break;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
else {
|
|
492
|
-
// There are no liveHeaders currently to process, check the out-of-band baseHeaders channel (`addHeader` method called by a client).
|
|
493
|
-
const bheader = this.baseHeaders.shift();
|
|
494
|
-
if (bheader) {
|
|
495
|
-
const prev = await this.storage.findLiveHeaderForBlockHash(bheader.previousHash);
|
|
496
|
-
if (!prev) {
|
|
497
|
-
// Ignoring attempt to add a baseHeader with unknown previous hash, no attempt made to find previous header(s).
|
|
498
|
-
this.log(`Ignoring header with unknown previousHash ${bheader.previousHash} in live storage.`);
|
|
499
|
-
// Does not trigger a re-sync.
|
|
500
|
-
}
|
|
501
|
-
else {
|
|
502
|
-
const header = {
|
|
503
|
-
...bheader,
|
|
504
|
-
height: prev.height + 1,
|
|
505
|
-
hash: (0, blockHeaderUtilities_1.blockHash)(bheader)
|
|
506
|
-
};
|
|
507
|
-
const ihr = await this.addLiveHeader(header);
|
|
508
|
-
if (this.invalidInsertHeaderResult(ihr)) {
|
|
509
|
-
this.log(`Ignoring invalid baseHeader ${header.height} ${header.hash}.`);
|
|
510
|
-
}
|
|
511
|
-
else {
|
|
512
|
-
if (this.subscriberCallbacksEnabled)
|
|
513
|
-
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' : ''}`);
|
|
514
|
-
// baseHeader was successfully added.
|
|
515
|
-
if (ihr.added) {
|
|
516
|
-
count++;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
else {
|
|
522
|
-
// There are no liveHeaders and no baseHeaders to add,
|
|
523
|
-
if (count > 0) {
|
|
524
|
-
if (liveHeaderDupes > 0) {
|
|
525
|
-
this.log(`${liveHeaderDupes} duplicate headers ignored.`);
|
|
526
|
-
liveHeaderDupes = 0;
|
|
527
|
-
}
|
|
528
|
-
const updated = await this.storage.getAvailableHeightRanges();
|
|
529
|
-
this.log(`After adding ${count} live headers
|
|
530
|
-
After live: bulk ${updated.bulk}, live ${updated.live}
|
|
531
|
-
`);
|
|
532
|
-
count = 0;
|
|
533
|
-
}
|
|
534
|
-
if (!this.subscriberCallbacksEnabled) {
|
|
535
|
-
const live = await this.storage.findLiveHeightRange();
|
|
536
|
-
if (!live.isEmpty) {
|
|
537
|
-
this.subscriberCallbacksEnabled = true;
|
|
538
|
-
this.log(`listening at height of ${live.maxHeight}`);
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
if (!this.available) {
|
|
542
|
-
this.available = true;
|
|
543
|
-
}
|
|
544
|
-
needSyncCheck = Date.now() - lastSyncCheck > syncCheckRepeatMsecs;
|
|
545
|
-
// If we aren't going to review sync, wait before checking input queues again
|
|
546
|
-
if (!needSyncCheck)
|
|
547
|
-
await (0, utilityHelpers_1.wait)(1000);
|
|
477
|
+
if (result.dupe)
|
|
478
|
+
liveHeaderDupes++;
|
|
479
|
+
if (result.added)
|
|
480
|
+
count++;
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
const bheader = this.baseHeaders.shift();
|
|
484
|
+
if (bheader != null) {
|
|
485
|
+
const added = await this.processOneBaseHeader(bheader);
|
|
486
|
+
if (added)
|
|
487
|
+
count++;
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
// No live or base headers queued — idle path.
|
|
491
|
+
if (count > 0) {
|
|
492
|
+
if (liveHeaderDupes > 0) {
|
|
493
|
+
this.log(`${liveHeaderDupes} duplicate headers ignored.`);
|
|
494
|
+
liveHeaderDupes = 0;
|
|
548
495
|
}
|
|
496
|
+
const updated = await this.storage.getAvailableHeightRanges();
|
|
497
|
+
this.log(`After adding ${count} live headers\n After live: bulk ${updated.bulk}, live ${updated.live}\n`);
|
|
498
|
+
count = 0;
|
|
549
499
|
}
|
|
500
|
+
await this.checkAndEnableSubscribers();
|
|
501
|
+
if (!this.available)
|
|
502
|
+
this.available = true;
|
|
503
|
+
needSyncCheck = Date.now() - lastSyncCheck > syncCheckRepeatMsecs;
|
|
504
|
+
if (!needSyncCheck)
|
|
505
|
+
await (0, utilityHelpers_1.wait)(1000);
|
|
550
506
|
}
|
|
551
507
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
formatIhrLog(prefix, header, ihr) {
|
|
511
|
+
return `${prefix} ${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' : ''}`;
|
|
512
|
+
}
|
|
513
|
+
async processOneLiveHeader(startHeader) {
|
|
514
|
+
let header = startHeader;
|
|
515
|
+
let recursions = this.addLiveRecursionLimit;
|
|
516
|
+
while (!this.stopMainThread) {
|
|
517
|
+
const ihr = await this.addLiveHeader(header);
|
|
518
|
+
if (this.invalidInsertHeaderResult(ihr)) {
|
|
519
|
+
this.log(`Ignoring liveHeader ${header.height} ${header.hash} due to invalid insert result.`);
|
|
520
|
+
return { needSyncCheck: true, dupe: false, added: false };
|
|
521
|
+
}
|
|
522
|
+
if (ihr.noPrev) {
|
|
523
|
+
// Previous header is unknown; request it by hash from the network and try adding it first.
|
|
524
|
+
if (recursions-- <= 0) {
|
|
525
|
+
this.log(`Ignoring liveHeader ${header.height} ${header.hash} addLiveRecursionLimit=${this.addLiveRecursionLimit} exceeded.`);
|
|
526
|
+
return { needSyncCheck: true, dupe: false, added: false };
|
|
557
527
|
}
|
|
558
|
-
|
|
559
|
-
|
|
528
|
+
const prevHeader = await this.getMissingBlockHeader(header.previousHash);
|
|
529
|
+
if (prevHeader == null) {
|
|
530
|
+
this.log(`Ignoring liveHeader ${header.height} ${header.hash} failed to find previous header by hash ${(0, utilityHelpers_noBuffer_1.asString)(header.previousHash)}`);
|
|
531
|
+
return { needSyncCheck: true, dupe: false, added: false };
|
|
560
532
|
}
|
|
533
|
+
// Retry adding prevHeader first; then re-queue current header.
|
|
534
|
+
this.liveHeaders.unshift(header);
|
|
535
|
+
header = prevHeader;
|
|
561
536
|
}
|
|
537
|
+
else {
|
|
538
|
+
if (this.subscriberCallbacksEnabled)
|
|
539
|
+
this.log(this.formatIhrLog('addLiveHeader', header, ihr));
|
|
540
|
+
return { needSyncCheck: false, dupe: ihr.dupe, added: ihr.added };
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
return { needSyncCheck: false, dupe: false, added: false };
|
|
544
|
+
}
|
|
545
|
+
async processOneBaseHeader(bheader) {
|
|
546
|
+
const prev = await this.storage.findLiveHeaderForBlockHash(bheader.previousHash);
|
|
547
|
+
if (prev == null) {
|
|
548
|
+
// Unknown previous hash — ignore without triggering a re-sync.
|
|
549
|
+
this.log(`Ignoring header with unknown previousHash ${bheader.previousHash} in live storage.`);
|
|
550
|
+
return false;
|
|
551
|
+
}
|
|
552
|
+
const header = { ...bheader, height: prev.height + 1, hash: (0, blockHeaderUtilities_1.blockHash)(bheader) };
|
|
553
|
+
const ihr = await this.addLiveHeader(header);
|
|
554
|
+
if (this.invalidInsertHeaderResult(ihr)) {
|
|
555
|
+
this.log(`Ignoring invalid baseHeader ${header.height} ${header.hash}.`);
|
|
556
|
+
return false;
|
|
557
|
+
}
|
|
558
|
+
if (this.subscriberCallbacksEnabled)
|
|
559
|
+
this.log(this.formatIhrLog('addBaseHeader', header, ihr));
|
|
560
|
+
return ihr.added;
|
|
561
|
+
}
|
|
562
|
+
async checkAndEnableSubscribers() {
|
|
563
|
+
if (this.subscriberCallbacksEnabled)
|
|
564
|
+
return;
|
|
565
|
+
const live = await this.storage.findLiveHeightRange();
|
|
566
|
+
if (!live.isEmpty) {
|
|
567
|
+
this.subscriberCallbacksEnabled = true;
|
|
568
|
+
this.log(`listening at height of ${live.maxHeight}`);
|
|
562
569
|
}
|
|
563
570
|
}
|
|
564
571
|
}
|