@bopen-io/wallet-toolbox 2.6.2-brc153.5 → 2.14.6
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 +744 -1
- package/LICENSES/Open-BSV-License-4-wallet-pre-2026.txt +28 -0
- package/README.md +823 -14
- package/THIRD_PARTY_NOTICES.md +35 -0
- package/docs/README.md +44 -31
- package/docs/action-batch-planning.md +80 -37
- package/docs/client.md +12996 -4571
- package/docs/identity-verification.md +218 -0
- package/docs/local-first-chaintracks.md +129 -0
- package/docs/managed-change-liquidity.md +258 -0
- package/docs/managed-change-policy.md +14 -1
- package/docs/monitor.md +505 -190
- package/docs/no-send-expiry.md +167 -0
- package/docs/prepared-beef.md +197 -0
- package/docs/services.md +4013 -1153
- package/docs/setup.md +107 -56
- package/docs/storage.md +5781 -1599
- package/docs/sync-transfer.md +144 -0
- package/docs/wab-shamir.md +5 -1
- package/docs/wallet.md +10188 -10904
- package/out/src/CWIStyleWalletManager.d.ts +39 -31
- package/out/src/CWIStyleWalletManager.d.ts.map +1 -1
- package/out/src/CWIStyleWalletManager.js +309 -258
- package/out/src/CWIStyleWalletManager.js.map +1 -1
- package/out/src/Setup.d.ts +14 -0
- package/out/src/Setup.d.ts.map +1 -1
- package/out/src/Setup.js +6 -2
- package/out/src/Setup.js.map +1 -1
- package/out/src/SetupClient.d.ts +3 -0
- package/out/src/SetupClient.d.ts.map +1 -1
- package/out/src/SetupClient.js +1 -0
- package/out/src/SetupClient.js.map +1 -1
- package/out/src/SetupWallet.d.ts +3 -0
- package/out/src/SetupWallet.d.ts.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 +54 -14
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +216 -114
- package/out/src/Wallet.js.map +1 -1
- package/out/src/WalletAuthenticationManager.d.ts +32 -0
- package/out/src/WalletAuthenticationManager.d.ts.map +1 -1
- package/out/src/WalletAuthenticationManager.js +531 -78
- 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 +101 -43
- package/out/src/WalletPermissionsManager.d.ts.map +1 -1
- package/out/src/WalletPermissionsManager.js +897 -414
- 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 +143 -8
- 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/index.client.d.ts +6 -0
- package/out/src/index.client.d.ts.map +1 -1
- package/out/src/index.client.js +16 -1
- package/out/src/index.client.js.map +1 -1
- package/out/src/index.mobile.d.ts +7 -0
- package/out/src/index.mobile.d.ts.map +1 -1
- package/out/src/index.mobile.js +17 -1
- package/out/src/index.mobile.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 +2 -0
- package/out/src/mockchain/MockServices.d.ts.map +1 -1
- package/out/src/mockchain/MockServices.js +54 -14
- package/out/src/mockchain/MockServices.js.map +1 -1
- package/out/src/monitor/Monitor.d.ts +51 -0
- package/out/src/monitor/Monitor.d.ts.map +1 -1
- package/out/src/monitor/Monitor.js +282 -41
- 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 +6 -1
- package/out/src/monitor/tasks/TaskArcSSE.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskArcSSE.js +117 -74
- 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/TaskNoSendExpiry.d.ts +19 -0
- package/out/src/monitor/tasks/TaskNoSendExpiry.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskNoSendExpiry.js +47 -0
- package/out/src/monitor/tasks/TaskNoSendExpiry.js.map +1 -0
- package/out/src/monitor/tasks/TaskReconcilePendingTransactions.d.ts +27 -0
- package/out/src/monitor/tasks/TaskReconcilePendingTransactions.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskReconcilePendingTransactions.js +242 -0
- package/out/src/monitor/tasks/TaskReconcilePendingTransactions.js.map +1 -0
- 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 +31 -9
- 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 +33 -6
- package/out/src/monitor/tasks/TaskReviewUtxos.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewUtxos.js +189 -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/monitor/tasks/index.all.d.ts +2 -0
- package/out/src/monitor/tasks/index.all.d.ts.map +1 -1
- package/out/src/monitor/tasks/index.all.js +2 -0
- package/out/src/monitor/tasks/index.all.js.map +1 -1
- package/out/src/sdk/ActionBatch.interfaces.d.ts +23 -0
- package/out/src/sdk/ActionBatch.interfaces.d.ts.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/WERR_errors.d.ts +23 -0
- package/out/src/sdk/WERR_errors.d.ts.map +1 -1
- package/out/src/sdk/WERR_errors.js +51 -7
- package/out/src/sdk/WERR_errors.js.map +1 -1
- package/out/src/sdk/WalletError.d.ts.map +1 -1
- package/out/src/sdk/WalletError.js +7 -21
- 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 +121 -3
- package/out/src/sdk/WalletErrorFromJson.js.map +1 -1
- package/out/src/sdk/WalletServices.interfaces.d.ts +45 -2
- package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
- package/out/src/sdk/WalletStorage.interfaces.d.ts +87 -4
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/out/src/sdk/types.d.ts +3 -2
- package/out/src/sdk/types.d.ts.map +1 -1
- package/out/src/sdk/types.js +3 -2
- package/out/src/sdk/types.js.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 +346 -120
- 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 +269 -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 +122 -0
- package/out/src/services/chaintracker/LocalChainTracker.d.ts.map +1 -0
- package/out/src/services/chaintracker/LocalChainTracker.js +465 -0
- package/out/src/services/chaintracker/LocalChainTracker.js.map +1 -0
- 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/BulkFileDataCacheApi.d.ts +48 -0
- package/out/src/services/chaintracker/chaintracks/Api/BulkFileDataCacheApi.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/BulkFileDataCacheApi.js +3 -0
- package/out/src/services/chaintracker/chaintracks/Api/BulkFileDataCacheApi.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/BulkFileDataValidatorApi.d.ts +70 -0
- package/out/src/services/chaintracker/chaintracks/Api/BulkFileDataValidatorApi.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/Api/BulkFileDataValidatorApi.js +21 -0
- package/out/src/services/chaintracker/chaintracks/Api/BulkFileDataValidatorApi.js.map +1 -0
- 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 +53 -0
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Api/ChaintracksFetchApi.d.ts +9 -2
- 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 +28 -3
- package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Chaintracks.js +282 -64
- 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 +348 -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 +378 -44
- 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 +230 -28
- 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 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.js +240 -87
- 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.d.ts +8 -0
- package/out/src/services/chaintracker/chaintracks/configureChaintracksIngestors.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/configureChaintracksIngestors.js +6 -3
- 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/index.all.d.ts +3 -0
- package/out/src/services/chaintracker/chaintracks/index.all.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/index.all.js +3 -0
- package/out/src/services/chaintracker/chaintracks/index.all.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/index.mobile.d.ts +5 -0
- package/out/src/services/chaintracker/chaintracks/index.mobile.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/index.mobile.js +5 -0
- package/out/src/services/chaintracker/chaintracks/index.mobile.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataCacheFs.d.ts +51 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataCacheFs.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataCacheFs.js +394 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataCacheFs.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts +45 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js +733 -166
- 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 +32 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataValidator.worker.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataValidator.worker.js +40 -0
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataValidator.worker.js.map +1 -0
- 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 +3 -1
- 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 +38 -4
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js +191 -47
- 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 +48 -0
- package/out/src/services/chaintracker/chaintracks/util/DurableFileBulkFileDownloadBudget.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/DurableFileBulkFileDownloadBudget.js +280 -0
- package/out/src/services/chaintracker/chaintracks/util/DurableFileBulkFileDownloadBudget.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/FixedWindowBulkFileDownloadBudget.d.ts +30 -0
- package/out/src/services/chaintracker/chaintracks/util/FixedWindowBulkFileDownloadBudget.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/FixedWindowBulkFileDownloadBudget.js +57 -0
- package/out/src/services/chaintracker/chaintracks/util/FixedWindowBulkFileDownloadBudget.js.map +1 -0
- 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 +14 -0
- package/out/src/services/chaintracker/chaintracks/util/InlineBulkFileDataValidator.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/InlineBulkFileDataValidator.js +148 -0
- package/out/src/services/chaintracker/chaintracks/util/InlineBulkFileDataValidator.js.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/NodeBulkFileDataValidator.d.ts +41 -0
- package/out/src/services/chaintracker/chaintracks/util/NodeBulkFileDataValidator.d.ts.map +1 -0
- package/out/src/services/chaintracker/chaintracks/util/NodeBulkFileDataValidator.js +271 -0
- package/out/src/services/chaintracker/chaintracks/util/NodeBulkFileDataValidator.js.map +1 -0
- 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 +17 -4
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js +362 -105
- 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/chaintracker/index.all.d.ts +1 -0
- package/out/src/services/chaintracker/index.all.d.ts.map +1 -1
- package/out/src/services/chaintracker/index.all.js +1 -0
- package/out/src/services/chaintracker/index.all.js.map +1 -1
- package/out/src/services/chaintracker/index.client.d.ts +1 -0
- package/out/src/services/chaintracker/index.client.d.ts.map +1 -1
- package/out/src/services/chaintracker/index.client.js +1 -0
- package/out/src/services/chaintracker/index.client.js.map +1 -1
- package/out/src/services/chaintracker/index.mobile.d.ts +1 -0
- package/out/src/services/chaintracker/index.mobile.d.ts.map +1 -1
- package/out/src/services/chaintracker/index.mobile.js +1 -0
- package/out/src/services/chaintracker/index.mobile.js.map +1 -1
- package/out/src/services/classifyOutputUtxo.d.ts +25 -0
- package/out/src/services/classifyOutputUtxo.d.ts.map +1 -0
- package/out/src/services/classifyOutputUtxo.js +96 -0
- package/out/src/services/classifyOutputUtxo.js.map +1 -0
- package/out/src/services/createDefaultWalletServicesOptions.d.ts +16 -3
- package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -1
- package/out/src/services/createDefaultWalletServicesOptions.js +38 -8
- package/out/src/services/createDefaultWalletServicesOptions.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 +38 -23
- package/out/src/services/providers/ArcSSEClient.d.ts.map +1 -1
- package/out/src/services/providers/ArcSSEClient.js +384 -63
- package/out/src/services/providers/ArcSSEClient.js.map +1 -1
- package/out/src/services/providers/Arcade.d.ts +11 -1
- package/out/src/services/providers/Arcade.d.ts.map +1 -1
- package/out/src/services/providers/Arcade.js +111 -33
- 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/arcadeStatus.d.ts +18 -0
- package/out/src/services/providers/arcadeStatus.d.ts.map +1 -0
- package/out/src/services/providers/arcadeStatus.js +56 -0
- package/out/src/services/providers/arcadeStatus.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 +29 -6
- package/out/src/signer/actionBatch/ActionBatchPlanner.js.map +1 -1
- package/out/src/signer/actionBatch/ActionBatchWorkspace.d.ts +8 -5
- package/out/src/signer/actionBatch/ActionBatchWorkspace.d.ts.map +1 -1
- package/out/src/signer/actionBatch/ActionBatchWorkspace.js +186 -73
- 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 +35 -3
- package/out/src/signer/methods/createAction.d.ts.map +1 -1
- package/out/src/signer/methods/createAction.js +50 -2
- package/out/src/signer/methods/createAction.js.map +1 -1
- package/out/src/signer/methods/createNoSendExpiryAction.d.ts +7 -0
- package/out/src/signer/methods/createNoSendExpiryAction.d.ts.map +1 -0
- package/out/src/signer/methods/createNoSendExpiryAction.js +254 -0
- package/out/src/signer/methods/createNoSendExpiryAction.js.map +1 -0
- package/out/src/signer/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/signer/methods/internalizeAction.js +9 -5
- 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 +20 -3
- 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 +11 -3
- package/out/src/storage/StorageIdb.d.ts.map +1 -1
- package/out/src/storage/StorageIdb.js +134 -44
- package/out/src/storage/StorageIdb.js.map +1 -1
- package/out/src/storage/StorageKnex.d.ts +68 -7
- package/out/src/storage/StorageKnex.d.ts.map +1 -1
- package/out/src/storage/StorageKnex.js +551 -105
- package/out/src/storage/StorageKnex.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts +41 -10
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +397 -107
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/StorageReader.d.ts +9 -3
- package/out/src/storage/StorageReader.d.ts.map +1 -1
- package/out/src/storage/StorageReader.js +21 -43
- package/out/src/storage/StorageReader.js.map +1 -1
- package/out/src/storage/StorageReaderWriter.d.ts +4 -0
- package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
- package/out/src/storage/StorageReaderWriter.js +68 -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 +31 -6
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.js +166 -75
- package/out/src/storage/WalletStorageManager.js.map +1 -1
- package/out/src/storage/adminServer/adminServer.d.ts +3 -1
- package/out/src/storage/adminServer/adminServer.d.ts.map +1 -1
- package/out/src/storage/adminServer/adminServer.js +38 -49
- package/out/src/storage/adminServer/adminServer.js.map +1 -1
- package/out/src/storage/adminServer/adminUi.d.ts.map +1 -1
- package/out/src/storage/adminServer/adminUi.js +32 -9
- package/out/src/storage/adminServer/adminUi.js.map +1 -1
- package/out/src/storage/adminServer/reviewUtxos.d.ts +27 -0
- package/out/src/storage/adminServer/reviewUtxos.d.ts.map +1 -0
- package/out/src/storage/adminServer/reviewUtxos.js +62 -0
- package/out/src/storage/adminServer/reviewUtxos.js.map +1 -0
- package/out/src/storage/idbHelpers.d.ts.map +1 -1
- package/out/src/storage/idbHelpers.js +14 -2
- package/out/src/storage/idbHelpers.js.map +1 -1
- package/out/src/storage/index.all.d.ts +3 -0
- package/out/src/storage/index.all.d.ts.map +1 -1
- package/out/src/storage/index.all.js +3 -0
- package/out/src/storage/index.all.js.map +1 -1
- package/out/src/storage/index.client.d.ts +1 -0
- package/out/src/storage/index.client.d.ts.map +1 -1
- package/out/src/storage/index.client.js +1 -0
- package/out/src/storage/index.client.js.map +1 -1
- package/out/src/storage/index.mobile.d.ts +1 -0
- package/out/src/storage/index.mobile.d.ts.map +1 -1
- package/out/src/storage/index.mobile.js +1 -0
- package/out/src/storage/index.mobile.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 +5 -44
- package/out/src/storage/methods/ListOutputsSpecOp.js.map +1 -1
- package/out/src/storage/methods/actionBatch.d.ts +9 -2
- package/out/src/storage/methods/actionBatch.d.ts.map +1 -1
- package/out/src/storage/methods/actionBatch.js +260 -67
- 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 +47 -26
- 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 +59 -110
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
- package/out/src/storage/methods/availableManagedChange.d.ts +8 -1
- package/out/src/storage/methods/availableManagedChange.d.ts.map +1 -1
- package/out/src/storage/methods/availableManagedChange.js.map +1 -1
- package/out/src/storage/methods/createAction.d.ts +60 -3
- package/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/out/src/storage/methods/createAction.js +396 -106
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/methods/generateChange.d.ts +21 -5
- package/out/src/storage/methods/generateChange.d.ts.map +1 -1
- package/out/src/storage/methods/generateChange.js +194 -27
- 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 +171 -133
- 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 +22 -11
- 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 +25 -18
- 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 +33 -31
- package/out/src/storage/methods/listOutputsKnex.js.map +1 -1
- package/out/src/storage/methods/managedChangePolicy.d.ts +44 -0
- package/out/src/storage/methods/managedChangePolicy.d.ts.map +1 -0
- package/out/src/storage/methods/managedChangePolicy.js +58 -0
- package/out/src/storage/methods/managedChangePolicy.js.map +1 -0
- package/out/src/storage/methods/maxPossibleSatoshis.d.ts +13 -0
- package/out/src/storage/methods/maxPossibleSatoshis.d.ts.map +1 -0
- package/out/src/storage/methods/maxPossibleSatoshis.js +16 -0
- package/out/src/storage/methods/maxPossibleSatoshis.js.map +1 -0
- package/out/src/storage/methods/noSendExpiry.d.ts +11 -0
- package/out/src/storage/methods/noSendExpiry.d.ts.map +1 -0
- package/out/src/storage/methods/noSendExpiry.js +369 -0
- package/out/src/storage/methods/noSendExpiry.js.map +1 -0
- package/out/src/storage/methods/noSendExpiryLifecycle.d.ts +14 -0
- package/out/src/storage/methods/noSendExpiryLifecycle.d.ts.map +1 -0
- package/out/src/storage/methods/noSendExpiryLifecycle.js +691 -0
- package/out/src/storage/methods/noSendExpiryLifecycle.js.map +1 -0
- package/out/src/storage/methods/preparedBeef.d.ts +104 -0
- package/out/src/storage/methods/preparedBeef.d.ts.map +1 -0
- package/out/src/storage/methods/preparedBeef.js +524 -0
- package/out/src/storage/methods/preparedBeef.js.map +1 -0
- package/out/src/storage/methods/processAction.d.ts.map +1 -1
- package/out/src/storage/methods/processAction.js +144 -32
- package/out/src/storage/methods/processAction.js.map +1 -1
- package/out/src/storage/methods/purgeData.d.ts.map +1 -1
- package/out/src/storage/methods/purgeData.js +21 -3
- package/out/src/storage/methods/purgeData.js.map +1 -1
- package/out/src/storage/methods/reconcileFailedTransactionInputs.d.ts +32 -0
- package/out/src/storage/methods/reconcileFailedTransactionInputs.d.ts.map +1 -0
- package/out/src/storage/methods/reconcileFailedTransactionInputs.js +142 -0
- package/out/src/storage/methods/reconcileFailedTransactionInputs.js.map +1 -0
- package/out/src/storage/methods/reviewStatus.d.ts.map +1 -1
- package/out/src/storage/methods/reviewStatus.js +7 -4
- package/out/src/storage/methods/reviewStatus.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 +38 -0
- package/out/src/storage/methods/reviewUtxoOutputs.d.ts.map +1 -0
- package/out/src/storage/methods/reviewUtxoOutputs.js +197 -0
- package/out/src/storage/methods/reviewUtxoOutputs.js.map +1 -0
- package/out/src/storage/methods/validateSyncProof.d.ts +32 -0
- package/out/src/storage/methods/validateSyncProof.d.ts.map +1 -0
- package/out/src/storage/methods/validateSyncProof.js +139 -0
- package/out/src/storage/methods/validateSyncProof.js.map +1 -0
- package/out/src/storage/portable/index.d.ts.map +1 -1
- package/out/src/storage/portable/index.js +25 -15
- 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/KnexPaymentReplayStore.d.ts.map +1 -1
- package/out/src/storage/remoting/KnexPaymentReplayStore.js +1 -0
- package/out/src/storage/remoting/KnexPaymentReplayStore.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 +221 -40
- 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 +57 -10
- package/out/src/storage/remoting/StorageClientBase.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClientBase.js +382 -10
- 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 +232 -20
- 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 +14 -0
- package/out/src/storage/remoting/syncChunkBinary.d.ts.map +1 -0
- package/out/src/storage/remoting/syncChunkBinary.js +42 -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 +6 -0
- package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -1
- package/out/src/storage/schema/KnexMigrations.js +194 -5
- package/out/src/storage/schema/KnexMigrations.js.map +1 -1
- package/out/src/storage/schema/StorageIdbSchema.d.ts +3 -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 +24 -4
- 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 +5 -2
- package/out/src/storage/schema/entities/EntityOutputBasket.js.map +1 -1
- package/out/src/storage/schema/entities/EntityProvenTx.d.ts +4 -1
- package/out/src/storage/schema/entities/EntityProvenTx.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityProvenTx.js +125 -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 +4 -2
- package/out/src/storage/schema/entities/EntitySyncState.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntitySyncState.js +12 -6
- package/out/src/storage/schema/entities/EntitySyncState.js.map +1 -1
- package/out/src/storage/schema/entities/EntityTransaction.d.ts +26 -0
- package/out/src/storage/schema/entities/EntityTransaction.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityTransaction.js +221 -21
- package/out/src/storage/schema/entities/EntityTransaction.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/TablePreparedBeef.interfaces.d.ts +23 -0
- package/out/src/storage/schema/tables/TablePreparedBeef.interfaces.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TablePreparedBeef.interfaces.js +3 -0
- package/out/src/storage/schema/tables/TablePreparedBeef.interfaces.js.map +1 -0
- 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 +2 -2
- 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 +17 -1
- package/out/src/storage/schema/tables/TableTransaction.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableTransaction.js +14 -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/Argon2idBackend.d.ts +36 -0
- package/out/src/utility/Argon2idBackend.d.ts.map +1 -0
- package/out/src/utility/Argon2idBackend.js +60 -0
- package/out/src/utility/Argon2idBackend.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/beefForTxids.d.ts +12 -3
- package/out/src/utility/beefForTxids.d.ts.map +1 -1
- package/out/src/utility/beefForTxids.js +69 -21
- package/out/src/utility/beefForTxids.js.map +1 -1
- package/out/src/utility/brc153ReferenceLabels.d.ts +16 -0
- package/out/src/utility/brc153ReferenceLabels.d.ts.map +1 -1
- package/out/src/utility/brc153ReferenceLabels.js +20 -5
- package/out/src/utility/brc153ReferenceLabels.js.map +1 -1
- package/out/src/utility/brc177NoSendExpiry.d.ts +34 -0
- package/out/src/utility/brc177NoSendExpiry.d.ts.map +1 -0
- package/out/src/utility/brc177NoSendExpiry.js +81 -0
- package/out/src/utility/brc177NoSendExpiry.js.map +1 -0
- package/out/src/utility/canonicalizeAtomicBeef.d.ts +12 -0
- package/out/src/utility/canonicalizeAtomicBeef.d.ts.map +1 -0
- package/out/src/utility/canonicalizeAtomicBeef.js +23 -0
- package/out/src/utility/canonicalizeAtomicBeef.js.map +1 -0
- package/out/src/utility/exactActionSpend.d.ts +9 -0
- package/out/src/utility/exactActionSpend.d.ts.map +1 -0
- package/out/src/utility/exactActionSpend.js +26 -0
- package/out/src/utility/exactActionSpend.js.map +1 -0
- package/out/src/utility/hashWasm.d.ts +1 -1
- package/out/src/utility/hashWasm.d.ts.map +1 -1
- package/out/src/utility/hashWasm.js +83 -1
- package/out/src/utility/hashWasm.js.map +1 -1
- 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 +523 -61
- package/out/src/utility/identityUtils.js.map +1 -1
- package/out/src/utility/index.all.d.ts +2 -0
- package/out/src/utility/index.all.d.ts.map +1 -1
- package/out/src/utility/index.all.js +2 -0
- package/out/src/utility/index.all.js.map +1 -1
- package/out/src/utility/index.client.d.ts +2 -0
- package/out/src/utility/index.client.d.ts.map +1 -1
- package/out/src/utility/index.client.js +2 -0
- package/out/src/utility/index.client.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 +1 -1
- package/out/src/utility/utilityHelpers.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.js +10 -7
- 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 +4 -17
- package/out/src/wab-client/WABClient.d.ts.map +1 -1
- package/out/src/wab-client/WABClient.js +35 -12
- 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/WABTransport.d.ts +17 -23
- package/out/src/wab-client/WABTransport.d.ts.map +1 -1
- package/out/src/wab-client/WABTransport.js +130 -142
- package/out/src/wab-client/WABTransport.js.map +1 -1
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts +8 -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 +45 -41
- package/docs/open-rpc/index.html +0 -46
|
@@ -1,16 +1,202 @@
|
|
|
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");
|
|
11
14
|
const blockHeaderUtilities_1 = require("./blockHeaderUtilities");
|
|
12
15
|
const ChaintracksFetch_1 = require("./ChaintracksFetch");
|
|
13
16
|
const SingleWriterMultiReaderLock_1 = require("./SingleWriterMultiReaderLock");
|
|
17
|
+
const BulkFileDataValidatorApi_1 = require("../Api/BulkFileDataValidatorApi");
|
|
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
|
+
}
|
|
14
200
|
/**
|
|
15
201
|
* Manages bulk file data (typically 8MB chunks of 100,000 headers each).
|
|
16
202
|
*
|
|
@@ -32,35 +218,93 @@ class BulkFileDataManager {
|
|
|
32
218
|
}
|
|
33
219
|
log = () => { };
|
|
34
220
|
bfds = [];
|
|
35
|
-
fileHashToIndex =
|
|
221
|
+
fileHashToIndex = Object.create(null);
|
|
36
222
|
lock = new SingleWriterMultiReaderLock_1.SingleWriterMultiReaderLock();
|
|
223
|
+
inFlightLoads = new Map();
|
|
224
|
+
failedLoads = new Map();
|
|
37
225
|
storage;
|
|
226
|
+
stats = {
|
|
227
|
+
memoryHits: 0,
|
|
228
|
+
storageHits: 0,
|
|
229
|
+
persistentCacheHits: 0,
|
|
230
|
+
persistentCacheMisses: 0,
|
|
231
|
+
persistentCacheRejects: 0,
|
|
232
|
+
coalescedLoads: 0,
|
|
233
|
+
downloads: 0,
|
|
234
|
+
downloadedBytes: 0,
|
|
235
|
+
loadBackoffs: 0
|
|
236
|
+
};
|
|
38
237
|
chain;
|
|
39
238
|
maxPerFile;
|
|
40
239
|
fetch;
|
|
41
240
|
maxRetained;
|
|
42
241
|
fromKnownSourceUrl;
|
|
242
|
+
cache;
|
|
243
|
+
downloadBudget;
|
|
244
|
+
validator;
|
|
245
|
+
failedLoadRetryMsecs;
|
|
43
246
|
constructor(options) {
|
|
247
|
+
if (options == null)
|
|
248
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('options', 'a Chain or BulkFileDataManagerOptions object');
|
|
44
249
|
const resolvedOptions = typeof options === 'object' ? options : BulkFileDataManager.createDefaultOptions(options);
|
|
45
250
|
this.chain = resolvedOptions.chain;
|
|
46
251
|
this.maxPerFile = resolvedOptions.maxPerFile;
|
|
47
252
|
this.maxRetained = resolvedOptions.maxRetained;
|
|
48
253
|
this.fromKnownSourceUrl = resolvedOptions.fromKnownSourceUrl;
|
|
49
254
|
this.fetch = resolvedOptions.fetch;
|
|
255
|
+
this.cache = resolvedOptions.cache;
|
|
256
|
+
this.downloadBudget = resolvedOptions.downloadBudget;
|
|
257
|
+
this.validator = resolvedOptions.validator ?? new InlineBulkFileDataValidator_1.InlineBulkFileDataValidator();
|
|
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
|
+
}
|
|
269
|
+
if (!Number.isSafeInteger(this.failedLoadRetryMsecs) || this.failedLoadRetryMsecs < 0) {
|
|
270
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('failedLoadRetryMsecs', 'a non-negative safe integer');
|
|
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
|
+
}
|
|
50
288
|
this.deleteBulkFilesNoLock();
|
|
51
289
|
}
|
|
290
|
+
getStats() {
|
|
291
|
+
return {
|
|
292
|
+
...this.stats,
|
|
293
|
+
validation: this.validator.getStats?.(),
|
|
294
|
+
downloadBudget: this.downloadBudget?.snapshot?.()
|
|
295
|
+
};
|
|
296
|
+
}
|
|
52
297
|
async deleteBulkFiles() {
|
|
53
298
|
return await this.lock.withWriteLock(async () => this.deleteBulkFilesNoLock());
|
|
54
299
|
}
|
|
55
300
|
deleteBulkFilesNoLock() {
|
|
56
|
-
this.
|
|
57
|
-
this.fileHashToIndex = {};
|
|
301
|
+
this.setBulkFilesState([]);
|
|
58
302
|
if (this.fromKnownSourceUrl) {
|
|
59
303
|
const vbhfs = validBulkHeaderFilesByFileHash_1.validBulkHeaderFiles;
|
|
60
304
|
const filtered = vbhfs.filter(f => f.sourceUrl === this.fromKnownSourceUrl);
|
|
61
305
|
const files = selectBulkHeaderFiles(filtered, this.chain, this.maxPerFile);
|
|
62
306
|
for (const file of files) {
|
|
63
|
-
this.add({ ...file, fileHash: file.fileHash, mru: Date.now() });
|
|
307
|
+
this.add({ ...file, fileHash: file.fileHash, validated: false, mru: Date.now() });
|
|
64
308
|
}
|
|
65
309
|
}
|
|
66
310
|
}
|
|
@@ -75,33 +319,62 @@ class BulkFileDataManager {
|
|
|
75
319
|
return await this.lock.withWriteLock(async () => await this.setStorageNoLock(storage, log));
|
|
76
320
|
}
|
|
77
321
|
async setStorageNoLock(storage, log) {
|
|
78
|
-
|
|
79
|
-
|
|
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');
|
|
80
333
|
// Get files currently in persistent storage.
|
|
81
|
-
const sfs = await
|
|
334
|
+
const sfs = await storage.getBulkFiles();
|
|
82
335
|
// Sync bfds with storage. Two scenarios supported:
|
|
83
336
|
const bfdsRanges = this.heightRangesFromBulkFiles(this.bfds);
|
|
84
337
|
const sfsRanges = this.heightRangesFromBulkFiles(sfs);
|
|
85
338
|
if (sfsRanges.cdn.length >= bfdsRanges.cdn.length) {
|
|
86
339
|
// Storage win if it has greater or equal CDN coverage
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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;
|
|
92
360
|
}
|
|
93
361
|
}
|
|
94
362
|
else {
|
|
95
363
|
// Bfds win if they have greater CDN coverage
|
|
96
|
-
// Replace
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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 = [];
|
|
101
370
|
for (const bfd of this.bfds) {
|
|
102
|
-
await this.ensureData(bfd);
|
|
103
|
-
|
|
371
|
+
const data = await this.ensureData(bfd);
|
|
372
|
+
desired.push({ ...bfdToInfo(bfd, true), data: new Uint8Array(data) });
|
|
104
373
|
}
|
|
374
|
+
const committed = await storage.replaceBulkFiles(desired);
|
|
375
|
+
this.applyCommittedBulkFiles(committed);
|
|
376
|
+
this.storage = storage;
|
|
377
|
+
this.log = log;
|
|
105
378
|
}
|
|
106
379
|
}
|
|
107
380
|
heightRangesFromBulkFiles(files) {
|
|
@@ -117,8 +390,8 @@ class BulkFileDataManager {
|
|
|
117
390
|
return ranges;
|
|
118
391
|
}
|
|
119
392
|
async createReader(range, maxBufferSize) {
|
|
120
|
-
range
|
|
121
|
-
maxBufferSize
|
|
393
|
+
range ??= await this.getHeightRange();
|
|
394
|
+
maxBufferSize ??= MAX_BULK_FILE_HEADERS * 80;
|
|
122
395
|
return new BulkFileDataReader_1.BulkFileDataReader(this, range, maxBufferSize);
|
|
123
396
|
}
|
|
124
397
|
async updateFromUrl(cdnUrl) {
|
|
@@ -126,10 +399,11 @@ class BulkFileDataManager {
|
|
|
126
399
|
throw new sdk_1.WERR_INVALID_OPERATION('fetch is not defined in the BulkFileDataManager.');
|
|
127
400
|
const toUrl = (file) => this.fetch.pathJoin(cdnUrl, file);
|
|
128
401
|
const url = toUrl(`${this.chain}NetBlockHeaders.json`);
|
|
129
|
-
const
|
|
130
|
-
if (!
|
|
402
|
+
const response = await this.fetch.fetchJson(url);
|
|
403
|
+
if (!response) {
|
|
131
404
|
throw new sdk_1.WERR_INVALID_PARAMETER('cdnUrl', `a valid BulkHeaderFilesInfo JSON resource available from ${url}`);
|
|
132
405
|
}
|
|
406
|
+
const availableBulkFiles = normalizeBulkHeaderFilesInfo(response);
|
|
133
407
|
const selectedFiles = selectBulkHeaderFiles(availableBulkFiles.files, this.chain, this.maxPerFile || availableBulkFiles.headersPerFile);
|
|
134
408
|
for (const bf of selectedFiles) {
|
|
135
409
|
if (!bf.fileHash) {
|
|
@@ -138,6 +412,8 @@ class BulkFileDataManager {
|
|
|
138
412
|
if (!bf.chain || bf.chain !== this.chain) {
|
|
139
413
|
throw new sdk_1.WERR_INVALID_PARAMETER('chain', `"${this.chain}" for all files in json downloaded from ${url}`);
|
|
140
414
|
}
|
|
415
|
+
// A remote manifest never has authority over local storage identities.
|
|
416
|
+
bf.fileId = undefined;
|
|
141
417
|
if (!bf.sourceUrl || bf.sourceUrl !== cdnUrl)
|
|
142
418
|
bf.sourceUrl = cdnUrl;
|
|
143
419
|
}
|
|
@@ -154,11 +430,20 @@ class BulkFileDataManager {
|
|
|
154
430
|
return await this.lock.withWriteLock(async () => await this.mergeNoLock(files));
|
|
155
431
|
}
|
|
156
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
|
+
}
|
|
157
436
|
const r = { inserted: [], updated: [], unchanged: [], dropped: [] };
|
|
158
|
-
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);
|
|
159
443
|
const hbf = this.getBfdForHeight(file.firstHeight);
|
|
160
|
-
if (
|
|
161
|
-
|
|
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
|
+
}
|
|
162
447
|
const lbf = this.getLastBfd();
|
|
163
448
|
if (hbf?.fileHash === file.fileHash &&
|
|
164
449
|
hbf.count === file.count &&
|
|
@@ -171,12 +456,18 @@ class BulkFileDataManager {
|
|
|
171
456
|
const vbf = await this.validateFileInfo(file);
|
|
172
457
|
if (hbf != null) {
|
|
173
458
|
// We have a matching file by firstHeight but count and fileHash differ
|
|
459
|
+
await this.ensureData(vbf);
|
|
174
460
|
await this.update(vbf, hbf, r);
|
|
175
461
|
}
|
|
176
462
|
else if (isBdfIncremental(vbf) && lbf != null && isBdfIncremental(lbf)) {
|
|
177
463
|
await this.mergeIncremental(lbf, vbf, r);
|
|
178
464
|
}
|
|
179
465
|
else {
|
|
466
|
+
// A storage-backed record must never be created with metadata only:
|
|
467
|
+
// subsequent reads prefer its fileId and correctly fail closed when
|
|
468
|
+
// data is absent. Validate and materialize it before insertion.
|
|
469
|
+
if (this.storage != null)
|
|
470
|
+
await this.ensureData(vbf);
|
|
180
471
|
const added = await this.add(vbf);
|
|
181
472
|
r.inserted.push(added);
|
|
182
473
|
}
|
|
@@ -185,23 +476,32 @@ class BulkFileDataManager {
|
|
|
185
476
|
return r;
|
|
186
477
|
}
|
|
187
478
|
async mergeIncremental(lbf, vbf, r) {
|
|
188
|
-
lbf.count
|
|
189
|
-
|
|
190
|
-
|
|
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
|
+
}
|
|
191
482
|
await this.ensureData(lbf);
|
|
192
483
|
const newData = new Uint8Array(lbf.data.length + vbf.data.length);
|
|
193
484
|
newData.set(lbf.data);
|
|
194
485
|
newData.set(vbf.data, lbf.data.length);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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}`);
|
|
204
502
|
}
|
|
503
|
+
this.replaceBfdAtIndex(this.bfds.length - 1, merged);
|
|
504
|
+
r.updated.push(lbfInfo);
|
|
205
505
|
}
|
|
206
506
|
toLogString(what) {
|
|
207
507
|
let log = '';
|
|
@@ -233,8 +533,51 @@ class BulkFileDataManager {
|
|
|
233
533
|
return log;
|
|
234
534
|
}
|
|
235
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;
|
|
236
576
|
if (newBulkHeaders.length === 0)
|
|
237
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
|
+
}
|
|
238
581
|
return await this.lock.withWriteLock(async () => {
|
|
239
582
|
const lbf = this.getLastFileNoLock();
|
|
240
583
|
const nextHeight = lbf != null ? lbf.firstHeight + lbf.count : 0;
|
|
@@ -253,7 +596,7 @@ class BulkFileDataManager {
|
|
|
253
596
|
? (0, blockHeaderUtilities_1.addWork)(incrementalChainWork, prevChainWork)
|
|
254
597
|
: computeChainWorkFromHeaders(newBulkHeaders, lbf);
|
|
255
598
|
const data = (0, blockHeaderUtilities_1.serializeBaseBlockHeaders)(newBulkHeaders);
|
|
256
|
-
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');
|
|
257
600
|
const bf = {
|
|
258
601
|
fileId: undefined,
|
|
259
602
|
chain: this.chain,
|
|
@@ -286,50 +629,78 @@ class BulkFileDataManager {
|
|
|
286
629
|
});
|
|
287
630
|
}
|
|
288
631
|
async getDataFromFile(file, offset, length) {
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
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
|
+
}
|
|
643
|
+
const resolved = await this.lock.withReadLock(async () => {
|
|
644
|
+
const resolved = this.getBfdForHeight(file.firstHeight);
|
|
645
|
+
if (resolved == null || resolved.count < file.count) {
|
|
646
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('file', `a match for ${file.firstHeight}, ${file.count} in the BulkFileDataManager.`);
|
|
647
|
+
}
|
|
648
|
+
return { current: resolved, snapshot: snapshotBfd(resolved) };
|
|
649
|
+
});
|
|
650
|
+
// The immutable descriptor is snapshotted under the reader lock, but disk,
|
|
651
|
+
// network, and validation work happens after releasing it. A concurrent
|
|
652
|
+
// writer can publish a newer descriptor without invalidating this read.
|
|
653
|
+
return await this.getDataFromSnapshot(resolved.current, resolved.snapshot, offset, length);
|
|
654
|
+
}
|
|
655
|
+
async getDataFromSnapshot(original, snapshot, offset, length) {
|
|
656
|
+
const data = await this.getDataFromFileNoLock(snapshot, offset, length);
|
|
657
|
+
if (snapshot.data != null) {
|
|
658
|
+
await this.lock.withWriteLock(async () => {
|
|
659
|
+
if (this.bfds.includes(original) &&
|
|
660
|
+
original.fileHash === snapshot.fileHash &&
|
|
661
|
+
original.firstHeight === snapshot.firstHeight &&
|
|
662
|
+
original.count === snapshot.count) {
|
|
663
|
+
original.data = snapshot.data;
|
|
664
|
+
original.validated = true;
|
|
665
|
+
original.lastHash = snapshot.lastHash;
|
|
666
|
+
original.lastChainWork = snapshot.lastChainWork;
|
|
667
|
+
original.mru = Date.now();
|
|
668
|
+
this.ensureMaxRetained();
|
|
669
|
+
}
|
|
670
|
+
});
|
|
292
671
|
}
|
|
293
|
-
return
|
|
672
|
+
return data;
|
|
294
673
|
}
|
|
295
674
|
async getDataFromFileNoLock(bfd, offset, length) {
|
|
296
675
|
const fileLength = bfd.count * 80;
|
|
297
|
-
offset
|
|
676
|
+
offset ??= 0;
|
|
298
677
|
if (offset > fileLength - 1)
|
|
299
678
|
return undefined;
|
|
300
|
-
length
|
|
679
|
+
length ??= bfd.count * 80 - offset;
|
|
301
680
|
length = Math.min(length, fileLength - offset);
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
await this.ensureData(bfd);
|
|
311
|
-
if (bfd.data != null)
|
|
312
|
-
data = bfd.data.slice(offset, offset + length);
|
|
313
|
-
}
|
|
314
|
-
if (data == null)
|
|
315
|
-
return undefined;
|
|
316
|
-
return data;
|
|
681
|
+
if (length === 0)
|
|
682
|
+
return new Uint8Array();
|
|
683
|
+
// Never serve a partial storage read before validating the complete
|
|
684
|
+
// immutable object. Metadata and advisory validation state may have crossed
|
|
685
|
+
// a storage boundary, and neither can establish the digest, linkage, or
|
|
686
|
+
// proof-of-work of an isolated 80-byte slice.
|
|
687
|
+
const data = await this.ensureData(bfd);
|
|
688
|
+
return data.slice(offset, offset + length);
|
|
317
689
|
}
|
|
318
690
|
async findHeaderForHeightOrUndefined(height) {
|
|
319
|
-
|
|
320
|
-
if (!Number.
|
|
321
|
-
throw new sdk_1.WERR_INVALID_PARAMETER('height', `
|
|
691
|
+
const resolved = await this.lock.withReadLock(async () => {
|
|
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}).`);
|
|
322
694
|
}
|
|
323
695
|
const file = this.bfds.find(f => f.firstHeight <= height && f.firstHeight + f.count > height);
|
|
324
696
|
if (file == null)
|
|
325
697
|
return undefined;
|
|
326
|
-
|
|
327
|
-
const data = await this.getDataFromFileNoLock(file, offset, 80);
|
|
328
|
-
if (data == null)
|
|
329
|
-
return undefined;
|
|
330
|
-
const header = (0, blockHeaderUtilities_1.deserializeBlockHeader)(data, height, 0);
|
|
331
|
-
return header;
|
|
698
|
+
return { current: file, snapshot: snapshotBfd(file), offset: (height - file.firstHeight) * 80 };
|
|
332
699
|
});
|
|
700
|
+
if (resolved == null)
|
|
701
|
+
return undefined;
|
|
702
|
+
const data = await this.getDataFromSnapshot(resolved.current, resolved.snapshot, resolved.offset, 80);
|
|
703
|
+
return data == null ? undefined : (0, blockHeaderUtilities_1.deserializeBlockHeader)(data, height, 0);
|
|
333
704
|
}
|
|
334
705
|
async getFileForHeight(height) {
|
|
335
706
|
return await this.lock.withReadLock(async () => {
|
|
@@ -340,13 +711,16 @@ class BulkFileDataManager {
|
|
|
340
711
|
});
|
|
341
712
|
}
|
|
342
713
|
getBfdForHeight(height) {
|
|
343
|
-
if (!Number.
|
|
344
|
-
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}).`);
|
|
345
716
|
}
|
|
346
717
|
const file = this.bfds.find(f => f.firstHeight <= height && f.firstHeight + f.count > height);
|
|
347
718
|
return file;
|
|
348
719
|
}
|
|
349
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
|
+
}
|
|
350
724
|
if (this.bfds.length < fromEnd)
|
|
351
725
|
return undefined;
|
|
352
726
|
const bfd = this.bfds[this.bfds.length - fromEnd];
|
|
@@ -379,11 +753,9 @@ class BulkFileDataManager {
|
|
|
379
753
|
return data;
|
|
380
754
|
}
|
|
381
755
|
async validateFileInfo(file) {
|
|
756
|
+
file = normalizeBulkHeaderFileInfo(file, true);
|
|
382
757
|
if (file.chain !== this.chain)
|
|
383
758
|
throw new sdk_1.WERR_INVALID_PARAMETER('chain', `${this.chain}`);
|
|
384
|
-
if (file.count <= 0) {
|
|
385
|
-
throw new sdk_1.WERR_INVALID_PARAMETER('bf.count', `expected count to be greater than 0, but got ${file.count}`);
|
|
386
|
-
}
|
|
387
759
|
if (file.count > this.maxPerFile && file.fileName !== 'incremental') {
|
|
388
760
|
throw new sdk_1.WERR_INVALID_PARAMETER('count', `less than or equal to maxPerFile ${this.maxPerFile}`);
|
|
389
761
|
}
|
|
@@ -392,44 +764,51 @@ class BulkFileDataManager {
|
|
|
392
764
|
if (!file.sourceUrl && !file.fileId && file.data == null) {
|
|
393
765
|
throw new sdk_1.WERR_INVALID_PARAMETER('data', 'defined when sourceUrl and fileId are undefined');
|
|
394
766
|
}
|
|
395
|
-
|
|
396
|
-
|
|
767
|
+
// `validated` may have crossed a storage or network boundary. Never trust
|
|
768
|
+
// that flag. Data supplied with the metadata is verified immediately;
|
|
769
|
+
// remotely or persistently backed data remains lazy and is verified by
|
|
770
|
+
// `loadAndValidateData` before its first use.
|
|
771
|
+
const bfd = {
|
|
772
|
+
...file,
|
|
773
|
+
fileHash: file.fileHash,
|
|
774
|
+
validated: false,
|
|
775
|
+
mru: Date.now()
|
|
776
|
+
};
|
|
777
|
+
if (bfd.data != null) {
|
|
397
778
|
await this.validateBfdData(bfd, file.fileHash);
|
|
398
779
|
bfd.validated = true;
|
|
399
780
|
}
|
|
400
781
|
return bfd;
|
|
401
782
|
}
|
|
402
783
|
async validateBfdData(bfd, expectedFileHash) {
|
|
403
|
-
await this.ensureData(bfd);
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
}
|
|
407
|
-
bfd.fileHash = (0, utilityHelpers_noBuffer_1.asString)(sdk_2.Hash.sha256((0, utilityHelpers_noBuffer_1.asArray)(bfd.data)), 'base64');
|
|
408
|
-
if (expectedFileHash && expectedFileHash !== bfd.fileHash) {
|
|
409
|
-
throw new sdk_1.WERR_INVALID_PARAMETER('file.fileHash', `expected ${expectedFileHash} but got ${bfd.fileHash}`);
|
|
410
|
-
}
|
|
411
|
-
if (!(0, validBulkHeaderFilesByFileHash_1.isKnownValidBulkHeaderFile)(bfd)) {
|
|
412
|
-
this.validateBfdHeaders(bfd);
|
|
413
|
-
}
|
|
784
|
+
const data = await this.ensureData(bfd);
|
|
785
|
+
const validated = await this.validateRetrievedData(bfd, data, expectedFileHash);
|
|
786
|
+
bfd.data = validated;
|
|
414
787
|
}
|
|
415
|
-
validateBfdHeaders(bfd) {
|
|
788
|
+
async validateBfdHeaders(bfd, expectedFileHash = bfd.fileHash) {
|
|
416
789
|
const pbf = bfd.firstHeight > 0 ? this.getBfdForHeight(bfd.firstHeight - 1) : undefined;
|
|
417
790
|
const prevHash = pbf?.lastHash ?? '00'.repeat(32);
|
|
418
791
|
const prevChainWork = pbf?.lastChainWork ?? '00'.repeat(32);
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
792
|
+
const result = await this.validator.validate({
|
|
793
|
+
fileName: bfd.fileName,
|
|
794
|
+
data: bfd.data,
|
|
795
|
+
count: bfd.count,
|
|
796
|
+
fileHash: expectedFileHash,
|
|
797
|
+
firstHeight: bfd.firstHeight,
|
|
798
|
+
prevHash,
|
|
799
|
+
prevChainWork,
|
|
800
|
+
lastHash: bfd.lastHash,
|
|
801
|
+
lastChainWork: bfd.lastChainWork,
|
|
802
|
+
chain: bfd.chain
|
|
803
|
+
});
|
|
804
|
+
bfd.data = result.data;
|
|
805
|
+
bfd.fileHash = result.fileHash;
|
|
806
|
+
bfd.lastHash = result.lastHeaderHash;
|
|
807
|
+
bfd.lastChainWork = result.lastChainWork;
|
|
808
|
+
return result.data;
|
|
430
809
|
}
|
|
431
810
|
async ReValidate() {
|
|
432
|
-
return await this.lock.
|
|
811
|
+
return await this.lock.withWriteLock(async () => await this.ReValidateNoLock());
|
|
433
812
|
}
|
|
434
813
|
async ReValidateNoLock() {
|
|
435
814
|
for (const file of this.bfds) {
|
|
@@ -442,6 +821,9 @@ class BulkFileDataManager {
|
|
|
442
821
|
}
|
|
443
822
|
}
|
|
444
823
|
validateBfdForAdd(bfd) {
|
|
824
|
+
if (this.fileHashToIndex[bfd.fileHash] !== undefined) {
|
|
825
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('fileHash', 'unique within bulk storage');
|
|
826
|
+
}
|
|
445
827
|
if (this.bfds.length === 0 && bfd.firstHeight !== 0) {
|
|
446
828
|
throw new sdk_1.WERR_INVALID_PARAMETER('firstHeight', '0 for the first file');
|
|
447
829
|
}
|
|
@@ -457,14 +839,14 @@ class BulkFileDataManager {
|
|
|
457
839
|
}
|
|
458
840
|
async add(bfd) {
|
|
459
841
|
this.validateBfdForAdd(bfd);
|
|
460
|
-
const index = this.bfds.length;
|
|
461
|
-
this.bfds.push(bfd);
|
|
462
|
-
this.fileHashToIndex[bfd.fileHash] = index;
|
|
463
|
-
this.ensureMaxRetained();
|
|
464
842
|
const info = bfdToInfo(bfd, true);
|
|
465
843
|
if (this.storage != null) {
|
|
466
844
|
info.fileId = bfd.fileId = await this.storage.insertBulkFile(info);
|
|
467
845
|
}
|
|
846
|
+
const index = this.bfds.length;
|
|
847
|
+
this.bfds.push(bfd);
|
|
848
|
+
this.fileHashToIndex[bfd.fileHash] = index;
|
|
849
|
+
this.ensureMaxRetained();
|
|
468
850
|
return info;
|
|
469
851
|
}
|
|
470
852
|
replaceBfdAtIndex(index, update) {
|
|
@@ -473,6 +855,40 @@ class BulkFileDataManager {
|
|
|
473
855
|
this.bfds[index] = update;
|
|
474
856
|
this.fileHashToIndex[update.fileHash] = index;
|
|
475
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
|
+
}
|
|
476
892
|
/**
|
|
477
893
|
* Updating an existing file occurs in two specific contexts:
|
|
478
894
|
*
|
|
@@ -508,15 +924,31 @@ class BulkFileDataManager {
|
|
|
508
924
|
if (isBdfCdn(update) === isBdfCdn(hbf) && update.count <= hbf.count) {
|
|
509
925
|
throw new sdk_1.WERR_INVALID_PARAMETER('file.count', `greater than the current count ${hbf.count}`);
|
|
510
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);
|
|
511
933
|
const { index, truncate, replaced, drop } = await this.resolveUpdatePlan(update, hbf);
|
|
512
|
-
|
|
513
|
-
if (
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
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
|
+
}
|
|
520
952
|
}
|
|
521
953
|
async resolveUpdatePlan(update, hbf) {
|
|
522
954
|
const lbf = this.getLastBfd();
|
|
@@ -568,23 +1000,19 @@ class BulkFileDataManager {
|
|
|
568
1000
|
replaced: penultimateFile
|
|
569
1001
|
};
|
|
570
1002
|
}
|
|
571
|
-
async persistUpdate(update, truncate,
|
|
1003
|
+
async persistUpdate(update, truncate, drop) {
|
|
572
1004
|
if (this.storage == null)
|
|
573
1005
|
return;
|
|
574
|
-
if (
|
|
575
|
-
await this.storage.
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
if (replaced != null) {
|
|
579
|
-
await this.storage.updateBulkFile(truncate.fileId, truncateInfo);
|
|
580
|
-
}
|
|
581
|
-
else {
|
|
582
|
-
truncateInfo.fileId = undefined;
|
|
583
|
-
truncate.fileId = await this.storage.insertBulkFile(truncateInfo);
|
|
584
|
-
}
|
|
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;
|
|
585
1010
|
}
|
|
586
|
-
if (
|
|
587
|
-
|
|
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}`);
|
|
588
1016
|
}
|
|
589
1017
|
recordUpdateResults(r, update, truncate, replaced, drop) {
|
|
590
1018
|
if (!r)
|
|
@@ -644,7 +1072,7 @@ class BulkFileDataManager {
|
|
|
644
1072
|
truncate.firstHeight += count;
|
|
645
1073
|
truncate.data = truncate.data?.slice(count * 80);
|
|
646
1074
|
delete this.fileHashToIndex[truncate.fileHash];
|
|
647
|
-
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');
|
|
648
1076
|
this.fileHashToIndex[truncate.fileHash] = updateIndex + 1;
|
|
649
1077
|
}
|
|
650
1078
|
/**
|
|
@@ -653,36 +1081,126 @@ class BulkFileDataManager {
|
|
|
653
1081
|
* @returns
|
|
654
1082
|
*/
|
|
655
1083
|
async ensureData(bfd) {
|
|
656
|
-
if (bfd.data != null)
|
|
1084
|
+
if (bfd.data != null) {
|
|
1085
|
+
this.stats.memoryHits++;
|
|
1086
|
+
bfd.mru = Date.now();
|
|
657
1087
|
return bfd.data;
|
|
658
|
-
if (this.storage != null && bfd.fileId) {
|
|
659
|
-
bfd.data = await this.storage.getBulkFileData(bfd.fileId);
|
|
660
|
-
if (bfd.data == null)
|
|
661
|
-
throw new sdk_1.WERR_INVALID_PARAMETER('fileId', `valid, data not found for fileId ${bfd.fileId}`);
|
|
662
1088
|
}
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
1089
|
+
const key = `${bfd.fileHash}:${bfd.fileName}`;
|
|
1090
|
+
const existing = this.inFlightLoads.get(key);
|
|
1091
|
+
if (existing != null) {
|
|
1092
|
+
this.stats.coalescedLoads++;
|
|
1093
|
+
const data = await existing;
|
|
1094
|
+
bfd.data = data;
|
|
1095
|
+
bfd.mru = Date.now();
|
|
1096
|
+
this.ensureMaxRetained();
|
|
1097
|
+
return data;
|
|
1098
|
+
}
|
|
1099
|
+
const failed = this.failedLoads.get(key);
|
|
1100
|
+
if (failed != null) {
|
|
1101
|
+
if (Date.now() < failed.retryAt) {
|
|
1102
|
+
this.stats.loadBackoffs++;
|
|
1103
|
+
throw failed.error;
|
|
672
1104
|
}
|
|
673
|
-
|
|
674
|
-
throw new sdk_1.WERR_INVALID_PARAMETER('sourceUrl', `data not found for sourceUrl ${url}`);
|
|
1105
|
+
this.failedLoads.delete(key);
|
|
675
1106
|
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
1107
|
+
const load = this.loadAndValidateData(bfd);
|
|
1108
|
+
this.inFlightLoads.set(key, load);
|
|
1109
|
+
try {
|
|
1110
|
+
const data = await load;
|
|
1111
|
+
bfd.data = data;
|
|
1112
|
+
bfd.validated = true;
|
|
1113
|
+
this.failedLoads.delete(key);
|
|
1114
|
+
bfd.mru = Date.now();
|
|
1115
|
+
this.ensureMaxRetained();
|
|
1116
|
+
return data;
|
|
683
1117
|
}
|
|
684
|
-
|
|
685
|
-
|
|
1118
|
+
catch (error) {
|
|
1119
|
+
const resolved = error instanceof Error ? error : new Error(String(error));
|
|
1120
|
+
this.failedLoads.set(key, { retryAt: Date.now() + this.failedLoadRetryMsecs, error: resolved });
|
|
1121
|
+
throw resolved;
|
|
1122
|
+
}
|
|
1123
|
+
finally {
|
|
1124
|
+
if (this.inFlightLoads.get(key) === load)
|
|
1125
|
+
this.inFlightLoads.delete(key);
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
async loadAndValidateData(bfd) {
|
|
1129
|
+
const stored = await this.loadFromStorage(bfd);
|
|
1130
|
+
if (stored != null)
|
|
1131
|
+
return stored;
|
|
1132
|
+
const cached = await this.loadFromCache(bfd);
|
|
1133
|
+
if (cached != null)
|
|
1134
|
+
return cached;
|
|
1135
|
+
const downloaded = await this.loadFromRemote(bfd);
|
|
1136
|
+
if (downloaded != null)
|
|
1137
|
+
return downloaded;
|
|
1138
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('data', `defined. Unable to retrieve data for ${bfd.fileName}`);
|
|
1139
|
+
}
|
|
1140
|
+
async loadFromStorage(bfd) {
|
|
1141
|
+
if (this.storage == null || !bfd.fileId)
|
|
1142
|
+
return undefined;
|
|
1143
|
+
const stored = await this.storage.getBulkFileData(bfd.fileId);
|
|
1144
|
+
if (stored == null) {
|
|
1145
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('fileId', `valid, data not found for fileId ${bfd.fileId}`);
|
|
1146
|
+
}
|
|
1147
|
+
const validated = await this.validateRetrievedData(bfd, stored);
|
|
1148
|
+
this.stats.storageHits++;
|
|
1149
|
+
return validated;
|
|
1150
|
+
}
|
|
1151
|
+
async loadFromCache(bfd) {
|
|
1152
|
+
if (this.cache == null)
|
|
1153
|
+
return undefined;
|
|
1154
|
+
const cached = await this.cache.get(bfd);
|
|
1155
|
+
if (cached == null) {
|
|
1156
|
+
this.stats.persistentCacheMisses++;
|
|
1157
|
+
return undefined;
|
|
1158
|
+
}
|
|
1159
|
+
try {
|
|
1160
|
+
const validated = await this.validateRetrievedData(bfd, cached);
|
|
1161
|
+
this.stats.persistentCacheHits++;
|
|
1162
|
+
await this.cache.promoteValidated?.(bfd, validated);
|
|
1163
|
+
return validated;
|
|
1164
|
+
}
|
|
1165
|
+
catch (error) {
|
|
1166
|
+
// Only deterministic rejection of these exact bytes may quarantine an
|
|
1167
|
+
// immutable cache object. Operational validation failures preserve it.
|
|
1168
|
+
if (!(error instanceof BulkFileDataValidatorApi_1.BulkFileDataValidationError))
|
|
1169
|
+
throw error;
|
|
1170
|
+
this.stats.persistentCacheRejects++;
|
|
1171
|
+
let rejectedData = error.data;
|
|
1172
|
+
if (!(rejectedData instanceof Uint8Array) && cached.byteLength > 0)
|
|
1173
|
+
rejectedData = cached;
|
|
1174
|
+
await this.cache.quarantine?.(bfd, String(error), rejectedData);
|
|
1175
|
+
this.log(`Rejected corrupt bulk-header cache entry ${bfd.fileName}: ${String(error)}`);
|
|
1176
|
+
return undefined;
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
async loadFromRemote(bfd) {
|
|
1180
|
+
if (this.fetch == null || !bfd.sourceUrl)
|
|
1181
|
+
return undefined;
|
|
1182
|
+
const expectedBytes = bfd.count * 80;
|
|
1183
|
+
await this.downloadBudget?.consume(expectedBytes);
|
|
1184
|
+
const url = this.fetch.pathJoin(bfd.sourceUrl, bfd.fileName);
|
|
1185
|
+
const downloaded = await this.fetch.download(url, expectedBytes, {
|
|
1186
|
+
publicNetworkOnly: true,
|
|
1187
|
+
beforeRetry: async () => await this.downloadBudget?.consume(expectedBytes)
|
|
1188
|
+
});
|
|
1189
|
+
if (downloaded == null) {
|
|
1190
|
+
throw new sdk_1.WERR_INVALID_PARAMETER('sourceUrl', `data not found for sourceUrl ${url}`);
|
|
1191
|
+
}
|
|
1192
|
+
const validated = await this.validateRetrievedData(bfd, downloaded);
|
|
1193
|
+
this.stats.downloads++;
|
|
1194
|
+
this.stats.downloadedBytes += validated.length;
|
|
1195
|
+
await this.cache?.set(bfd, validated);
|
|
1196
|
+
return validated;
|
|
1197
|
+
}
|
|
1198
|
+
async validateRetrievedData(bfd, data, expectedFileHash = bfd.fileHash) {
|
|
1199
|
+
const candidate = { ...bfd, data };
|
|
1200
|
+
const validated = await this.validateBfdHeaders(candidate, expectedFileHash);
|
|
1201
|
+
bfd.lastHash = candidate.lastHash;
|
|
1202
|
+
bfd.lastChainWork = candidate.lastChainWork;
|
|
1203
|
+
return validated;
|
|
686
1204
|
}
|
|
687
1205
|
ensureMaxRetained() {
|
|
688
1206
|
if (this.maxRetained === undefined)
|
|
@@ -700,6 +1218,19 @@ class BulkFileDataManager {
|
|
|
700
1218
|
}
|
|
701
1219
|
}
|
|
702
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
|
+
}
|
|
703
1234
|
const chain = this.chain;
|
|
704
1235
|
const toFileName = (i) => `${chain}Net_${i}.headers`;
|
|
705
1236
|
const toPath = (i) => toFs.pathJoin(toFolder, toFileName(i));
|
|
@@ -711,7 +1242,7 @@ class BulkFileDataManager {
|
|
|
711
1242
|
files: []
|
|
712
1243
|
};
|
|
713
1244
|
let range = await this.getHeightRange();
|
|
714
|
-
if (maxHeight)
|
|
1245
|
+
if (maxHeight !== undefined)
|
|
715
1246
|
range = range.intersect(new HeightRange_1.HeightRange(0, maxHeight));
|
|
716
1247
|
const reader = await this.createReader(range, toHeadersPerFile * 80);
|
|
717
1248
|
let firstHeight = 0;
|
|
@@ -724,17 +1255,24 @@ class BulkFileDataManager {
|
|
|
724
1255
|
if (data == null || data.length === 0) {
|
|
725
1256
|
break;
|
|
726
1257
|
}
|
|
727
|
-
const
|
|
728
|
-
|
|
729
|
-
|
|
1258
|
+
const validated = await this.validator.validate({
|
|
1259
|
+
fileName: toFileName(i),
|
|
1260
|
+
data,
|
|
1261
|
+
count: data.length / 80,
|
|
1262
|
+
firstHeight,
|
|
1263
|
+
prevHash: lastHeaderHash,
|
|
1264
|
+
prevChainWork: lastChainWork,
|
|
1265
|
+
chain
|
|
1266
|
+
});
|
|
1267
|
+
await toFs.writeFile(toPath(i), validated.data);
|
|
730
1268
|
const file = {
|
|
731
1269
|
chain,
|
|
732
|
-
count: data.length / 80,
|
|
733
|
-
fileHash,
|
|
1270
|
+
count: validated.data.length / 80,
|
|
1271
|
+
fileHash: validated.fileHash,
|
|
734
1272
|
fileName: toFileName(i),
|
|
735
1273
|
firstHeight,
|
|
736
|
-
lastChainWork:
|
|
737
|
-
lastHash:
|
|
1274
|
+
lastChainWork: validated.lastChainWork,
|
|
1275
|
+
lastHash: validated.lastHeaderHash,
|
|
738
1276
|
prevChainWork: lastChainWork,
|
|
739
1277
|
prevHash: lastHeaderHash,
|
|
740
1278
|
sourceUrl
|
|
@@ -746,15 +1284,44 @@ class BulkFileDataManager {
|
|
|
746
1284
|
}
|
|
747
1285
|
await toFs.writeFile(toJsonPath(), (0, utilityHelpers_noBuffer_1.asUint8Array)(JSON.stringify(toBulkFiles), 'utf8'));
|
|
748
1286
|
}
|
|
1287
|
+
async destroy() {
|
|
1288
|
+
await this.validator.destroy?.();
|
|
1289
|
+
}
|
|
749
1290
|
}
|
|
750
1291
|
exports.BulkFileDataManager = BulkFileDataManager;
|
|
1292
|
+
function snapshotBfd(file) {
|
|
1293
|
+
return { ...file, data: file.data };
|
|
1294
|
+
}
|
|
751
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
|
+
}
|
|
752
1321
|
const r = [];
|
|
753
1322
|
let height = 0;
|
|
754
|
-
|
|
755
|
-
const
|
|
756
|
-
// Pick the file with the maximum count
|
|
757
|
-
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);
|
|
758
1325
|
if (!choice)
|
|
759
1326
|
break; // no more files to select
|
|
760
1327
|
r.push(choice);
|
|
@@ -782,7 +1349,7 @@ function bfdToInfo(bfd, keepData) {
|
|
|
782
1349
|
prevHash: bfd.prevHash,
|
|
783
1350
|
lastHash: bfd.lastHash,
|
|
784
1351
|
validated: bfd.validated || false,
|
|
785
|
-
data: keepData ? bfd.data : undefined
|
|
1352
|
+
data: keepData && bfd.data != null ? Uint8Array.from(bfd.data) : undefined
|
|
786
1353
|
};
|
|
787
1354
|
}
|
|
788
1355
|
/**
|