@bsv/wallet-toolbox 2.12.0 → 2.13.2
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/CHANGELOG.md +350 -1
- package/README.md +556 -6
- package/docs/README.md +8 -1
- package/docs/client.md +13057 -4632
- package/docs/identity-verification.md +196 -0
- package/docs/monitor.md +505 -190
- package/docs/services.md +4013 -1153
- package/docs/setup.md +98 -58
- package/docs/storage.md +5780 -1609
- package/docs/sync-transfer.md +144 -0
- package/docs/wallet.md +10155 -10871
- package/out/src/CWIStyleWalletManager.d.ts +6 -8
- package/out/src/CWIStyleWalletManager.d.ts.map +1 -1
- package/out/src/CWIStyleWalletManager.js +170 -125
- package/out/src/CWIStyleWalletManager.js.map +1 -1
- package/out/src/Setup.d.ts +2 -0
- package/out/src/Setup.d.ts.map +1 -1
- package/out/src/Setup.js +3 -2
- package/out/src/Setup.js.map +1 -1
- package/out/src/ShamirWalletManager.d.ts.map +1 -1
- package/out/src/ShamirWalletManager.js +34 -19
- package/out/src/ShamirWalletManager.js.map +1 -1
- package/out/src/SimpleWalletManager.d.ts.map +1 -1
- package/out/src/SimpleWalletManager.js +7 -6
- package/out/src/SimpleWalletManager.js.map +1 -1
- package/out/src/Wallet.d.ts +50 -11
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +183 -107
- package/out/src/Wallet.js.map +1 -1
- package/out/src/WalletAuthenticationManager.d.ts.map +1 -1
- package/out/src/WalletAuthenticationManager.js +282 -26
- package/out/src/WalletAuthenticationManager.js.map +1 -1
- package/out/src/WalletLogger.js +1 -1
- package/out/src/WalletLogger.js.map +1 -1
- package/out/src/WalletPermissionsManager.d.ts +30 -17
- package/out/src/WalletPermissionsManager.d.ts.map +1 -1
- package/out/src/WalletPermissionsManager.js +540 -312
- package/out/src/WalletPermissionsManager.js.map +1 -1
- package/out/src/WalletSettingsManager.d.ts +3 -2
- package/out/src/WalletSettingsManager.d.ts.map +1 -1
- package/out/src/WalletSettingsManager.js +141 -6
- package/out/src/WalletSettingsManager.js.map +1 -1
- package/out/src/entropy/EntropyCollector.d.ts.map +1 -1
- package/out/src/entropy/EntropyCollector.js +3 -2
- package/out/src/entropy/EntropyCollector.js.map +1 -1
- package/out/src/fundWalletP2PKH.d.ts.map +1 -1
- package/out/src/fundWalletP2PKH.js +143 -44
- package/out/src/fundWalletP2PKH.js.map +1 -1
- package/out/src/mockchain/MockChainTracker.d.ts.map +1 -1
- package/out/src/mockchain/MockChainTracker.js +5 -5
- package/out/src/mockchain/MockChainTracker.js.map +1 -1
- package/out/src/mockchain/MockServices.d.ts.map +1 -1
- package/out/src/mockchain/MockServices.js +32 -8
- package/out/src/mockchain/MockServices.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 +206 -42
- package/out/src/monitor/Monitor.js.map +1 -1
- package/out/src/monitor/MonitorDaemon.d.ts.map +1 -1
- package/out/src/monitor/MonitorDaemon.js +64 -16
- package/out/src/monitor/MonitorDaemon.js.map +1 -1
- package/out/src/monitor/monitorValidation.d.ts +12 -0
- package/out/src/monitor/monitorValidation.d.ts.map +1 -0
- package/out/src/monitor/monitorValidation.js +133 -0
- package/out/src/monitor/monitorValidation.js.map +1 -0
- package/out/src/monitor/tasks/TaskArcSSE.d.ts +2 -0
- package/out/src/monitor/tasks/TaskArcSSE.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskArcSSE.js +28 -12
- package/out/src/monitor/tasks/TaskArcSSE.js.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +5 -0
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.js +29 -24
- package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
- package/out/src/monitor/tasks/TaskCheckNoSends.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskCheckNoSends.js +11 -3
- package/out/src/monitor/tasks/TaskCheckNoSends.js.map +1 -1
- package/out/src/monitor/tasks/TaskFailAbandoned.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskFailAbandoned.js +9 -4
- package/out/src/monitor/tasks/TaskFailAbandoned.js.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.js +3 -1
- package/out/src/monitor/tasks/TaskNewHeader.js.map +1 -1
- package/out/src/monitor/tasks/TaskReconcilePendingTransactions.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReconcilePendingTransactions.js +9 -3
- package/out/src/monitor/tasks/TaskReconcilePendingTransactions.js.map +1 -1
- package/out/src/monitor/tasks/TaskReorg.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReorg.js +4 -4
- package/out/src/monitor/tasks/TaskReorg.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewDoubleSpends.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewDoubleSpends.js +17 -7
- package/out/src/monitor/tasks/TaskReviewDoubleSpends.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewProvenTxs.d.ts +18 -1
- package/out/src/monitor/tasks/TaskReviewProvenTxs.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewProvenTxs.js +99 -21
- package/out/src/monitor/tasks/TaskReviewProvenTxs.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewUtxos.d.ts +4 -4
- package/out/src/monitor/tasks/TaskReviewUtxos.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewUtxos.js +41 -13
- package/out/src/monitor/tasks/TaskReviewUtxos.js.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.js +52 -11
- package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
- package/out/src/monitor/tasks/TaskUnFail.d.ts +1 -0
- package/out/src/monitor/tasks/TaskUnFail.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskUnFail.js +26 -8
- package/out/src/monitor/tasks/TaskUnFail.js.map +1 -1
- package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -1
- package/out/src/sdk/PrivilegedKeyManager.js +3 -2
- package/out/src/sdk/PrivilegedKeyManager.js.map +1 -1
- package/out/src/sdk/WalletErrorFromJson.d.ts.map +1 -1
- package/out/src/sdk/WalletErrorFromJson.js +112 -2
- package/out/src/sdk/WalletErrorFromJson.js.map +1 -1
- package/out/src/sdk/WalletServices.interfaces.d.ts +23 -1
- package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
- package/out/src/sdk/WalletStorage.interfaces.d.ts +49 -3
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/out/src/services/ServiceCollection.js +2 -2
- 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 +276 -110
- package/out/src/services/Services.js.map +1 -1
- package/out/src/services/chaintracker/BHServiceClient.d.ts +21 -4
- package/out/src/services/chaintracker/BHServiceClient.d.ts.map +1 -1
- package/out/src/services/chaintracker/BHServiceClient.js +267 -66
- package/out/src/services/chaintracker/BHServiceClient.js.map +1 -1
- package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts +25 -3
- package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts.map +1 -1
- package/out/src/services/chaintracker/ChaintracksChainTracker.js +188 -53
- package/out/src/services/chaintracker/ChaintracksChainTracker.js.map +1 -1
- package/out/src/services/chaintracker/LocalChainTracker.d.ts +26 -0
- package/out/src/services/chaintracker/LocalChainTracker.d.ts.map +1 -1
- package/out/src/services/chaintracker/LocalChainTracker.js +180 -10
- package/out/src/services/chaintracker/LocalChainTracker.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.js +59 -7
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksApi.d.ts +6 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksApi.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi.d.ts +7 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFetchApi.d.ts +2 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFetchApi.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksStorageApi.d.ts +9 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksStorageApi.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts +19 -0
- package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Chaintracks.js +237 -61
- package/out/src/services/chaintracker/chaintracks/Chaintracks.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksService.d.ts +16 -0
- package/out/src/services/chaintracker/chaintracks/ChaintracksService.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksService.js +150 -26
- package/out/src/services/chaintracker/chaintracks/ChaintracksService.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts +30 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +346 -30
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/GoChaintracksServiceClient.d.ts +32 -1
- package/out/src/services/chaintracker/chaintracks/GoChaintracksServiceClient.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/GoChaintracksServiceClient.js +375 -43
- package/out/src/services/chaintracker/chaintracks/GoChaintracksServiceClient.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 +28 -3
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js +33 -9
- 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/BulkIngestorChaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorChaintracks.js +4 -2
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorChaintracks.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.d.ts +2 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js +17 -4
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainWs.d.ts +2 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainWs.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainWs.js +40 -20
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainWs.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 +14 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorChaintracksSSE.d.ts +6 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorChaintracksSSE.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorChaintracksSSE.js +56 -9
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorChaintracksSSE.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorTeranodeP2P.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorTeranodeP2P.js +6 -3
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorTeranodeP2P.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.d.ts +4 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js +27 -9
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainWs.d.ts +8 -0
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainWs.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainWs.js +49 -5
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainWs.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js +90 -21
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts +3 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.js +185 -38
- 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 +59 -6
- package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksKnexMigrations.d.ts +2 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksKnexMigrations.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksKnexMigrations.js +89 -39
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksKnexMigrations.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts +10 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js +225 -24
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.d.ts +2 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js +265 -96
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.d.ts +3 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.js +225 -86
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts +3 -0
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js +121 -35
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/configureChaintracksIngestors.js +2 -2
- package/out/src/services/chaintracker/chaintracks/configureChaintracksIngestors.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultKnexChaintracksOptions.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultKnexChaintracksOptions.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.js +1 -7
- package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createKnexChaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createKnexChaintracks.js +1 -7
- package/out/src/services/chaintracker/chaintracks/createKnexChaintracks.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.js +1 -7
- package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataCacheFs.d.ts +18 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataCacheFs.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataCacheFs.js +204 -14
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataCacheFs.js.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 +486 -82
- 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 +17 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataValidator.worker.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataValidator.worker.js +12 -2
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataValidator.worker.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 +99 -30
- package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.d.ts +1 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.js +23 -15
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts +7 -0
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js +90 -24
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFs.d.ts +2 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFs.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFs.js +57 -11
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFs.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/DurableFileBulkFileDownloadBudget.d.ts +9 -0
- package/out/src/services/chaintracker/chaintracks/util/DurableFileBulkFileDownloadBudget.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/DurableFileBulkFileDownloadBudget.js +100 -14
- package/out/src/services/chaintracker/chaintracks/util/DurableFileBulkFileDownloadBudget.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.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/InlineBulkFileDataValidator.d.ts +2 -0
- package/out/src/services/chaintracker/chaintracks/util/InlineBulkFileDataValidator.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/InlineBulkFileDataValidator.js +104 -8
- package/out/src/services/chaintracker/chaintracks/util/InlineBulkFileDataValidator.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/NodeBulkFileDataValidator.d.ts +1 -0
- package/out/src/services/chaintracker/chaintracks/util/NodeBulkFileDataValidator.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/NodeBulkFileDataValidator.js +79 -15
- package/out/src/services/chaintracker/chaintracks/util/NodeBulkFileDataValidator.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts +3 -0
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.js +15 -0
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts +6 -1
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js +311 -93
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/safeDiagnostic.d.ts +4 -0
- package/out/src/services/chaintracker/chaintracks/util/safeDiagnostic.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/safeDiagnostic.js +33 -0
- package/out/src/services/chaintracker/chaintracks/util/safeDiagnostic.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.js.map +1 -1
- package/out/src/services/classifyOutputUtxo.d.ts.map +1 -1
- package/out/src/services/classifyOutputUtxo.js +19 -10
- package/out/src/services/classifyOutputUtxo.js.map +1 -1
- package/out/src/services/fiatRateValidation.d.ts +12 -0
- package/out/src/services/fiatRateValidation.d.ts.map +1 -0
- package/out/src/services/fiatRateValidation.js +138 -0
- package/out/src/services/fiatRateValidation.js.map +1 -0
- package/out/src/services/getCanonicalMerklePath.d.ts +15 -0
- package/out/src/services/getCanonicalMerklePath.d.ts.map +1 -0
- package/out/src/services/getCanonicalMerklePath.js +90 -0
- package/out/src/services/getCanonicalMerklePath.js.map +1 -0
- package/out/src/services/providers/ARC.d.ts +3 -16
- package/out/src/services/providers/ARC.d.ts.map +1 -1
- package/out/src/services/providers/ARC.js +36 -37
- package/out/src/services/providers/ARC.js.map +1 -1
- package/out/src/services/providers/ArcSSEClient.d.ts +25 -19
- package/out/src/services/providers/ArcSSEClient.d.ts.map +1 -1
- package/out/src/services/providers/ArcSSEClient.js +352 -85
- package/out/src/services/providers/ArcSSEClient.js.map +1 -1
- package/out/src/services/providers/Arcade.d.ts +1 -0
- package/out/src/services/providers/Arcade.d.ts.map +1 -1
- package/out/src/services/providers/Arcade.js +56 -41
- package/out/src/services/providers/Arcade.js.map +1 -1
- package/out/src/services/providers/Bitails.d.ts +3 -0
- package/out/src/services/providers/Bitails.d.ts.map +1 -1
- package/out/src/services/providers/Bitails.js +79 -12
- package/out/src/services/providers/Bitails.js.map +1 -1
- package/out/src/services/providers/SdkWhatsOnChain.d.ts +8 -2
- package/out/src/services/providers/SdkWhatsOnChain.d.ts.map +1 -1
- package/out/src/services/providers/SdkWhatsOnChain.js +83 -10
- package/out/src/services/providers/SdkWhatsOnChain.js.map +1 -1
- package/out/src/services/providers/WhatsOnChain.d.ts +3 -0
- package/out/src/services/providers/WhatsOnChain.d.ts.map +1 -1
- package/out/src/services/providers/WhatsOnChain.js +221 -69
- package/out/src/services/providers/WhatsOnChain.js.map +1 -1
- package/out/src/services/providers/arcProviderConfig.d.ts +27 -0
- package/out/src/services/providers/arcProviderConfig.d.ts.map +1 -0
- package/out/src/services/providers/arcProviderConfig.js +83 -0
- package/out/src/services/providers/arcProviderConfig.js.map +1 -0
- package/out/src/services/providers/arcTxDataValidation.d.ts +4 -0
- package/out/src/services/providers/arcTxDataValidation.d.ts.map +1 -0
- package/out/src/services/providers/arcTxDataValidation.js +92 -0
- package/out/src/services/providers/arcTxDataValidation.js.map +1 -0
- package/out/src/services/providers/exchangeRates.d.ts +3 -3
- package/out/src/services/providers/exchangeRates.d.ts.map +1 -1
- package/out/src/services/providers/exchangeRates.js +153 -226
- package/out/src/services/providers/exchangeRates.js.map +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 +2 -2
- package/out/src/services/providers/whatsOnChainHelpers.d.ts.map +1 -1
- package/out/src/services/providers/whatsOnChainHelpers.js +11 -8
- package/out/src/services/providers/whatsOnChainHelpers.js.map +1 -1
- package/out/src/services/validateMerklePathResult.d.ts +30 -0
- package/out/src/services/validateMerklePathResult.d.ts.map +1 -0
- package/out/src/services/validateMerklePathResult.js +272 -0
- package/out/src/services/validateMerklePathResult.js.map +1 -0
- package/out/src/services/validatePostBeefResult.d.ts +17 -0
- package/out/src/services/validatePostBeefResult.d.ts.map +1 -0
- package/out/src/services/validatePostBeefResult.js +334 -0
- package/out/src/services/validatePostBeefResult.js.map +1 -0
- package/out/src/services/validateRawTxResult.d.ts +6 -0
- package/out/src/services/validateRawTxResult.d.ts.map +1 -0
- package/out/src/services/validateRawTxResult.js +77 -0
- package/out/src/services/validateRawTxResult.js.map +1 -0
- package/out/src/services/validateScriptHashHistoryResult.d.ts +5 -0
- package/out/src/services/validateScriptHashHistoryResult.d.ts.map +1 -0
- package/out/src/services/validateScriptHashHistoryResult.js +99 -0
- package/out/src/services/validateScriptHashHistoryResult.js.map +1 -0
- package/out/src/services/validateStatusForTxidsResult.d.ts +8 -0
- package/out/src/services/validateStatusForTxidsResult.d.ts.map +1 -0
- package/out/src/services/validateStatusForTxidsResult.js +181 -0
- package/out/src/services/validateStatusForTxidsResult.js.map +1 -0
- package/out/src/services/validateUtxoStatusResult.d.ts +6 -0
- package/out/src/services/validateUtxoStatusResult.d.ts.map +1 -0
- package/out/src/services/validateUtxoStatusResult.js +126 -0
- package/out/src/services/validateUtxoStatusResult.js.map +1 -0
- package/out/src/signer/actionBatch/ActionBatchPlanner.d.ts +3 -2
- package/out/src/signer/actionBatch/ActionBatchPlanner.d.ts.map +1 -1
- package/out/src/signer/actionBatch/ActionBatchPlanner.js +4 -3
- package/out/src/signer/actionBatch/ActionBatchPlanner.js.map +1 -1
- package/out/src/signer/actionBatch/ActionBatchWorkspace.d.ts +6 -5
- package/out/src/signer/actionBatch/ActionBatchWorkspace.d.ts.map +1 -1
- package/out/src/signer/actionBatch/ActionBatchWorkspace.js +70 -76
- package/out/src/signer/actionBatch/ActionBatchWorkspace.js.map +1 -1
- package/out/src/signer/actionBatch/actionBatchBootstrap.d.ts +2 -2
- package/out/src/signer/actionBatch/actionBatchBootstrap.d.ts.map +1 -1
- package/out/src/signer/actionBatch/actionBatchBootstrap.js +3 -3
- package/out/src/signer/actionBatch/actionBatchBootstrap.js.map +1 -1
- package/out/src/signer/methods/acquireDirectCertificate.d.ts +3 -2
- package/out/src/signer/methods/acquireDirectCertificate.d.ts.map +1 -1
- package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.d.ts +6 -5
- package/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.js +6 -11
- package/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
- package/out/src/signer/methods/createAction.d.ts +4 -3
- package/out/src/signer/methods/createAction.d.ts.map +1 -1
- package/out/src/signer/methods/createAction.js +4 -2
- package/out/src/signer/methods/createAction.js.map +1 -1
- package/out/src/signer/methods/createNoSendExpiryAction.d.ts +3 -3
- package/out/src/signer/methods/createNoSendExpiryAction.d.ts.map +1 -1
- package/out/src/signer/methods/createNoSendExpiryAction.js +9 -4
- package/out/src/signer/methods/createNoSendExpiryAction.js.map +1 -1
- package/out/src/signer/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/signer/methods/internalizeAction.js +2 -2
- package/out/src/signer/methods/internalizeAction.js.map +1 -1
- package/out/src/signer/methods/proveCertificate.d.ts +3 -2
- package/out/src/signer/methods/proveCertificate.d.ts.map +1 -1
- package/out/src/signer/methods/proveCertificate.js.map +1 -1
- package/out/src/signer/methods/signAction.d.ts.map +1 -1
- package/out/src/signer/methods/signAction.js +3 -2
- package/out/src/signer/methods/signAction.js.map +1 -1
- package/out/src/signer/methods/verifyUnlockScripts.d.ts.map +1 -1
- package/out/src/signer/methods/verifyUnlockScripts.js +12 -17
- package/out/src/signer/methods/verifyUnlockScripts.js.map +1 -1
- package/out/src/storage/StorageIdb.d.ts +6 -3
- package/out/src/storage/StorageIdb.d.ts.map +1 -1
- package/out/src/storage/StorageIdb.js +70 -42
- package/out/src/storage/StorageIdb.js.map +1 -1
- package/out/src/storage/StorageKnex.d.ts +8 -4
- package/out/src/storage/StorageKnex.d.ts.map +1 -1
- package/out/src/storage/StorageKnex.js +185 -92
- package/out/src/storage/StorageKnex.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts +19 -9
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +237 -138
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/StorageReader.d.ts +7 -1
- package/out/src/storage/StorageReader.d.ts.map +1 -1
- package/out/src/storage/StorageReader.js +17 -42
- package/out/src/storage/StorageReader.js.map +1 -1
- package/out/src/storage/StorageReaderWriter.d.ts +2 -0
- package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
- package/out/src/storage/StorageReaderWriter.js +63 -38
- package/out/src/storage/StorageReaderWriter.js.map +1 -1
- package/out/src/storage/StorageSyncReader.d.ts +1 -1
- package/out/src/storage/StorageSyncReader.d.ts.map +1 -1
- package/out/src/storage/StorageSyncReader.js +3 -36
- package/out/src/storage/StorageSyncReader.js.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts +9 -7
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.js +71 -65
- package/out/src/storage/WalletStorageManager.js.map +1 -1
- package/out/src/storage/adminServer/adminServer.d.ts +1 -1
- package/out/src/storage/adminServer/adminServer.d.ts.map +1 -1
- package/out/src/storage/adminServer/adminServer.js +16 -44
- package/out/src/storage/adminServer/adminServer.js.map +1 -1
- package/out/src/storage/methods/ListActionsSpecOp.d.ts +2 -2
- package/out/src/storage/methods/ListActionsSpecOp.d.ts.map +1 -1
- package/out/src/storage/methods/ListActionsSpecOp.js.map +1 -1
- package/out/src/storage/methods/ListOutputsSpecOp.d.ts +7 -4
- package/out/src/storage/methods/ListOutputsSpecOp.d.ts.map +1 -1
- package/out/src/storage/methods/ListOutputsSpecOp.js +1 -0
- package/out/src/storage/methods/ListOutputsSpecOp.js.map +1 -1
- package/out/src/storage/methods/actionBatch.d.ts.map +1 -1
- package/out/src/storage/methods/actionBatch.js +3 -2
- package/out/src/storage/methods/actionBatch.js.map +1 -1
- package/out/src/storage/methods/actionBatchBlobs.d.ts +2 -0
- package/out/src/storage/methods/actionBatchBlobs.d.ts.map +1 -1
- package/out/src/storage/methods/actionBatchBlobs.js +40 -22
- package/out/src/storage/methods/actionBatchBlobs.js.map +1 -1
- package/out/src/storage/methods/actionBatchValidation.d.ts.map +1 -1
- package/out/src/storage/methods/actionBatchValidation.js +22 -30
- package/out/src/storage/methods/actionBatchValidation.js.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +7 -2
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js +57 -44
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
- package/out/src/storage/methods/createAction.d.ts +7 -6
- package/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/out/src/storage/methods/createAction.js +7 -5
- 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 +12 -11
- package/out/src/storage/methods/generateChange.js.map +1 -1
- package/out/src/storage/methods/getBeefForTransaction.js +5 -7
- 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 +42 -11
- package/out/src/storage/methods/getSyncChunk.js.map +1 -1
- package/out/src/storage/methods/internalizeAction.d.ts +3 -3
- package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/storage/methods/internalizeAction.js +134 -129
- package/out/src/storage/methods/internalizeAction.js.map +1 -1
- package/out/src/storage/methods/listActionsIdb.d.ts +3 -2
- package/out/src/storage/methods/listActionsIdb.d.ts.map +1 -1
- package/out/src/storage/methods/listActionsIdb.js +2 -2
- package/out/src/storage/methods/listActionsIdb.js.map +1 -1
- package/out/src/storage/methods/listActionsKnex.d.ts +3 -2
- package/out/src/storage/methods/listActionsKnex.d.ts.map +1 -1
- package/out/src/storage/methods/listActionsKnex.js +10 -9
- package/out/src/storage/methods/listActionsKnex.js.map +1 -1
- package/out/src/storage/methods/listCertificates.d.ts +3 -2
- package/out/src/storage/methods/listCertificates.d.ts.map +1 -1
- package/out/src/storage/methods/listCertificates.js.map +1 -1
- package/out/src/storage/methods/listOutputsIdb.d.ts +3 -2
- package/out/src/storage/methods/listOutputsIdb.d.ts.map +1 -1
- package/out/src/storage/methods/listOutputsIdb.js +11 -11
- package/out/src/storage/methods/listOutputsIdb.js.map +1 -1
- package/out/src/storage/methods/listOutputsKnex.d.ts +3 -2
- package/out/src/storage/methods/listOutputsKnex.d.ts.map +1 -1
- package/out/src/storage/methods/listOutputsKnex.js +15 -23
- package/out/src/storage/methods/listOutputsKnex.js.map +1 -1
- package/out/src/storage/methods/noSendExpiry.d.ts +3 -3
- package/out/src/storage/methods/noSendExpiry.d.ts.map +1 -1
- package/out/src/storage/methods/noSendExpiry.js +10 -8
- package/out/src/storage/methods/noSendExpiry.js.map +1 -1
- package/out/src/storage/methods/preparedBeef.d.ts.map +1 -1
- package/out/src/storage/methods/preparedBeef.js +13 -14
- package/out/src/storage/methods/preparedBeef.js.map +1 -1
- package/out/src/storage/methods/processAction.d.ts.map +1 -1
- package/out/src/storage/methods/processAction.js +37 -6
- package/out/src/storage/methods/processAction.js.map +1 -1
- package/out/src/storage/methods/reconcileFailedTransactionInputs.d.ts +1 -1
- package/out/src/storage/methods/reconcileFailedTransactionInputs.d.ts.map +1 -1
- package/out/src/storage/methods/reconcileFailedTransactionInputs.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/reviewUtxoOutputs.d.ts +1 -0
- package/out/src/storage/methods/reviewUtxoOutputs.d.ts.map +1 -1
- package/out/src/storage/methods/reviewUtxoOutputs.js +51 -4
- package/out/src/storage/methods/reviewUtxoOutputs.js.map +1 -1
- package/out/src/storage/methods/validateSyncProof.d.ts +10 -2
- package/out/src/storage/methods/validateSyncProof.d.ts.map +1 -1
- package/out/src/storage/methods/validateSyncProof.js +27 -4
- package/out/src/storage/methods/validateSyncProof.js.map +1 -1
- package/out/src/storage/portable/index.d.ts.map +1 -1
- package/out/src/storage/portable/index.js +21 -13
- package/out/src/storage/portable/index.js.map +1 -1
- package/out/src/storage/remoting/BinaryJson.d.ts +11 -0
- package/out/src/storage/remoting/BinaryJson.d.ts.map +1 -1
- package/out/src/storage/remoting/BinaryJson.js +94 -8
- package/out/src/storage/remoting/BinaryJson.js.map +1 -1
- package/out/src/storage/remoting/KnexSessionManager.d.ts +26 -2
- package/out/src/storage/remoting/KnexSessionManager.d.ts.map +1 -1
- package/out/src/storage/remoting/KnexSessionManager.js +222 -30
- package/out/src/storage/remoting/KnexSessionManager.js.map +1 -1
- package/out/src/storage/remoting/KnexSyncTransferStore.d.ts +26 -0
- package/out/src/storage/remoting/KnexSyncTransferStore.d.ts.map +1 -0
- package/out/src/storage/remoting/KnexSyncTransferStore.js +222 -0
- package/out/src/storage/remoting/KnexSyncTransferStore.js.map +1 -0
- package/out/src/storage/remoting/StorageClient.d.ts +6 -1
- package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClient.js +65 -8
- package/out/src/storage/remoting/StorageClient.js.map +1 -1
- package/out/src/storage/remoting/StorageClientBase.d.ts +53 -10
- package/out/src/storage/remoting/StorageClientBase.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClientBase.js +304 -9
- package/out/src/storage/remoting/StorageClientBase.js.map +1 -1
- package/out/src/storage/remoting/StorageMobile.d.ts +5 -0
- package/out/src/storage/remoting/StorageMobile.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageMobile.js +13 -11
- package/out/src/storage/remoting/StorageMobile.js.map +1 -1
- package/out/src/storage/remoting/StorageServer.d.ts +10 -1
- package/out/src/storage/remoting/StorageServer.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageServer.js +206 -21
- package/out/src/storage/remoting/StorageServer.js.map +1 -1
- package/out/src/storage/remoting/SyncTransfer.d.ts +29 -0
- package/out/src/storage/remoting/SyncTransfer.d.ts.map +1 -0
- package/out/src/storage/remoting/SyncTransfer.js +153 -0
- package/out/src/storage/remoting/SyncTransfer.js.map +1 -0
- package/out/src/storage/remoting/entityValidationHelpers.d.ts.map +1 -1
- package/out/src/storage/remoting/entityValidationHelpers.js +35 -0
- package/out/src/storage/remoting/entityValidationHelpers.js.map +1 -1
- package/out/src/storage/remoting/syncChunkBinary.d.ts +4 -0
- package/out/src/storage/remoting/syncChunkBinary.d.ts.map +1 -0
- package/out/src/storage/remoting/syncChunkBinary.js +38 -0
- package/out/src/storage/remoting/syncChunkBinary.js.map +1 -0
- package/out/src/storage/remoting/validateRpcSyncProofs.d.ts +5 -0
- package/out/src/storage/remoting/validateRpcSyncProofs.d.ts.map +1 -0
- package/out/src/storage/remoting/validateRpcSyncProofs.js +82 -0
- package/out/src/storage/remoting/validateRpcSyncProofs.js.map +1 -0
- package/out/src/storage/schema/KnexMigrations.d.ts +3 -0
- package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -1
- package/out/src/storage/schema/KnexMigrations.js +89 -2
- package/out/src/storage/schema/KnexMigrations.js.map +1 -1
- package/out/src/storage/schema/StorageIdbSchema.d.ts +1 -0
- package/out/src/storage/schema/StorageIdbSchema.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityOutput.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityOutput.js +11 -4
- package/out/src/storage/schema/entities/EntityOutput.js.map +1 -1
- package/out/src/storage/schema/entities/EntityProvenTx.d.ts +2 -1
- package/out/src/storage/schema/entities/EntityProvenTx.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityProvenTx.js +95 -41
- package/out/src/storage/schema/entities/EntityProvenTx.js.map +1 -1
- package/out/src/storage/schema/entities/EntityProvenTxReq.js +1 -1
- package/out/src/storage/schema/entities/EntityProvenTxReq.js.map +1 -1
- package/out/src/storage/schema/entities/EntitySyncState.d.ts +3 -1
- package/out/src/storage/schema/entities/EntitySyncState.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntitySyncState.js +7 -1
- package/out/src/storage/schema/entities/EntitySyncState.js.map +1 -1
- package/out/src/storage/schema/tables/TableCertificate.d.ts +1 -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 +1 -1
- package/out/src/storage/schema/tables/TableOutput.d.ts.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 +1 -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/TableTransaction.js.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/sync/StorageMySQLDojoReader.d.ts.map +1 -1
- package/out/src/storage/sync/StorageMySQLDojoReader.js +8 -7
- package/out/src/storage/sync/StorageMySQLDojoReader.js.map +1 -1
- package/out/src/storage/sync/SyncPageBudget.d.ts +8 -0
- package/out/src/storage/sync/SyncPageBudget.d.ts.map +1 -0
- package/out/src/storage/sync/SyncPageBudget.js +24 -0
- package/out/src/storage/sync/SyncPageBudget.js.map +1 -0
- package/out/src/storage/sync/syncCheckpoint.d.ts +4 -0
- package/out/src/storage/sync/syncCheckpoint.d.ts.map +1 -0
- package/out/src/storage/sync/syncCheckpoint.js +49 -0
- package/out/src/storage/sync/syncCheckpoint.js.map +1 -0
- package/out/src/utility/actionBatchDigest.d.ts.map +1 -1
- package/out/src/utility/actionBatchDigest.js +9 -7
- package/out/src/utility/actionBatchDigest.js.map +1 -1
- package/out/src/utility/actionBatchPack.d.ts.map +1 -1
- package/out/src/utility/actionBatchPack.js +7 -12
- package/out/src/utility/actionBatchPack.js.map +1 -1
- package/out/src/utility/brc153ReferenceLabels.d.ts.map +1 -1
- package/out/src/utility/brc153ReferenceLabels.js +4 -4
- package/out/src/utility/brc153ReferenceLabels.js.map +1 -1
- package/out/src/utility/brc177NoSendExpiry.d.ts +2 -2
- package/out/src/utility/brc177NoSendExpiry.d.ts.map +1 -1
- package/out/src/utility/canonicalizeAtomicBeef.js +2 -2
- package/out/src/utility/canonicalizeAtomicBeef.js.map +1 -1
- package/out/src/utility/exactActionSpend.d.ts +11 -0
- package/out/src/utility/exactActionSpend.d.ts.map +1 -0
- package/out/src/utility/exactActionSpend.js +11 -0
- package/out/src/utility/exactActionSpend.js.map +1 -0
- package/out/src/utility/identityUtils.d.ts +44 -4
- package/out/src/utility/identityUtils.d.ts.map +1 -1
- package/out/src/utility/identityUtils.js +376 -61
- package/out/src/utility/identityUtils.js.map +1 -1
- package/out/src/utility/parseTxScriptOffsets.d.ts.map +1 -1
- package/out/src/utility/parseTxScriptOffsets.js +1 -19
- package/out/src/utility/parseTxScriptOffsets.js.map +1 -1
- package/out/src/utility/tscProofToMerklePath.d.ts.map +1 -1
- package/out/src/utility/tscProofToMerklePath.js +35 -4
- package/out/src/utility/tscProofToMerklePath.js.map +1 -1
- package/out/src/utility/utilityHelpers.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.js +8 -6
- package/out/src/utility/utilityHelpers.js.map +1 -1
- package/out/src/utility/utilityHelpers.noBuffer.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.noBuffer.js +6 -6
- package/out/src/utility/utilityHelpers.noBuffer.js.map +1 -1
- package/out/src/utility/verifyOverlayOutput.d.ts +12 -0
- package/out/src/utility/verifyOverlayOutput.d.ts.map +1 -0
- package/out/src/utility/verifyOverlayOutput.js +22 -0
- package/out/src/utility/verifyOverlayOutput.js.map +1 -0
- package/out/src/utility/walletResultGuards.d.ts +14 -0
- package/out/src/utility/walletResultGuards.d.ts.map +1 -0
- package/out/src/utility/walletResultGuards.js +28 -0
- package/out/src/utility/walletResultGuards.js.map +1 -0
- package/out/src/wab-client/WABClient.d.ts +3 -17
- package/out/src/wab-client/WABClient.d.ts.map +1 -1
- package/out/src/wab-client/WABClient.js +30 -14
- package/out/src/wab-client/WABClient.js.map +1 -1
- package/out/src/wab-client/WABResponseValidation.d.ts +48 -0
- package/out/src/wab-client/WABResponseValidation.d.ts.map +1 -0
- package/out/src/wab-client/WABResponseValidation.js +321 -0
- package/out/src/wab-client/WABResponseValidation.js.map +1 -0
- 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 -2
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js.map +1 -1
- package/package.json +6 -5
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BulkFileDataReader = exports.BulkFileDataManager = void 0;
|
|
4
|
+
exports.normalizeBulkHeaderFileInfo = normalizeBulkHeaderFileInfo;
|
|
5
|
+
exports.normalizeBulkHeaderFilesInfo = normalizeBulkHeaderFilesInfo;
|
|
6
|
+
exports.normalizeBulkHeaderFileSequence = normalizeBulkHeaderFileSequence;
|
|
4
7
|
exports.selectBulkHeaderFiles = selectBulkHeaderFiles;
|
|
5
8
|
const BulkFileDataReader_1 = require("./BulkFileDataReader");
|
|
6
9
|
const sdk_1 = require("../../../../sdk");
|
|
7
|
-
const
|
|
10
|
+
const Hash_1 = require("@bsv/sdk/primitives/Hash");
|
|
8
11
|
const utilityHelpers_noBuffer_1 = require("../../../../utility/utilityHelpers.noBuffer");
|
|
9
12
|
const validBulkHeaderFilesByFileHash_1 = require("./validBulkHeaderFilesByFileHash");
|
|
10
13
|
const HeightRange_1 = require("./HeightRange");
|
|
@@ -13,6 +16,187 @@ const ChaintracksFetch_1 = require("./ChaintracksFetch");
|
|
|
13
16
|
const SingleWriterMultiReaderLock_1 = require("./SingleWriterMultiReaderLock");
|
|
14
17
|
const BulkFileDataValidatorApi_1 = require("../Api/BulkFileDataValidatorApi");
|
|
15
18
|
const InlineBulkFileDataValidator_1 = require("./InlineBulkFileDataValidator");
|
|
19
|
+
const MAX_BULK_FILE_HEADERS = 100_000;
|
|
20
|
+
const MAX_BULK_MANIFEST_FILES = 10_000;
|
|
21
|
+
const MAX_BULK_FILE_NAME_BYTES = 255;
|
|
22
|
+
const HEX_32_BYTES = /^[0-9a-f]{64}$/;
|
|
23
|
+
const SHA256_BASE64 = /^[A-Za-z0-9+/]{43}=$/;
|
|
24
|
+
const SAFE_BULK_FILE_NAME = /^[A-Za-z0-9][A-Za-z0-9._~-]*$/;
|
|
25
|
+
const SUPPORTED_CHAINS = new Set(['main', 'test', 'stn', 'ttn', 'tstn', 'mock']);
|
|
26
|
+
function ownDataValue(value, property, required = true) {
|
|
27
|
+
if (value == null || typeof value !== 'object') {
|
|
28
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('bulk file metadata', 'an object containing plain data properties');
|
|
29
|
+
}
|
|
30
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, property);
|
|
31
|
+
if (descriptor == null) {
|
|
32
|
+
if (!required)
|
|
33
|
+
return undefined;
|
|
34
|
+
throw new sdk_1.WERR_INVALID_PARAMETER(`bulk file ${property}`, 'defined');
|
|
35
|
+
}
|
|
36
|
+
if (!('value' in descriptor)) {
|
|
37
|
+
throw new sdk_1.WERR_INVALID_PARAMETER(`bulk file ${property}`, 'an own data property');
|
|
38
|
+
}
|
|
39
|
+
return descriptor.value;
|
|
40
|
+
}
|
|
41
|
+
function optionalString(value, name, maximum) {
|
|
42
|
+
if (value === undefined)
|
|
43
|
+
return undefined;
|
|
44
|
+
if (typeof value !== 'string' || value.length > maximum || /[\r\n]/.test(value) || value.includes('\u0000')) {
|
|
45
|
+
throw new sdk_1.WERR_INVALID_PARAMETER(name, `a string no longer than ${maximum} characters without control lines`);
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
function normalizeBulkHeaderFileInfo(value, allowStoredBoolean = false) {
|
|
50
|
+
const chain = ownDataValue(value, 'chain');
|
|
51
|
+
const count = ownDataValue(value, 'count');
|
|
52
|
+
const firstHeight = ownDataValue(value, 'firstHeight');
|
|
53
|
+
const fileName = ownDataValue(value, 'fileName');
|
|
54
|
+
const fileHash = ownDataValue(value, 'fileHash');
|
|
55
|
+
const prevHash = ownDataValue(value, 'prevHash');
|
|
56
|
+
const lastHash = ownDataValue(value, 'lastHash');
|
|
57
|
+
const prevChainWork = ownDataValue(value, 'prevChainWork');
|
|
58
|
+
const lastChainWork = ownDataValue(value, 'lastChainWork');
|
|
59
|
+
if (!SUPPORTED_CHAINS.has(chain)) {
|
|
60
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('bulk file chain', 'a supported Chaintracks network');
|
|
61
|
+
}
|
|
62
|
+
if (!Number.isSafeInteger(count) || count < 1 || count > MAX_BULK_FILE_HEADERS) {
|
|
63
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('bulk file count', `an integer from 1 through ${MAX_BULK_FILE_HEADERS}`);
|
|
64
|
+
}
|
|
65
|
+
if (!Number.isSafeInteger(firstHeight) ||
|
|
66
|
+
firstHeight < 0 ||
|
|
67
|
+
firstHeight > 0x7fffffff ||
|
|
68
|
+
firstHeight + count - 1 > 0x7fffffff) {
|
|
69
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('bulk file firstHeight', 'a supported non-negative block-header range');
|
|
70
|
+
}
|
|
71
|
+
if (typeof fileName !== 'string' ||
|
|
72
|
+
fileName.length === 0 ||
|
|
73
|
+
fileName.length > MAX_BULK_FILE_NAME_BYTES ||
|
|
74
|
+
!SAFE_BULK_FILE_NAME.test(fileName) ||
|
|
75
|
+
fileName === '.' ||
|
|
76
|
+
fileName === '..') {
|
|
77
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('bulk file fileName', 'a safe path-free ASCII file name');
|
|
78
|
+
}
|
|
79
|
+
let canonicalFileHash = false;
|
|
80
|
+
if (typeof fileHash === 'string' && SHA256_BASE64.test(fileHash)) {
|
|
81
|
+
try {
|
|
82
|
+
const digest = (0, utilityHelpers_noBuffer_1.asUint8Array)(fileHash, 'base64');
|
|
83
|
+
canonicalFileHash = digest.length === 32 && (0, utilityHelpers_noBuffer_1.asString)(digest, 'base64') === fileHash;
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
canonicalFileHash = false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (!canonicalFileHash) {
|
|
90
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('bulk file fileHash', 'a canonical base64 SHA-256 digest');
|
|
91
|
+
}
|
|
92
|
+
for (const [name, candidate] of [
|
|
93
|
+
['prevHash', prevHash],
|
|
94
|
+
['lastHash', lastHash],
|
|
95
|
+
['prevChainWork', prevChainWork],
|
|
96
|
+
['lastChainWork', lastChainWork]
|
|
97
|
+
]) {
|
|
98
|
+
if (typeof candidate !== 'string' || !HEX_32_BYTES.test(candidate)) {
|
|
99
|
+
throw new sdk_1.WERR_INVALID_PARAMETER(`bulk file ${name}`, 'exactly 32 lowercase hexadecimal bytes');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const storedSourceUrl = ownDataValue(value, 'sourceUrl', false);
|
|
103
|
+
const sourceUrl = optionalString(allowStoredBoolean && storedSourceUrl === null ? undefined : storedSourceUrl, 'bulk file sourceUrl', 2048);
|
|
104
|
+
const fileIdValue = ownDataValue(value, 'fileId', false);
|
|
105
|
+
if (fileIdValue !== undefined && (!Number.isSafeInteger(fileIdValue) || fileIdValue < 1)) {
|
|
106
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('bulk file fileId', 'a positive safe integer');
|
|
107
|
+
}
|
|
108
|
+
const validatedValue = ownDataValue(value, 'validated', false);
|
|
109
|
+
if (validatedValue !== undefined &&
|
|
110
|
+
typeof validatedValue !== 'boolean' &&
|
|
111
|
+
!(allowStoredBoolean && (validatedValue === 0 || validatedValue === 1))) {
|
|
112
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('bulk file validated', 'a boolean when defined');
|
|
113
|
+
}
|
|
114
|
+
const dataValue = ownDataValue(value, 'data', false);
|
|
115
|
+
if (dataValue !== undefined && !(dataValue instanceof Uint8Array)) {
|
|
116
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('bulk file data', 'a Uint8Array when defined');
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
chain: chain,
|
|
120
|
+
count: count,
|
|
121
|
+
firstHeight: firstHeight,
|
|
122
|
+
fileName: fileName,
|
|
123
|
+
fileHash: fileHash,
|
|
124
|
+
prevHash: prevHash,
|
|
125
|
+
lastHash: lastHash,
|
|
126
|
+
prevChainWork: prevChainWork,
|
|
127
|
+
lastChainWork: lastChainWork,
|
|
128
|
+
sourceUrl,
|
|
129
|
+
fileId: fileIdValue,
|
|
130
|
+
validated: validatedValue === undefined ? undefined : validatedValue === true || validatedValue === 1,
|
|
131
|
+
data: dataValue === undefined ? undefined : new Uint8Array(dataValue)
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function normalizeBulkHeaderFilesInfo(value) {
|
|
135
|
+
const filesValue = ownDataValue(value, 'files');
|
|
136
|
+
const headersPerFile = ownDataValue(value, 'headersPerFile');
|
|
137
|
+
if (!Array.isArray(filesValue) || filesValue.length > MAX_BULK_MANIFEST_FILES) {
|
|
138
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('bulk manifest files', `a dense array of no more than ${MAX_BULK_MANIFEST_FILES} entries`);
|
|
139
|
+
}
|
|
140
|
+
if (!Number.isSafeInteger(headersPerFile) ||
|
|
141
|
+
headersPerFile < 1 ||
|
|
142
|
+
headersPerFile > MAX_BULK_FILE_HEADERS) {
|
|
143
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('bulk manifest headersPerFile', `an integer from 1 through ${MAX_BULK_FILE_HEADERS}`);
|
|
144
|
+
}
|
|
145
|
+
const files = [];
|
|
146
|
+
for (let index = 0; index < filesValue.length; index++) {
|
|
147
|
+
const descriptor = Object.getOwnPropertyDescriptor(filesValue, String(index));
|
|
148
|
+
if (descriptor == null || !('value' in descriptor)) {
|
|
149
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('bulk manifest files', 'a dense array of plain data entries');
|
|
150
|
+
}
|
|
151
|
+
files.push(normalizeBulkHeaderFileInfo(descriptor.value));
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
rootFolder: optionalString(ownDataValue(value, 'rootFolder', false), 'bulk manifest rootFolder', 2048) ?? '',
|
|
155
|
+
jsonFilename: optionalString(ownDataValue(value, 'jsonFilename', false), 'bulk manifest jsonFilename', 255) ?? '',
|
|
156
|
+
headersPerFile: headersPerFile,
|
|
157
|
+
files
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function normalizeBulkHeaderFileSequence(files, allowStoredBoolean = false) {
|
|
161
|
+
if (!Array.isArray(files) || files.length > MAX_BULK_MANIFEST_FILES) {
|
|
162
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('files', `a dense array of no more than ${MAX_BULK_MANIFEST_FILES} bulk files`);
|
|
163
|
+
}
|
|
164
|
+
const canonical = [];
|
|
165
|
+
const hashes = new Set();
|
|
166
|
+
const ids = new Set();
|
|
167
|
+
for (let index = 0; index < files.length; index++) {
|
|
168
|
+
const descriptor = Object.getOwnPropertyDescriptor(files, String(index));
|
|
169
|
+
if (descriptor == null || !('value' in descriptor)) {
|
|
170
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('files', 'a dense array of plain data entries');
|
|
171
|
+
}
|
|
172
|
+
const file = normalizeBulkHeaderFileInfo(descriptor.value, allowStoredBoolean);
|
|
173
|
+
const fileHash = file.fileHash;
|
|
174
|
+
if (hashes.has(fileHash))
|
|
175
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('files', 'unique file hashes');
|
|
176
|
+
hashes.add(fileHash);
|
|
177
|
+
if (file.fileId !== undefined) {
|
|
178
|
+
if (ids.has(file.fileId))
|
|
179
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('files', 'unique file ids');
|
|
180
|
+
ids.add(file.fileId);
|
|
181
|
+
}
|
|
182
|
+
const previous = canonical.at(-1);
|
|
183
|
+
if (previous == null) {
|
|
184
|
+
if (file.firstHeight !== 0 || file.prevHash !== '00'.repeat(32) || file.prevChainWork !== '00'.repeat(32)) {
|
|
185
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('files', 'a genesis-anchored first bulk file');
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
else if (file.firstHeight !== previous.firstHeight + previous.count ||
|
|
189
|
+
file.prevHash !== previous.lastHash ||
|
|
190
|
+
file.prevChainWork !== previous.lastChainWork) {
|
|
191
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('files', 'one contiguous chain of bulk files');
|
|
192
|
+
}
|
|
193
|
+
if (previous != null && isBdfIncremental(previous)) {
|
|
194
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('files', 'an incremental bulk file only in the final position');
|
|
195
|
+
}
|
|
196
|
+
canonical.push(file);
|
|
197
|
+
}
|
|
198
|
+
return canonical;
|
|
199
|
+
}
|
|
16
200
|
/**
|
|
17
201
|
* Manages bulk file data (typically 8MB chunks of 100,000 headers each).
|
|
18
202
|
*
|
|
@@ -34,7 +218,7 @@ class BulkFileDataManager {
|
|
|
34
218
|
}
|
|
35
219
|
log = () => { };
|
|
36
220
|
bfds = [];
|
|
37
|
-
fileHashToIndex =
|
|
221
|
+
fileHashToIndex = Object.create(null);
|
|
38
222
|
lock = new SingleWriterMultiReaderLock_1.SingleWriterMultiReaderLock();
|
|
39
223
|
inFlightLoads = new Map();
|
|
40
224
|
failedLoads = new Map();
|
|
@@ -60,6 +244,8 @@ class BulkFileDataManager {
|
|
|
60
244
|
validator;
|
|
61
245
|
failedLoadRetryMsecs;
|
|
62
246
|
constructor(options) {
|
|
247
|
+
if (options == null)
|
|
248
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('options', 'a Chain or BulkFileDataManagerOptions object');
|
|
63
249
|
const resolvedOptions = typeof options === 'object' ? options : BulkFileDataManager.createDefaultOptions(options);
|
|
64
250
|
this.chain = resolvedOptions.chain;
|
|
65
251
|
this.maxPerFile = resolvedOptions.maxPerFile;
|
|
@@ -70,9 +256,35 @@ class BulkFileDataManager {
|
|
|
70
256
|
this.downloadBudget = resolvedOptions.downloadBudget;
|
|
71
257
|
this.validator = resolvedOptions.validator ?? new InlineBulkFileDataValidator_1.InlineBulkFileDataValidator();
|
|
72
258
|
this.failedLoadRetryMsecs = resolvedOptions.failedLoadRetryMsecs ?? 30 * 1000;
|
|
259
|
+
if (!SUPPORTED_CHAINS.has(this.chain)) {
|
|
260
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('chain', 'a supported Chaintracks network');
|
|
261
|
+
}
|
|
262
|
+
if (!Number.isSafeInteger(this.maxPerFile) || this.maxPerFile < 1 || this.maxPerFile > MAX_BULK_FILE_HEADERS) {
|
|
263
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('maxPerFile', `an integer from 1 through ${MAX_BULK_FILE_HEADERS}`);
|
|
264
|
+
}
|
|
265
|
+
if (this.maxRetained !== undefined &&
|
|
266
|
+
(!Number.isSafeInteger(this.maxRetained) || this.maxRetained < 0 || this.maxRetained > 1000)) {
|
|
267
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('maxRetained', 'an integer from 0 through 1000 when defined');
|
|
268
|
+
}
|
|
73
269
|
if (!Number.isSafeInteger(this.failedLoadRetryMsecs) || this.failedLoadRetryMsecs < 0) {
|
|
74
270
|
throw new sdk_1.WERR_INVALID_PARAMETER('failedLoadRetryMsecs', 'a non-negative safe integer');
|
|
75
271
|
}
|
|
272
|
+
if (this.fromKnownSourceUrl !== undefined &&
|
|
273
|
+
(typeof this.fromKnownSourceUrl !== 'string' ||
|
|
274
|
+
this.fromKnownSourceUrl.length > 2048 ||
|
|
275
|
+
/[\r\n]/.test(this.fromKnownSourceUrl) ||
|
|
276
|
+
this.fromKnownSourceUrl.includes('\u0000'))) {
|
|
277
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('fromKnownSourceUrl', 'a bounded string without control lines when defined');
|
|
278
|
+
}
|
|
279
|
+
if (typeof this.validator?.validate !== 'function') {
|
|
280
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('validator', 'an object with a validate function');
|
|
281
|
+
}
|
|
282
|
+
if (this.cache != null && (typeof this.cache.get !== 'function' || typeof this.cache.set !== 'function')) {
|
|
283
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('cache', 'an object with get and set functions when defined');
|
|
284
|
+
}
|
|
285
|
+
if (this.downloadBudget != null && typeof this.downloadBudget.consume !== 'function') {
|
|
286
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('downloadBudget', 'an object with a consume function when defined');
|
|
287
|
+
}
|
|
76
288
|
this.deleteBulkFilesNoLock();
|
|
77
289
|
}
|
|
78
290
|
getStats() {
|
|
@@ -86,8 +298,7 @@ class BulkFileDataManager {
|
|
|
86
298
|
return await this.lock.withWriteLock(async () => this.deleteBulkFilesNoLock());
|
|
87
299
|
}
|
|
88
300
|
deleteBulkFilesNoLock() {
|
|
89
|
-
this.
|
|
90
|
-
this.fileHashToIndex = {};
|
|
301
|
+
this.setBulkFilesState([]);
|
|
91
302
|
if (this.fromKnownSourceUrl) {
|
|
92
303
|
const vbhfs = validBulkHeaderFilesByFileHash_1.validBulkHeaderFiles;
|
|
93
304
|
const filtered = vbhfs.filter(f => f.sourceUrl === this.fromKnownSourceUrl);
|
|
@@ -108,33 +319,62 @@ class BulkFileDataManager {
|
|
|
108
319
|
return await this.lock.withWriteLock(async () => await this.setStorageNoLock(storage, log));
|
|
109
320
|
}
|
|
110
321
|
async setStorageNoLock(storage, log) {
|
|
111
|
-
|
|
112
|
-
|
|
322
|
+
if (storage == null ||
|
|
323
|
+
typeof storage !== 'object' ||
|
|
324
|
+
typeof storage.getBulkFiles !== 'function' ||
|
|
325
|
+
typeof storage.getBulkFileData !== 'function' ||
|
|
326
|
+
typeof storage.insertBulkFile !== 'function' ||
|
|
327
|
+
typeof storage.updateBulkFile !== 'function' ||
|
|
328
|
+
typeof storage.deleteBulkFile !== 'function') {
|
|
329
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('storage', 'a complete ChaintracksStorageBulkFileApi implementation');
|
|
330
|
+
}
|
|
331
|
+
if (typeof log !== 'function')
|
|
332
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('log', 'a function');
|
|
113
333
|
// Get files currently in persistent storage.
|
|
114
|
-
const sfs = await
|
|
334
|
+
const sfs = await storage.getBulkFiles();
|
|
115
335
|
// Sync bfds with storage. Two scenarios supported:
|
|
116
336
|
const bfdsRanges = this.heightRangesFromBulkFiles(this.bfds);
|
|
117
337
|
const sfsRanges = this.heightRangesFromBulkFiles(sfs);
|
|
118
338
|
if (sfsRanges.cdn.length >= bfdsRanges.cdn.length) {
|
|
119
339
|
// Storage win if it has greater or equal CDN coverage
|
|
120
|
-
//
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
340
|
+
// Validate the entire durable sequence before making it authoritative.
|
|
341
|
+
const priorStorage = this.storage;
|
|
342
|
+
const priorLog = this.log;
|
|
343
|
+
const priorFiles = this.bfds;
|
|
344
|
+
this.storage = storage;
|
|
345
|
+
this.log = log;
|
|
346
|
+
this.setBulkFilesState([]);
|
|
347
|
+
try {
|
|
348
|
+
for (const file of sfs) {
|
|
349
|
+
const vbf = await this.validateFileInfo(file);
|
|
350
|
+
this.validateBfdForAdd(vbf);
|
|
351
|
+
this.bfds.push(vbf);
|
|
352
|
+
this.fileHashToIndex[vbf.fileHash] = this.bfds.length - 1;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
catch (error) {
|
|
356
|
+
this.storage = priorStorage;
|
|
357
|
+
this.log = priorLog;
|
|
358
|
+
this.setBulkFilesState(priorFiles);
|
|
359
|
+
throw error;
|
|
125
360
|
}
|
|
126
361
|
}
|
|
127
362
|
else {
|
|
128
363
|
// Bfds win if they have greater CDN coverage
|
|
129
|
-
// Replace
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
364
|
+
// Replace durable state as one transaction. Sequential deletion and
|
|
365
|
+
// insertion can expose a valid-looking but incomplete header chain.
|
|
366
|
+
if (typeof storage.replaceBulkFiles !== 'function') {
|
|
367
|
+
throw new sdk_1.WERR_INVALID_OPERATION('storage must implement atomic replaceBulkFiles before replacing an existing bulk-header set');
|
|
368
|
+
}
|
|
369
|
+
const desired = [];
|
|
134
370
|
for (const bfd of this.bfds) {
|
|
135
|
-
await this.ensureData(bfd);
|
|
136
|
-
|
|
371
|
+
const data = await this.ensureData(bfd);
|
|
372
|
+
desired.push({ ...bfdToInfo(bfd, true), data: new Uint8Array(data) });
|
|
137
373
|
}
|
|
374
|
+
const committed = await storage.replaceBulkFiles(desired);
|
|
375
|
+
this.applyCommittedBulkFiles(committed);
|
|
376
|
+
this.storage = storage;
|
|
377
|
+
this.log = log;
|
|
138
378
|
}
|
|
139
379
|
}
|
|
140
380
|
heightRangesFromBulkFiles(files) {
|
|
@@ -150,8 +390,8 @@ class BulkFileDataManager {
|
|
|
150
390
|
return ranges;
|
|
151
391
|
}
|
|
152
392
|
async createReader(range, maxBufferSize) {
|
|
153
|
-
range
|
|
154
|
-
maxBufferSize
|
|
393
|
+
range ??= await this.getHeightRange();
|
|
394
|
+
maxBufferSize ??= MAX_BULK_FILE_HEADERS * 80;
|
|
155
395
|
return new BulkFileDataReader_1.BulkFileDataReader(this, range, maxBufferSize);
|
|
156
396
|
}
|
|
157
397
|
async updateFromUrl(cdnUrl) {
|
|
@@ -159,10 +399,11 @@ class BulkFileDataManager {
|
|
|
159
399
|
throw new sdk_1.WERR_INVALID_OPERATION('fetch is not defined in the BulkFileDataManager.');
|
|
160
400
|
const toUrl = (file) => this.fetch.pathJoin(cdnUrl, file);
|
|
161
401
|
const url = toUrl(`${this.chain}NetBlockHeaders.json`);
|
|
162
|
-
const
|
|
163
|
-
if (!
|
|
402
|
+
const response = await this.fetch.fetchJson(url);
|
|
403
|
+
if (!response) {
|
|
164
404
|
throw new sdk_1.WERR_INVALID_PARAMETER('cdnUrl', `a valid BulkHeaderFilesInfo JSON resource available from ${url}`);
|
|
165
405
|
}
|
|
406
|
+
const availableBulkFiles = normalizeBulkHeaderFilesInfo(response);
|
|
166
407
|
const selectedFiles = selectBulkHeaderFiles(availableBulkFiles.files, this.chain, this.maxPerFile || availableBulkFiles.headersPerFile);
|
|
167
408
|
for (const bf of selectedFiles) {
|
|
168
409
|
if (!bf.fileHash) {
|
|
@@ -171,6 +412,8 @@ class BulkFileDataManager {
|
|
|
171
412
|
if (!bf.chain || bf.chain !== this.chain) {
|
|
172
413
|
throw new sdk_1.WERR_INVALID_PARAMETER('chain', `"${this.chain}" for all files in json downloaded from ${url}`);
|
|
173
414
|
}
|
|
415
|
+
// A remote manifest never has authority over local storage identities.
|
|
416
|
+
bf.fileId = undefined;
|
|
174
417
|
if (!bf.sourceUrl || bf.sourceUrl !== cdnUrl)
|
|
175
418
|
bf.sourceUrl = cdnUrl;
|
|
176
419
|
}
|
|
@@ -187,11 +430,20 @@ class BulkFileDataManager {
|
|
|
187
430
|
return await this.lock.withWriteLock(async () => await this.mergeNoLock(files));
|
|
188
431
|
}
|
|
189
432
|
async mergeNoLock(files) {
|
|
433
|
+
if (!Array.isArray(files) || files.length > MAX_BULK_MANIFEST_FILES) {
|
|
434
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('files', `an array of no more than ${MAX_BULK_MANIFEST_FILES} entries`);
|
|
435
|
+
}
|
|
190
436
|
const r = { inserted: [], updated: [], unchanged: [], dropped: [] };
|
|
191
|
-
for (
|
|
437
|
+
for (let index = 0; index < files.length; index++) {
|
|
438
|
+
const descriptor = Object.getOwnPropertyDescriptor(files, String(index));
|
|
439
|
+
if (descriptor == null || !('value' in descriptor)) {
|
|
440
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('files', 'a dense array of plain data entries');
|
|
441
|
+
}
|
|
442
|
+
const file = normalizeBulkHeaderFileInfo(descriptor.value);
|
|
192
443
|
const hbf = this.getBfdForHeight(file.firstHeight);
|
|
193
|
-
if (
|
|
194
|
-
|
|
444
|
+
if (this.storage != null && hbf == null && file.fileId !== undefined) {
|
|
445
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('file.fileId', 'undefined for a new bulk file');
|
|
446
|
+
}
|
|
195
447
|
const lbf = this.getLastBfd();
|
|
196
448
|
if (hbf?.fileHash === file.fileHash &&
|
|
197
449
|
hbf.count === file.count &&
|
|
@@ -224,23 +476,32 @@ class BulkFileDataManager {
|
|
|
224
476
|
return r;
|
|
225
477
|
}
|
|
226
478
|
async mergeIncremental(lbf, vbf, r) {
|
|
227
|
-
lbf.count
|
|
228
|
-
|
|
229
|
-
|
|
479
|
+
if (lbf.count + vbf.count > MAX_BULK_FILE_HEADERS) {
|
|
480
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('incremental headers', `no more than ${MAX_BULK_FILE_HEADERS} per file`);
|
|
481
|
+
}
|
|
230
482
|
await this.ensureData(lbf);
|
|
231
483
|
const newData = new Uint8Array(lbf.data.length + vbf.data.length);
|
|
232
484
|
newData.set(lbf.data);
|
|
233
485
|
newData.set(vbf.data, lbf.data.length);
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
486
|
+
const merged = {
|
|
487
|
+
...lbf,
|
|
488
|
+
count: lbf.count + vbf.count,
|
|
489
|
+
lastHash: vbf.lastHash,
|
|
490
|
+
lastChainWork: vbf.lastChainWork,
|
|
491
|
+
data: newData,
|
|
492
|
+
fileHash: (0, utilityHelpers_noBuffer_1.asString)((0, Hash_1.sha256)((0, utilityHelpers_noBuffer_1.asArray)(newData)), 'base64'),
|
|
493
|
+
mru: Date.now()
|
|
494
|
+
};
|
|
495
|
+
const lbfInfo = bfdToInfo(merged, true);
|
|
496
|
+
if (this.storage != null) {
|
|
497
|
+
if (!merged.fileId)
|
|
498
|
+
throw new sdk_1.WERR_INVALID_OPERATION('stored incremental bulk file is missing its fileId');
|
|
499
|
+
const affected = await this.storage.updateBulkFile(merged.fileId, lbfInfo);
|
|
500
|
+
if (affected !== 1)
|
|
501
|
+
throw new sdk_1.WERR_INVALID_OPERATION(`failed to update bulk file ${merged.fileId}`);
|
|
243
502
|
}
|
|
503
|
+
this.replaceBfdAtIndex(this.bfds.length - 1, merged);
|
|
504
|
+
r.updated.push(lbfInfo);
|
|
244
505
|
}
|
|
245
506
|
toLogString(what) {
|
|
246
507
|
let log = '';
|
|
@@ -272,8 +533,51 @@ class BulkFileDataManager {
|
|
|
272
533
|
return log;
|
|
273
534
|
}
|
|
274
535
|
async mergeIncrementalBlockHeaders(newBulkHeaders, incrementalChainWork) {
|
|
536
|
+
if (!Array.isArray(newBulkHeaders) || newBulkHeaders.length > MAX_BULK_FILE_HEADERS) {
|
|
537
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('newBulkHeaders', `a dense array of no more than ${MAX_BULK_FILE_HEADERS} headers`);
|
|
538
|
+
}
|
|
539
|
+
const authenticatedHeaders = [];
|
|
540
|
+
for (let index = 0; index < newBulkHeaders.length; index++) {
|
|
541
|
+
if (!Object.hasOwn(newBulkHeaders, index)) {
|
|
542
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('newBulkHeaders', 'a dense array');
|
|
543
|
+
}
|
|
544
|
+
const source = newBulkHeaders[index];
|
|
545
|
+
if (source == null || typeof source !== 'object' || Array.isArray(source)) {
|
|
546
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('newBulkHeaders', 'plain header data objects');
|
|
547
|
+
}
|
|
548
|
+
const prototype = Object.getPrototypeOf(source);
|
|
549
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
550
|
+
if ((prototype !== Object.prototype && prototype !== null) ||
|
|
551
|
+
Object.values(descriptors).some(descriptor => descriptor.get != null || descriptor.set != null)) {
|
|
552
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('newBulkHeaders', 'accessor-free plain header data objects');
|
|
553
|
+
}
|
|
554
|
+
const value = (name) => {
|
|
555
|
+
const descriptor = descriptors[name];
|
|
556
|
+
if (descriptor == null || !('value' in descriptor)) {
|
|
557
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('newBulkHeaders', `headers with an own ${name} data property`);
|
|
558
|
+
}
|
|
559
|
+
return descriptor.value;
|
|
560
|
+
};
|
|
561
|
+
const candidate = {
|
|
562
|
+
version: value('version'),
|
|
563
|
+
previousHash: value('previousHash'),
|
|
564
|
+
merkleRoot: value('merkleRoot'),
|
|
565
|
+
time: value('time'),
|
|
566
|
+
bits: value('bits'),
|
|
567
|
+
nonce: value('nonce'),
|
|
568
|
+
height: value('height'),
|
|
569
|
+
hash: value('hash')
|
|
570
|
+
};
|
|
571
|
+
(0, blockHeaderUtilities_1.validateHeaderFormat)(candidate);
|
|
572
|
+
(0, blockHeaderUtilities_1.validateHeaderProofOfWork)(candidate);
|
|
573
|
+
authenticatedHeaders.push(candidate);
|
|
574
|
+
}
|
|
575
|
+
newBulkHeaders = authenticatedHeaders;
|
|
275
576
|
if (newBulkHeaders.length === 0)
|
|
276
577
|
return;
|
|
578
|
+
if (incrementalChainWork !== undefined && !HEX_32_BYTES.test(incrementalChainWork)) {
|
|
579
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('incrementalChainWork', 'exactly 32 lowercase hexadecimal bytes');
|
|
580
|
+
}
|
|
277
581
|
return await this.lock.withWriteLock(async () => {
|
|
278
582
|
const lbf = this.getLastFileNoLock();
|
|
279
583
|
const nextHeight = lbf != null ? lbf.firstHeight + lbf.count : 0;
|
|
@@ -292,7 +596,7 @@ class BulkFileDataManager {
|
|
|
292
596
|
? (0, blockHeaderUtilities_1.addWork)(incrementalChainWork, prevChainWork)
|
|
293
597
|
: computeChainWorkFromHeaders(newBulkHeaders, lbf);
|
|
294
598
|
const data = (0, blockHeaderUtilities_1.serializeBaseBlockHeaders)(newBulkHeaders);
|
|
295
|
-
const fileHash = (0, utilityHelpers_noBuffer_1.asString)(
|
|
599
|
+
const fileHash = (0, utilityHelpers_noBuffer_1.asString)((0, Hash_1.sha256)((0, utilityHelpers_noBuffer_1.asArray)(data)), 'base64');
|
|
296
600
|
const bf = {
|
|
297
601
|
fileId: undefined,
|
|
298
602
|
chain: this.chain,
|
|
@@ -325,6 +629,17 @@ class BulkFileDataManager {
|
|
|
325
629
|
});
|
|
326
630
|
}
|
|
327
631
|
async getDataFromFile(file, offset, length) {
|
|
632
|
+
for (const [name, value] of [
|
|
633
|
+
['offset', offset],
|
|
634
|
+
['length', length]
|
|
635
|
+
]) {
|
|
636
|
+
if (value !== undefined && (!Number.isSafeInteger(value) || value < 0 || value > MAX_BULK_FILE_HEADERS * 80)) {
|
|
637
|
+
throw new sdk_1.WERR_INVALID_PARAMETER(name, `an integer from 0 through ${MAX_BULK_FILE_HEADERS * 80}`);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
if (offset !== undefined && length !== undefined && !Number.isSafeInteger(offset + length)) {
|
|
641
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('offset and length', 'values with a safe sum');
|
|
642
|
+
}
|
|
328
643
|
const resolved = await this.lock.withReadLock(async () => {
|
|
329
644
|
const resolved = this.getBfdForHeight(file.firstHeight);
|
|
330
645
|
if (resolved == null || resolved.count < file.count) {
|
|
@@ -358,11 +673,13 @@ class BulkFileDataManager {
|
|
|
358
673
|
}
|
|
359
674
|
async getDataFromFileNoLock(bfd, offset, length) {
|
|
360
675
|
const fileLength = bfd.count * 80;
|
|
361
|
-
offset
|
|
676
|
+
offset ??= 0;
|
|
362
677
|
if (offset > fileLength - 1)
|
|
363
678
|
return undefined;
|
|
364
|
-
length
|
|
679
|
+
length ??= bfd.count * 80 - offset;
|
|
365
680
|
length = Math.min(length, fileLength - offset);
|
|
681
|
+
if (length === 0)
|
|
682
|
+
return new Uint8Array();
|
|
366
683
|
// Never serve a partial storage read before validating the complete
|
|
367
684
|
// immutable object. Metadata and advisory validation state may have crossed
|
|
368
685
|
// a storage boundary, and neither can establish the digest, linkage, or
|
|
@@ -372,8 +689,8 @@ class BulkFileDataManager {
|
|
|
372
689
|
}
|
|
373
690
|
async findHeaderForHeightOrUndefined(height) {
|
|
374
691
|
const resolved = await this.lock.withReadLock(async () => {
|
|
375
|
-
if (!Number.
|
|
376
|
-
throw new sdk_1.WERR_INVALID_PARAMETER('height', `
|
|
692
|
+
if (!Number.isSafeInteger(height) || height < 0 || height > 0x7fffffff) {
|
|
693
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('height', `an integer from 0 through 2147483647 (${height}).`);
|
|
377
694
|
}
|
|
378
695
|
const file = this.bfds.find(f => f.firstHeight <= height && f.firstHeight + f.count > height);
|
|
379
696
|
if (file == null)
|
|
@@ -394,13 +711,16 @@ class BulkFileDataManager {
|
|
|
394
711
|
});
|
|
395
712
|
}
|
|
396
713
|
getBfdForHeight(height) {
|
|
397
|
-
if (!Number.
|
|
398
|
-
throw new sdk_1.WERR_INVALID_PARAMETER('height', `
|
|
714
|
+
if (!Number.isSafeInteger(height) || height < 0 || height > 0x7fffffff) {
|
|
715
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('height', `an integer from 0 through 2147483647 (${height}).`);
|
|
399
716
|
}
|
|
400
717
|
const file = this.bfds.find(f => f.firstHeight <= height && f.firstHeight + f.count > height);
|
|
401
718
|
return file;
|
|
402
719
|
}
|
|
403
720
|
getLastBfd(fromEnd = 1) {
|
|
721
|
+
if (!Number.isSafeInteger(fromEnd) || fromEnd < 1 || fromEnd > MAX_BULK_MANIFEST_FILES) {
|
|
722
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('fromEnd', `an integer from 1 through ${MAX_BULK_MANIFEST_FILES}`);
|
|
723
|
+
}
|
|
404
724
|
if (this.bfds.length < fromEnd)
|
|
405
725
|
return undefined;
|
|
406
726
|
const bfd = this.bfds[this.bfds.length - fromEnd];
|
|
@@ -433,11 +753,9 @@ class BulkFileDataManager {
|
|
|
433
753
|
return data;
|
|
434
754
|
}
|
|
435
755
|
async validateFileInfo(file) {
|
|
756
|
+
file = normalizeBulkHeaderFileInfo(file, true);
|
|
436
757
|
if (file.chain !== this.chain)
|
|
437
758
|
throw new sdk_1.WERR_INVALID_PARAMETER('chain', `${this.chain}`);
|
|
438
|
-
if (file.count <= 0) {
|
|
439
|
-
throw new sdk_1.WERR_INVALID_PARAMETER('bf.count', `expected count to be greater than 0, but got ${file.count}`);
|
|
440
|
-
}
|
|
441
759
|
if (file.count > this.maxPerFile && file.fileName !== 'incremental') {
|
|
442
760
|
throw new sdk_1.WERR_INVALID_PARAMETER('count', `less than or equal to maxPerFile ${this.maxPerFile}`);
|
|
443
761
|
}
|
|
@@ -490,7 +808,7 @@ class BulkFileDataManager {
|
|
|
490
808
|
return result.data;
|
|
491
809
|
}
|
|
492
810
|
async ReValidate() {
|
|
493
|
-
return await this.lock.
|
|
811
|
+
return await this.lock.withWriteLock(async () => await this.ReValidateNoLock());
|
|
494
812
|
}
|
|
495
813
|
async ReValidateNoLock() {
|
|
496
814
|
for (const file of this.bfds) {
|
|
@@ -503,6 +821,9 @@ class BulkFileDataManager {
|
|
|
503
821
|
}
|
|
504
822
|
}
|
|
505
823
|
validateBfdForAdd(bfd) {
|
|
824
|
+
if (this.fileHashToIndex[bfd.fileHash] !== undefined) {
|
|
825
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('fileHash', 'unique within bulk storage');
|
|
826
|
+
}
|
|
506
827
|
if (this.bfds.length === 0 && bfd.firstHeight !== 0) {
|
|
507
828
|
throw new sdk_1.WERR_INVALID_PARAMETER('firstHeight', '0 for the first file');
|
|
508
829
|
}
|
|
@@ -518,14 +839,14 @@ class BulkFileDataManager {
|
|
|
518
839
|
}
|
|
519
840
|
async add(bfd) {
|
|
520
841
|
this.validateBfdForAdd(bfd);
|
|
521
|
-
const index = this.bfds.length;
|
|
522
|
-
this.bfds.push(bfd);
|
|
523
|
-
this.fileHashToIndex[bfd.fileHash] = index;
|
|
524
|
-
this.ensureMaxRetained();
|
|
525
842
|
const info = bfdToInfo(bfd, true);
|
|
526
843
|
if (this.storage != null) {
|
|
527
844
|
info.fileId = bfd.fileId = await this.storage.insertBulkFile(info);
|
|
528
845
|
}
|
|
846
|
+
const index = this.bfds.length;
|
|
847
|
+
this.bfds.push(bfd);
|
|
848
|
+
this.fileHashToIndex[bfd.fileHash] = index;
|
|
849
|
+
this.ensureMaxRetained();
|
|
529
850
|
return info;
|
|
530
851
|
}
|
|
531
852
|
replaceBfdAtIndex(index, update) {
|
|
@@ -534,6 +855,40 @@ class BulkFileDataManager {
|
|
|
534
855
|
this.bfds[index] = update;
|
|
535
856
|
this.fileHashToIndex[update.fileHash] = index;
|
|
536
857
|
}
|
|
858
|
+
setBulkFilesState(files) {
|
|
859
|
+
const index = Object.create(null);
|
|
860
|
+
for (let i = 0; i < files.length; i++) {
|
|
861
|
+
if (index[files[i].fileHash] !== undefined) {
|
|
862
|
+
throw new sdk_1.WERR_INVALID_OPERATION('bulk-file state contains a duplicate file hash');
|
|
863
|
+
}
|
|
864
|
+
index[files[i].fileHash] = i;
|
|
865
|
+
}
|
|
866
|
+
this.bfds = files;
|
|
867
|
+
this.fileHashToIndex = index;
|
|
868
|
+
}
|
|
869
|
+
applyCommittedBulkFiles(files) {
|
|
870
|
+
if (!Array.isArray(files) || files.length !== this.bfds.length) {
|
|
871
|
+
throw new sdk_1.WERR_INVALID_OPERATION('storage returned an incomplete atomic bulk-file replacement');
|
|
872
|
+
}
|
|
873
|
+
const ids = new Set();
|
|
874
|
+
for (let index = 0; index < files.length; index++) {
|
|
875
|
+
if (!Object.hasOwn(files, index)) {
|
|
876
|
+
throw new sdk_1.WERR_INVALID_OPERATION('storage returned a sparse atomic bulk-file replacement');
|
|
877
|
+
}
|
|
878
|
+
const committed = normalizeBulkHeaderFileInfo(files[index], true);
|
|
879
|
+
const expected = this.bfds[index];
|
|
880
|
+
if (committed.fileId === undefined ||
|
|
881
|
+
ids.has(committed.fileId) ||
|
|
882
|
+
committed.chain !== expected.chain ||
|
|
883
|
+
committed.firstHeight !== expected.firstHeight ||
|
|
884
|
+
committed.count !== expected.count ||
|
|
885
|
+
committed.fileHash !== expected.fileHash) {
|
|
886
|
+
throw new sdk_1.WERR_INVALID_OPERATION('storage returned a mismatched atomic bulk-file replacement');
|
|
887
|
+
}
|
|
888
|
+
ids.add(committed.fileId);
|
|
889
|
+
expected.fileId = committed.fileId;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
537
892
|
/**
|
|
538
893
|
* Updating an existing file occurs in two specific contexts:
|
|
539
894
|
*
|
|
@@ -569,15 +924,31 @@ class BulkFileDataManager {
|
|
|
569
924
|
if (isBdfCdn(update) === isBdfCdn(hbf) && update.count <= hbf.count) {
|
|
570
925
|
throw new sdk_1.WERR_INVALID_PARAMETER('file.count', `greater than the current count ${hbf.count}`);
|
|
571
926
|
}
|
|
927
|
+
if (update.fileId !== undefined && hbf.fileId !== undefined && update.fileId !== hbf.fileId) {
|
|
928
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('file.fileId', 'undefined or equal to the existing bulk file id');
|
|
929
|
+
}
|
|
930
|
+
if (update.fileId === undefined)
|
|
931
|
+
update.fileId = hbf.fileId;
|
|
932
|
+
const stateBefore = this.bfds.map(snapshotBfd);
|
|
572
933
|
const { index, truncate, replaced, drop } = await this.resolveUpdatePlan(update, hbf);
|
|
573
|
-
|
|
574
|
-
if (
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
934
|
+
const requiresAtomicReplacement = truncate != null || drop != null;
|
|
935
|
+
if (this.storage != null && requiresAtomicReplacement && typeof this.storage.replaceBulkFiles !== 'function') {
|
|
936
|
+
throw new sdk_1.WERR_INVALID_OPERATION('storage must implement atomic replaceBulkFiles for a multi-file bulk update');
|
|
937
|
+
}
|
|
938
|
+
try {
|
|
939
|
+
this.replaceBfdAtIndex(index, update);
|
|
940
|
+
if (truncate != null)
|
|
941
|
+
await this.shiftWork(update, truncate, replaced);
|
|
942
|
+
if (drop != null)
|
|
943
|
+
this.dropLastBulkFile(drop);
|
|
944
|
+
await this.persistUpdate(update, truncate, drop);
|
|
945
|
+
this.recordUpdateResults(r, update, truncate, replaced, drop);
|
|
946
|
+
this.ensureMaxRetained();
|
|
947
|
+
}
|
|
948
|
+
catch (error) {
|
|
949
|
+
this.setBulkFilesState(stateBefore);
|
|
950
|
+
throw error;
|
|
951
|
+
}
|
|
581
952
|
}
|
|
582
953
|
async resolveUpdatePlan(update, hbf) {
|
|
583
954
|
const lbf = this.getLastBfd();
|
|
@@ -629,23 +1000,19 @@ class BulkFileDataManager {
|
|
|
629
1000
|
replaced: penultimateFile
|
|
630
1001
|
};
|
|
631
1002
|
}
|
|
632
|
-
async persistUpdate(update, truncate,
|
|
1003
|
+
async persistUpdate(update, truncate, drop) {
|
|
633
1004
|
if (this.storage == null)
|
|
634
1005
|
return;
|
|
635
|
-
if (
|
|
636
|
-
await this.storage.
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
if (replaced != null) {
|
|
640
|
-
await this.storage.updateBulkFile(truncate.fileId, truncateInfo);
|
|
641
|
-
}
|
|
642
|
-
else {
|
|
643
|
-
truncateInfo.fileId = undefined;
|
|
644
|
-
truncate.fileId = await this.storage.insertBulkFile(truncateInfo);
|
|
645
|
-
}
|
|
1006
|
+
if (truncate != null || drop != null) {
|
|
1007
|
+
const committed = await this.storage.replaceBulkFiles(this.bfds.map(bfd => bfdToInfo(bfd, true)));
|
|
1008
|
+
this.applyCommittedBulkFiles(committed);
|
|
1009
|
+
return;
|
|
646
1010
|
}
|
|
647
|
-
if (
|
|
648
|
-
|
|
1011
|
+
if (!update.fileId)
|
|
1012
|
+
throw new sdk_1.WERR_INVALID_OPERATION('stored bulk-file update is missing its fileId');
|
|
1013
|
+
const affected = await this.storage.updateBulkFile(update.fileId, bfdToInfo(update, true));
|
|
1014
|
+
if (affected !== 1)
|
|
1015
|
+
throw new sdk_1.WERR_INVALID_OPERATION(`failed to update bulk file ${update.fileId}`);
|
|
649
1016
|
}
|
|
650
1017
|
recordUpdateResults(r, update, truncate, replaced, drop) {
|
|
651
1018
|
if (!r)
|
|
@@ -705,7 +1072,7 @@ class BulkFileDataManager {
|
|
|
705
1072
|
truncate.firstHeight += count;
|
|
706
1073
|
truncate.data = truncate.data?.slice(count * 80);
|
|
707
1074
|
delete this.fileHashToIndex[truncate.fileHash];
|
|
708
|
-
truncate.fileHash = (0, utilityHelpers_noBuffer_1.asString)(
|
|
1075
|
+
truncate.fileHash = (0, utilityHelpers_noBuffer_1.asString)((0, Hash_1.sha256)((0, utilityHelpers_noBuffer_1.asArray)(truncate.data)), 'base64');
|
|
709
1076
|
this.fileHashToIndex[truncate.fileHash] = updateIndex + 1;
|
|
710
1077
|
}
|
|
711
1078
|
/**
|
|
@@ -816,6 +1183,7 @@ class BulkFileDataManager {
|
|
|
816
1183
|
await this.downloadBudget?.consume(expectedBytes);
|
|
817
1184
|
const url = this.fetch.pathJoin(bfd.sourceUrl, bfd.fileName);
|
|
818
1185
|
const downloaded = await this.fetch.download(url, expectedBytes, {
|
|
1186
|
+
publicNetworkOnly: true,
|
|
819
1187
|
beforeRetry: async () => await this.downloadBudget?.consume(expectedBytes)
|
|
820
1188
|
});
|
|
821
1189
|
if (downloaded == null) {
|
|
@@ -850,6 +1218,19 @@ class BulkFileDataManager {
|
|
|
850
1218
|
}
|
|
851
1219
|
}
|
|
852
1220
|
async exportHeadersToFs(toFs, toHeadersPerFile, toFolder, sourceUrl, maxHeight) {
|
|
1221
|
+
if (!Number.isSafeInteger(toHeadersPerFile) || toHeadersPerFile < 1 || toHeadersPerFile > MAX_BULK_FILE_HEADERS) {
|
|
1222
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('toHeadersPerFile', `an integer from 1 through ${MAX_BULK_FILE_HEADERS}`);
|
|
1223
|
+
}
|
|
1224
|
+
if (maxHeight !== undefined && (!Number.isSafeInteger(maxHeight) || maxHeight < 0 || maxHeight > 0x7fffffff)) {
|
|
1225
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('maxHeight', 'an integer from 0 through 2147483647 when defined');
|
|
1226
|
+
}
|
|
1227
|
+
if (typeof toFolder !== 'string' || toFolder.trim() === '' || /[\r\n]/.test(toFolder)) {
|
|
1228
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('toFolder', 'a non-empty path without control lines');
|
|
1229
|
+
}
|
|
1230
|
+
if (sourceUrl !== undefined &&
|
|
1231
|
+
(typeof sourceUrl !== 'string' || sourceUrl.length > 2048 || /[\r\n]/.test(sourceUrl))) {
|
|
1232
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('sourceUrl', 'a bounded string without control lines when defined');
|
|
1233
|
+
}
|
|
853
1234
|
const chain = this.chain;
|
|
854
1235
|
const toFileName = (i) => `${chain}Net_${i}.headers`;
|
|
855
1236
|
const toPath = (i) => toFs.pathJoin(toFolder, toFileName(i));
|
|
@@ -861,7 +1242,7 @@ class BulkFileDataManager {
|
|
|
861
1242
|
files: []
|
|
862
1243
|
};
|
|
863
1244
|
let range = await this.getHeightRange();
|
|
864
|
-
if (maxHeight)
|
|
1245
|
+
if (maxHeight !== undefined)
|
|
865
1246
|
range = range.intersect(new HeightRange_1.HeightRange(0, maxHeight));
|
|
866
1247
|
const reader = await this.createReader(range, toHeadersPerFile * 80);
|
|
867
1248
|
let firstHeight = 0;
|
|
@@ -912,12 +1293,35 @@ function snapshotBfd(file) {
|
|
|
912
1293
|
return { ...file, data: file.data };
|
|
913
1294
|
}
|
|
914
1295
|
function selectBulkHeaderFiles(files, chain, maxPerFile) {
|
|
1296
|
+
if (!SUPPORTED_CHAINS.has(chain))
|
|
1297
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('chain', 'a supported Chaintracks network');
|
|
1298
|
+
if (!Number.isSafeInteger(maxPerFile) || maxPerFile < 1 || maxPerFile > MAX_BULK_FILE_HEADERS) {
|
|
1299
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('maxPerFile', `an integer from 1 through ${MAX_BULK_FILE_HEADERS}`);
|
|
1300
|
+
}
|
|
1301
|
+
if (!Array.isArray(files) || files.length > MAX_BULK_MANIFEST_FILES) {
|
|
1302
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('files', `a dense array of no more than ${MAX_BULK_MANIFEST_FILES} entries`);
|
|
1303
|
+
}
|
|
1304
|
+
const bestByHeight = new Map();
|
|
1305
|
+
for (let index = 0; index < files.length; index++) {
|
|
1306
|
+
const descriptor = Object.getOwnPropertyDescriptor(files, String(index));
|
|
1307
|
+
if (descriptor == null || !('value' in descriptor)) {
|
|
1308
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('files', 'a dense array of plain data entries');
|
|
1309
|
+
}
|
|
1310
|
+
const file = normalizeBulkHeaderFileInfo(descriptor.value);
|
|
1311
|
+
if (file.chain !== chain || file.count > maxPerFile)
|
|
1312
|
+
continue;
|
|
1313
|
+
const current = bestByHeight.get(file.firstHeight);
|
|
1314
|
+
if (current == null || current.count < file.count) {
|
|
1315
|
+
bestByHeight.set(file.firstHeight, file);
|
|
1316
|
+
}
|
|
1317
|
+
else if (current.count === file.count && current.fileHash !== file.fileHash) {
|
|
1318
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('files', 'unambiguous for each chain, first height, and count');
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
915
1321
|
const r = [];
|
|
916
1322
|
let height = 0;
|
|
917
|
-
|
|
918
|
-
const
|
|
919
|
-
// Pick the file with the maximum count
|
|
920
|
-
const choice = choices.reduce((a, b) => (a.count > b.count ? a : b), choices[0]);
|
|
1323
|
+
while (r.length <= bestByHeight.size) {
|
|
1324
|
+
const choice = bestByHeight.get(height);
|
|
921
1325
|
if (!choice)
|
|
922
1326
|
break; // no more files to select
|
|
923
1327
|
r.push(choice);
|
|
@@ -945,7 +1349,7 @@ function bfdToInfo(bfd, keepData) {
|
|
|
945
1349
|
prevHash: bfd.prevHash,
|
|
946
1350
|
lastHash: bfd.lastHash,
|
|
947
1351
|
validated: bfd.validated || false,
|
|
948
|
-
data: keepData ? bfd.data : undefined
|
|
1352
|
+
data: keepData && bfd.data != null ? Uint8Array.from(bfd.data) : undefined
|
|
949
1353
|
};
|
|
950
1354
|
}
|
|
951
1355
|
/**
|