@effectstream/midnight-contracts 0.100.22 → 0.100.24
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/package.json +2 -2
- package/src/get-wallet-info.ts +37 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effectstream/midnight-contracts",
|
|
3
|
-
"version": "0.100.
|
|
3
|
+
"version": "0.100.24",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://effectstream.github.io/docs/",
|
|
6
6
|
"repository": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"./types": "./src/types.ts"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@effectstream/utils": "0.100.
|
|
24
|
+
"@effectstream/utils": "0.100.24",
|
|
25
25
|
"@scure/bip39": "^2.0.1",
|
|
26
26
|
"dotenv": "^16.4.7",
|
|
27
27
|
"@midnight-ntwrk/zswap": "4.0.0",
|
package/src/get-wallet-info.ts
CHANGED
|
@@ -827,6 +827,42 @@ function buildShieldedWallet(config: DefaultConfiguration, seed: Uint8Array) {
|
|
|
827
827
|
return ShieldedWallet(config as any).startWithSeed(seed);
|
|
828
828
|
}
|
|
829
829
|
|
|
830
|
+
/**
|
|
831
|
+
* Sync batching tuning for the dust wallet.
|
|
832
|
+
*
|
|
833
|
+
* The wallet SDK's default sync settings (batch size 10, 1ms timeout, 4ms
|
|
834
|
+
* spacing) are tuned to keep a browser UI responsive — they emit many small
|
|
835
|
+
* state snapshots and throttle 4ms between every batch. In a headless backend
|
|
836
|
+
* (e.g. the batcher's fee wallets) that is wasteful: it slows initial sync and
|
|
837
|
+
* produces a lot of short-lived intermediate state, inflating memory churn.
|
|
838
|
+
*
|
|
839
|
+
* We collect larger batches (fewer intermediate snapshots) with minimal
|
|
840
|
+
* spacing. Spacing is kept >0 because the batcher syncs on the main event loop
|
|
841
|
+
* rather than in a worker — spacing 0 would starve other work during the
|
|
842
|
+
* initial catch-up sync.
|
|
843
|
+
*
|
|
844
|
+
* NOTE: `batchUpdates` is only honoured by `wallet-sdk-dust-wallet >= 4.0.0`.
|
|
845
|
+
* On the currently-pinned 3.0.0 these values are ignored unless the package is
|
|
846
|
+
* patched (see patches/). Plumbing them here is harmless on 3.0.0.
|
|
847
|
+
*/
|
|
848
|
+
function resolveDustBatchUpdates(): {
|
|
849
|
+
size: number;
|
|
850
|
+
timeout: number;
|
|
851
|
+
spacing: number;
|
|
852
|
+
} {
|
|
853
|
+
const num = (name: string, fallback: number): number => {
|
|
854
|
+
const raw = getEnv(name);
|
|
855
|
+
if (raw == null || raw === "") return fallback;
|
|
856
|
+
const parsed = Number(raw);
|
|
857
|
+
return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback;
|
|
858
|
+
};
|
|
859
|
+
return {
|
|
860
|
+
size: num("MIDNIGHT_DUST_SYNC_BATCH_SIZE", 100),
|
|
861
|
+
timeout: num("MIDNIGHT_DUST_SYNC_BATCH_TIMEOUT_MS", 1),
|
|
862
|
+
spacing: num("MIDNIGHT_DUST_SYNC_BATCH_SPACING_MS", 1),
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
|
|
830
866
|
function buildDustWallet(
|
|
831
867
|
config: DefaultConfiguration,
|
|
832
868
|
seed: Uint8Array,
|
|
@@ -834,6 +870,7 @@ function buildDustWallet(
|
|
|
834
870
|
) {
|
|
835
871
|
const dustConfig = {
|
|
836
872
|
...config,
|
|
873
|
+
batchUpdates: resolveDustBatchUpdates(),
|
|
837
874
|
costParameters: {
|
|
838
875
|
ledgerParams: LedgerParameters.initialParameters(),
|
|
839
876
|
additionalFeeOverhead: CONSTANTS.DUST_FEE_OVERHEAD,
|