@dignetwork/dig-sdk 0.0.1-alpha.5 → 0.0.1-alpha.52

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.
Files changed (53) hide show
  1. package/dist/DataIntegrityTree/DataIntegrityTree.d.ts +2 -2
  2. package/dist/DataIntegrityTree/DataIntegrityTree.d.ts.map +1 -1
  3. package/dist/DataIntegrityTree/DataIntegrityTree.js +83 -29
  4. package/dist/DigNetwork/ContentServer.d.ts +6 -1
  5. package/dist/DigNetwork/ContentServer.d.ts.map +1 -1
  6. package/dist/DigNetwork/ContentServer.js +40 -16
  7. package/dist/DigNetwork/DigNetwork.d.ts +2 -5
  8. package/dist/DigNetwork/DigNetwork.d.ts.map +1 -1
  9. package/dist/DigNetwork/DigNetwork.js +119 -155
  10. package/dist/DigNetwork/DigPeer.d.ts +8 -3
  11. package/dist/DigNetwork/DigPeer.d.ts.map +1 -1
  12. package/dist/DigNetwork/DigPeer.js +116 -114
  13. package/dist/DigNetwork/PropagationServer.d.ts +8 -2
  14. package/dist/DigNetwork/PropagationServer.d.ts.map +1 -1
  15. package/dist/DigNetwork/PropagationServer.js +110 -75
  16. package/dist/blockchain/DataStore.d.ts +1 -4
  17. package/dist/blockchain/DataStore.d.ts.map +1 -1
  18. package/dist/blockchain/DataStore.js +5 -83
  19. package/dist/blockchain/DataStoreSerializer.d.ts +1 -1
  20. package/dist/blockchain/DataStoreSerializer.d.ts.map +1 -1
  21. package/dist/blockchain/FullNodePeer.d.ts +9 -1
  22. package/dist/blockchain/FullNodePeer.d.ts.map +1 -1
  23. package/dist/blockchain/FullNodePeer.js +60 -14
  24. package/dist/blockchain/ServerCoin.d.ts +11 -3
  25. package/dist/blockchain/ServerCoin.d.ts.map +1 -1
  26. package/dist/blockchain/ServerCoin.js +45 -17
  27. package/dist/blockchain/Wallet.d.ts +1 -1
  28. package/dist/blockchain/Wallet.d.ts.map +1 -1
  29. package/dist/blockchain/Wallet.js +1 -1
  30. package/dist/blockchain/coins.d.ts +1 -1
  31. package/dist/blockchain/coins.d.ts.map +1 -1
  32. package/dist/blockchain/coins.js +1 -1
  33. package/dist/types.d.ts +1 -0
  34. package/dist/types.d.ts.map +1 -1
  35. package/dist/utils/FileTransfer.d.ts +47 -0
  36. package/dist/utils/FileTransfer.d.ts.map +1 -0
  37. package/dist/utils/FileTransfer.js +209 -0
  38. package/dist/utils/StoreArchiveManager.d.ts +45 -0
  39. package/dist/utils/StoreArchiveManager.d.ts.map +1 -0
  40. package/dist/utils/StoreArchiveManager.js +153 -0
  41. package/dist/utils/config.d.ts +0 -1
  42. package/dist/utils/config.d.ts.map +1 -1
  43. package/dist/utils/config.js +5 -12
  44. package/dist/utils/directoryUtils.d.ts +0 -6
  45. package/dist/utils/directoryUtils.d.ts.map +1 -1
  46. package/dist/utils/directoryUtils.js +30 -11
  47. package/dist/utils/index.d.ts +0 -1
  48. package/dist/utils/index.d.ts.map +1 -1
  49. package/dist/utils/index.js +0 -1
  50. package/package.json +9 -3
  51. package/dist/utils/deltaUtils.d.ts +0 -2
  52. package/dist/utils/deltaUtils.d.ts.map +0 -1
  53. package/dist/utils/deltaUtils.js +0 -83
@@ -1,4 +1,4 @@
1
- import { ServerCoin as ServerCoinDriver } from "datalayer-driver";
1
+ import { ServerCoin as ServerCoinDriver } from "@dignetwork/datalayer-driver";
2
2
  import { NconfManager } from "../utils/NconfManager";
3
3
  export declare class ServerCoin {
4
4
  private storeId;
@@ -8,14 +8,22 @@ export declare class ServerCoin {
8
8
  saveServerCoinData(serverCoin: ServerCoinDriver, epoch: number, peerIp: string): Promise<void>;
9
9
  melt(epoch: number, peerIp: string): Promise<void>;
10
10
  private removeServerCoinData;
11
+ getAllEpochPeers(epoch: number, blacklist?: string[]): Promise<string[]>;
12
+ getActiveEpochPeers(blacklist?: string[]): Promise<string[]>;
11
13
  sampleCurrentEpoch(sampleSize?: number, blacklist?: string[]): Promise<string[]>;
12
14
  sampleServerCoinsByEpoch(epoch: number, sampleSize?: number, blacklist?: string[]): Promise<string[]>;
13
- static getCurrentEpoch(): number;
15
+ static getCurrentEpoch(): {
16
+ epoch: number;
17
+ round: number;
18
+ };
14
19
  ensureServerCoinExists(peerIp: string): Promise<void>;
15
20
  meltOutdatedEpochs(peerIp: string): Promise<void>;
16
21
  static meltUntrackedStoreCoins(): Promise<void>;
17
22
  private getServerCoinsForStore;
18
23
  hasEpochCoinBeenCreated(currentEpoch: number, peerIp: string): Promise<boolean>;
19
- static calculateEpoch(currentTimestampUTC: Date): number;
24
+ static calculateEpochAndRound(currentTimestampUTC: Date): {
25
+ epoch: number;
26
+ round: number;
27
+ };
20
28
  }
21
29
  //# sourceMappingURL=ServerCoin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ServerCoin.d.ts","sourceRoot":"","sources":["../../src/blockchain/ServerCoin.ts"],"names":[],"mappings":"AACA,OAAO,EAML,UAAU,IAAI,gBAAgB,EAE/B,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAMrD,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAS;IACxB,gBAAuB,iBAAiB,eAAwC;gBAGpE,OAAO,EAAE,MAAM;IAKd,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA2DzD,kBAAkB,CAC7B,UAAU,EAAE,gBAAgB,EAC5B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC;IAqBH,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAoDjD,oBAAoB;IAgBrB,kBAAkB,CAC7B,UAAU,GAAE,MAAU,EACtB,SAAS,GAAE,MAAM,EAAO,GACvB,OAAO,CAAC,MAAM,EAAE,CAAC;IAMP,wBAAwB,CACnC,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAU,E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,UAAU,GAAE,MAAU,EACtB,SAAS,GAAE,MAAM,EAAO,GACvB,OAAO,CAAC,MAAM,EAAE,CAAC;IAMP,wBAAwB,CACnC,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAU,EACtB,SAAS,GAAE,MAAM,EAAO,GACvB,OAAO,CAAC,MAAM,EAAE,CAAC;WASN,eAAe,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAKpD,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiDrD,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WA+B1C,uBAAuB;YAkE7B,sBAAsB;IAWvB,uBAAuB,CAClC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC;WAuBL,sBAAsB,CAAC,mBAAmB,EAAE,IAAI,GAAG;QAC/D,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf;CA2BF"}
@@ -5,13 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ServerCoin = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
- const datalayer_driver_1 = require("datalayer-driver");
8
+ const datalayer_driver_1 = require("@dignetwork/datalayer-driver");
9
9
  const FullNodePeer_1 = require("./FullNodePeer");
10
10
  const coins_1 = require("./coins");
11
11
  const Wallet_1 = require("./Wallet");
12
12
  const NconfManager_1 = require("../utils/NconfManager");
13
13
  const DataStore_1 = require("./DataStore");
14
+ const node_cache_1 = __importDefault(require("node-cache"));
14
15
  const serverCoinCollateral = 300000000;
16
+ // Initialize the cache with a TTL of 300 seconds (5 minutes)
17
+ const serverCoinPeersCache = new node_cache_1.default({ stdTTL: 300 });
15
18
  class ServerCoin {
16
19
  constructor(storeId) {
17
20
  this.storeId = storeId;
@@ -23,7 +26,7 @@ class ServerCoin {
23
26
  const wallet = await Wallet_1.Wallet.load("default");
24
27
  const publicSyntheticKey = await wallet.getPublicSyntheticKey();
25
28
  const serverCoinCreationCoins = await (0, coins_1.selectUnspentCoins)(peer, BigInt(serverCoinCollateral), BigInt(1000000));
26
- const currentEpoch = ServerCoin.getCurrentEpoch();
29
+ const { epoch: currentEpoch } = ServerCoin.getCurrentEpoch();
27
30
  const epochBasedHint = (0, datalayer_driver_1.morphLauncherId)(Buffer.from(this.storeId, "hex"), BigInt(currentEpoch));
28
31
  const newServerCoin = (0, datalayer_driver_1.createServerCoin)(publicSyntheticKey, serverCoinCreationCoins, epochBasedHint, [peerIp], BigInt(serverCoinCollateral), BigInt(1000000));
29
32
  const combinedCoinSpends = [...newServerCoin.coinSpends];
@@ -94,13 +97,13 @@ class ServerCoin {
94
97
  serverCoins = serverCoins.filter((coin) => coin.coin.parentCoinInfo !== serverCoin.parentCoinInfo);
95
98
  await ServerCoin.serverCoinManager.setConfigValue(`${this.storeId}:${peerIp}`, serverCoins);
96
99
  }
97
- // Sample server coins for the current epoch
98
- async sampleCurrentEpoch(sampleSize = 5, blacklist = []) {
99
- const epoch = ServerCoin.getCurrentEpoch();
100
- return this.sampleServerCoinsByEpoch(epoch, sampleSize, blacklist);
101
- }
102
- // Sample server coins by epoch
103
- async sampleServerCoinsByEpoch(epoch, sampleSize = 5, blacklist = []) {
100
+ async getAllEpochPeers(epoch, blacklist = []) {
101
+ const cacheKey = `serverCoinPeers-${this.storeId}-${epoch}`;
102
+ // Check if the result is already cached
103
+ const cachedPeers = serverCoinPeersCache.get(cacheKey);
104
+ if (cachedPeers) {
105
+ return cachedPeers;
106
+ }
104
107
  const epochBasedHint = (0, datalayer_driver_1.morphLauncherId)(Buffer.from(this.storeId, "hex"), BigInt(epoch));
105
108
  const peer = await FullNodePeer_1.FullNodePeer.connect();
106
109
  const maxClvmCost = BigInt(11000000000);
@@ -118,18 +121,37 @@ class ServerCoin {
118
121
  if (process.env.DIG_DEBUG === "1") {
119
122
  console.log("Server Coin Peers: ", serverCoinPeers);
120
123
  }
121
- // Convert the Set back to an array if needed
122
- return lodash_1.default.sampleSize(Array.from(serverCoinPeers), sampleSize);
124
+ const peerList = Array.from(serverCoinPeers);
125
+ // Cache the result
126
+ serverCoinPeersCache.set(cacheKey, peerList);
127
+ return peerList;
128
+ }
129
+ async getActiveEpochPeers(blacklist = []) {
130
+ const { epoch } = ServerCoin.getCurrentEpoch();
131
+ return this.getAllEpochPeers(epoch, blacklist);
132
+ }
133
+ // Sample server coins for the current epoch
134
+ async sampleCurrentEpoch(sampleSize = 5, blacklist = []) {
135
+ const { epoch } = ServerCoin.getCurrentEpoch();
136
+ return this.sampleServerCoinsByEpoch(epoch, sampleSize, blacklist);
137
+ }
138
+ // Sample server coins by epoch
139
+ async sampleServerCoinsByEpoch(epoch, sampleSize = 5, blacklist = []) {
140
+ const serverCoinPeers = await this.getAllEpochPeers(epoch, blacklist);
141
+ if (process.env.DIG_DEBUG === "1") {
142
+ console.log("Server Coin Peers: ", serverCoinPeers);
143
+ }
144
+ return lodash_1.default.sampleSize(serverCoinPeers, sampleSize);
123
145
  }
124
146
  // Get the current epoch based on the current timestamp
125
147
  static getCurrentEpoch() {
126
- return ServerCoin.calculateEpoch(new Date());
148
+ return ServerCoin.calculateEpochAndRound(new Date());
127
149
  }
128
150
  // Ensure server coin exists for the current epoch
129
151
  async ensureServerCoinExists(peerIp) {
130
152
  try {
131
153
  console.log(`Ensuring server coin exists for store ${this.storeId}...`);
132
- const currentEpoch = ServerCoin.getCurrentEpoch();
154
+ const { epoch: currentEpoch } = ServerCoin.getCurrentEpoch();
133
155
  const serverCoins = await this.getServerCoinsForStore(peerIp);
134
156
  // Check if a server coin already exists for the current epoch
135
157
  const existingCoin = serverCoins.find((coin) => coin.epoch === currentEpoch);
@@ -160,7 +182,7 @@ class ServerCoin {
160
182
  // Melt outdated server coins
161
183
  async meltOutdatedEpochs(peerIp) {
162
184
  try {
163
- const currentEpoch = ServerCoin.getCurrentEpoch();
185
+ const { epoch: currentEpoch } = ServerCoin.getCurrentEpoch();
164
186
  let serverCoins = await this.getServerCoinsForStore(peerIp);
165
187
  // Filter out coins that are not in the current epoch
166
188
  const outdatedCoins = serverCoins.filter((coin) => coin.epoch < currentEpoch);
@@ -244,17 +266,23 @@ class ServerCoin {
244
266
  }
245
267
  }
246
268
  // Static method to calculate the current epoch
247
- static calculateEpoch(currentTimestampUTC) {
269
+ static calculateEpochAndRound(currentTimestampUTC) {
248
270
  const firstEpochStart = new Date(Date.UTC(2024, 8, 3, 0, 0)); // Sept 3, 2024, 00:00 UTC
249
271
  // Convert the current timestamp to milliseconds
250
272
  const currentTimestampMillis = currentTimestampUTC.getTime();
251
273
  // Calculate the number of milliseconds in one epoch (7 days)
252
- const millisecondsInEpoch = 7 * 24 * 60 * 60 * 1000;
274
+ const millisecondsInEpoch = 7 * 24 * 60 * 60 * 1000; // 7 days in milliseconds
253
275
  // Calculate the difference in milliseconds between the current timestamp and the first epoch start
254
276
  const differenceMillis = currentTimestampMillis - firstEpochStart.getTime();
255
277
  // Calculate the current epoch number
256
278
  const epochNumber = Math.floor(differenceMillis / millisecondsInEpoch) + 1;
257
- return epochNumber;
279
+ // Calculate the milliseconds elapsed since the start of the current epoch
280
+ const elapsedMillisInCurrentEpoch = differenceMillis % millisecondsInEpoch;
281
+ // Calculate the number of milliseconds in a round (10 minutes)
282
+ const millisecondsInRound = 10 * 60 * 1000; // 10 minutes in milliseconds
283
+ // Calculate the current round number
284
+ const roundNumber = Math.floor(elapsedMillisInCurrentEpoch / millisecondsInRound) + 1;
285
+ return { epoch: epochNumber, round: roundNumber };
258
286
  }
259
287
  }
260
288
  exports.ServerCoin = ServerCoin;
@@ -1,5 +1,5 @@
1
1
  import { Buffer } from "buffer";
2
- import { Peer, Coin, CoinSpend } from "datalayer-driver";
2
+ import { Peer, Coin, CoinSpend } from "@dignetwork/datalayer-driver";
3
3
  export declare const DEFAULT_FEE_COIN_COST = 64000000;
4
4
  export declare class Wallet {
5
5
  private mnemonic;
@@ -1 +1 @@
1
- {"version":3,"file":"Wallet.d.ts","sourceRoot":"","sources":["../../src/blockchain/Wallet.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EASL,IAAI,EACJ,IAAI,EAEJ,SAAS,EAEV,MAAM,kBAAkB,CAAC;AAM1B,eAAO,MAAM,qBAAqB,WAAa,CAAC;AAOhD,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO;WAKa,IAAI,CACtB,UAAU,GAAE,MAAkB,EAC9B,iBAAiB,GAAE,OAAc,GAChC,OAAO,CAAC,MAAM,CAAC;IAsBX,WAAW,IAAI,MAAM;WAOR,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAMpD,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAShE,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA6BhE,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAKrC,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC;IAMxC,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC;IAKzC,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAMrC,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;WAK7B,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WASlD,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;mBAU/B,oBAAoB;mBAWpB,mBAAmB;IAM3B,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO3D,2BAA2B,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AAC,MAAM,CAAC;IAMxC,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC;IAKzC,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAMrC,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;WAK7B,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WASlD,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;mBAU/B,oBAAoB;mBAWpB,mBAAmB;IAM3B,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO3D,2BAA2B,CACtC,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,CAAC;IASN,kBAAkB,CAC7B,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,SAAS,GAAE,IAAI,EAAO,GACrB,OAAO,CAAC,IAAI,EAAE,CAAC;WAwCE,yBAAyB,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;WAItF,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAOlF"}
@@ -38,7 +38,7 @@ const chia_root_resolver_1 = require("chia-root-resolver");
38
38
  const chia_config_loader_1 = require("chia-config-loader");
39
39
  const encryption_1 = require("../utils/encryption");
40
40
  const buffer_1 = require("buffer");
41
- const datalayer_driver_1 = require("datalayer-driver");
41
+ const datalayer_driver_1 = require("@dignetwork/datalayer-driver");
42
42
  const config_1 = require("../utils/config");
43
43
  const FileCache_1 = require("../utils/FileCache");
44
44
  const KEYRING_FILE = "keyring.json";
@@ -1,4 +1,4 @@
1
- import { Peer, Coin, CoinSpend } from "datalayer-driver";
1
+ import { Peer, Coin, CoinSpend } from "@dignetwork/datalayer-driver";
2
2
  export declare const DEFAULT_FEE_COIN_COST = 64000000;
3
3
  export declare const calculateFeeForCoinSpends: (peer: Peer, coinSpends: CoinSpend[] | null) => Promise<bigint>;
4
4
  export declare const selectUnspentCoins: (peer: Peer, coinAmount: bigint, feeBigInt: bigint, omitCoins?: Coin[], walletName?: string) => Promise<Coin[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"coins.d.ts","sourceRoot":"","sources":["../../src/blockchain/coins.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,IAAI,EACJ,IAAI,EAEJ,SAAS,EAEV,MAAM,kBAAkB,CAAC;AAK1B,eAAO,MAAM,qBAAqB,WAAa,CAAC;AAWhD,eAAO,MAAM,yBAAyB,SAC9B,IAAI,cACE,SAAS,EAAE,GAAG,IAAI,KAC7B,OAAO,CAAC,MAAM,CA4BhB,CAAC;AAEF,eAAO,MAAM,kBAAkB,SACvB,IAAI,cACE,MAAM,aACP,MAAM,cACN,IAAI,EAAE,eACL,MAAM,KACjB,OAAO,CAAC,IAAI,EAAE,CAoEhB,CAAC;AAGF,eAAO,MAAM,eAAe,SACpB,IAAI,UACF,MAAM,KACb,OAAO,CAAC,OAAO,CAWjB,CAAC"}
1
+ {"version":3,"file":"coins.d.ts","sourceRoot":"","sources":["../../src/blockchain/coins.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,IAAI,EACJ,IAAI,EAEJ,SAAS,EAEV,MAAM,8BAA8B,CAAC;AAKtC,eAAO,MAAM,qBAAqB,WAAa,CAAC;AAWhD,eAAO,MAAM,yBAAyB,SAC9B,IAAI,cACE,SAAS,EAAE,GAAG,IAAI,KAC7B,OAAO,CAAC,MAAM,CA4BhB,CAAC;AAEF,eAAO,MAAM,kBAAkB,SACvB,IAAI,cACE,MAAM,aACP,MAAM,cACN,IAAI,EAAE,eACL,MAAM,KACjB,OAAO,CAAC,IAAI,EAAE,CAoEhB,CAAC;AAGF,eAAO,MAAM,eAAe,SACpB,IAAI,UACF,MAAM,KACb,OAAO,CAAC,OAAO,CAWjB,CAAC"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isCoinSpendable = exports.selectUnspentCoins = exports.calculateFeeForCoinSpends = exports.DEFAULT_FEE_COIN_COST = void 0;
4
- const datalayer_driver_1 = require("datalayer-driver");
4
+ const datalayer_driver_1 = require("@dignetwork/datalayer-driver");
5
5
  const Wallet_1 = require("./Wallet");
6
6
  const config_1 = require("../utils/config");
7
7
  const FileCache_1 = require("../utils/FileCache");
package/dist/types.d.ts CHANGED
@@ -23,6 +23,7 @@ export interface DigConfig {
23
23
  export interface RootHistoryItem {
24
24
  root_hash: string;
25
25
  timestamp: Number | undefined;
26
+ synced: boolean;
26
27
  }
27
28
  export interface DatFile {
28
29
  root: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,MAAM;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,S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5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,cAAc,CAAC;CAC9B"}
@@ -0,0 +1,47 @@
1
+ import { Readable } from "stream";
2
+ export declare class FileTransfer {
3
+ private static certPath;
4
+ private static keyPath;
5
+ constructor();
6
+ /** ------------------------ UPLOAD FUNCTIONALITY ------------------------ **/
7
+ /**
8
+ * Upload a file to the server using a stream.
9
+ * @param filePath - Local path of the file.
10
+ * @param uploadUrl - Server URL to upload the file.
11
+ * @param headers - Additional headers for the request.
12
+ * @returns Promise<void>
13
+ */
14
+ uploadFile(filePath: string, uploadUrl: string, headers: Record<string, string>): Promise<void>;
15
+ /**
16
+ * Perform a POST request.
17
+ * @param url - The URL to POST to.
18
+ * @param data - Data to send.
19
+ * @param headers - Headers for the POST request.
20
+ * @returns Promise<void>
21
+ */
22
+ postRequest(url: string, data: string, headers: Record<string, string>): Promise<void>;
23
+ /** ------------------------ DOWNLOAD FUNCTIONALITY ------------------------ **/
24
+ /**
25
+ * Download data from a URL.
26
+ * @param url - The URL to download data from.
27
+ * @returns Promise<string>
28
+ */
29
+ downloadData(url: string): Promise<string>;
30
+ /**
31
+ * Stream data from a URL.
32
+ * @param url - The URL to stream data from.
33
+ * @returns Promise<Readable>
34
+ */
35
+ streamData(url: string): Promise<Readable>;
36
+ /** ------------------------ HEAD REQUEST FUNCTIONALITY ------------------------ **/
37
+ /**
38
+ * Perform a HEAD request to check if a resource exists on the server.
39
+ * @param url - The URL to check.
40
+ * @returns Promise<{ success: boolean; headers?: Record<string, string> }>
41
+ */
42
+ headRequest(url: string): Promise<{
43
+ success: boolean;
44
+ headers?: Record<string, string>;
45
+ }>;
46
+ }
47
+ //# sourceMappingURL=FileTransfer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileTransfer.d.ts","sourceRoot":"","sources":["../../src/utils/FileTransfer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAChC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAS;;IAU/B,8EAA8E;IAE9E;;;;;;OAMG;IACU,UAAU,CACrB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,OAAO,CAAC,IAAI,CAAC;IA0ChB;;;;;;OAMG;IACU,WAAW,CACtB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,OAAO,CAAC,IAAI,CAAC;IAsChB,gFAAgF;IAEhF;;;;OAIG;IACU,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA0CvD;;;;OAIG;IACU,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAuCvD,oFAAoF;IAEpF;;;;OAIG;IACU,WAAW,CACtB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;CA8BnE"}
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FileTransfer = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const https_1 = __importDefault(require("https"));
9
+ const url_1 = require("url");
10
+ const ssl_1 = require("../utils/ssl");
11
+ class FileTransfer {
12
+ constructor() {
13
+ if (!FileTransfer.certPath || !FileTransfer.keyPath) {
14
+ const { certPath, keyPath } = (0, ssl_1.getOrCreateSSLCerts)();
15
+ FileTransfer.certPath = certPath;
16
+ FileTransfer.keyPath = keyPath;
17
+ }
18
+ }
19
+ /** ------------------------ UPLOAD FUNCTIONALITY ------------------------ **/
20
+ /**
21
+ * Upload a file to the server using a stream.
22
+ * @param filePath - Local path of the file.
23
+ * @param uploadUrl - Server URL to upload the file.
24
+ * @param headers - Additional headers for the request.
25
+ * @returns Promise<void>
26
+ */
27
+ async uploadFile(filePath, uploadUrl, headers) {
28
+ const fileStream = fs_1.default.createReadStream(filePath);
29
+ const fileSize = fs_1.default.statSync(filePath).size;
30
+ return new Promise((resolve, reject) => {
31
+ const url = new url_1.URL(uploadUrl);
32
+ const options = {
33
+ hostname: url.hostname,
34
+ port: url.port || 443,
35
+ path: url.pathname,
36
+ method: "PUT",
37
+ headers: {
38
+ ...headers,
39
+ "Content-Type": "application/octet-stream",
40
+ "Content-Length": fileSize,
41
+ },
42
+ key: fs_1.default.readFileSync(FileTransfer.keyPath),
43
+ cert: fs_1.default.readFileSync(FileTransfer.certPath),
44
+ rejectUnauthorized: false,
45
+ };
46
+ const req = https_1.default.request(options, (res) => {
47
+ if (res.statusCode === 200) {
48
+ resolve();
49
+ }
50
+ else {
51
+ reject(new Error(`Upload failed with status ${res.statusCode}: ${res.statusMessage}`));
52
+ }
53
+ });
54
+ req.on("error", (err) => reject(err));
55
+ fileStream.pipe(req);
56
+ fileStream.on("error", (err) => reject(err));
57
+ });
58
+ }
59
+ /**
60
+ * Perform a POST request.
61
+ * @param url - The URL to POST to.
62
+ * @param data - Data to send.
63
+ * @param headers - Headers for the POST request.
64
+ * @returns Promise<void>
65
+ */
66
+ async postRequest(url, data, headers) {
67
+ return new Promise((resolve, reject) => {
68
+ const urlObj = new url_1.URL(url);
69
+ const options = {
70
+ hostname: urlObj.hostname,
71
+ port: urlObj.port || 443,
72
+ path: urlObj.pathname,
73
+ method: "POST",
74
+ headers: {
75
+ ...headers,
76
+ "Content-Type": "application/json",
77
+ "Content-Length": Buffer.byteLength(data),
78
+ },
79
+ key: fs_1.default.readFileSync(FileTransfer.keyPath),
80
+ cert: fs_1.default.readFileSync(FileTransfer.certPath),
81
+ rejectUnauthorized: false,
82
+ };
83
+ const req = https_1.default.request(options, (res) => {
84
+ if (res.statusCode === 200) {
85
+ resolve();
86
+ }
87
+ else {
88
+ reject(new Error(`POST request failed with status ${res.statusCode}: ${res.statusMessage}`));
89
+ }
90
+ });
91
+ req.on("error", (err) => reject(err));
92
+ req.write(data);
93
+ req.end();
94
+ });
95
+ }
96
+ /** ------------------------ DOWNLOAD FUNCTIONALITY ------------------------ **/
97
+ /**
98
+ * Download data from a URL.
99
+ * @param url - The URL to download data from.
100
+ * @returns Promise<string>
101
+ */
102
+ async downloadData(url) {
103
+ return new Promise((resolve, reject) => {
104
+ const urlObj = new url_1.URL(url);
105
+ const options = {
106
+ hostname: urlObj.hostname,
107
+ port: urlObj.port || 443,
108
+ path: urlObj.pathname + urlObj.search,
109
+ method: "GET",
110
+ key: fs_1.default.readFileSync(FileTransfer.keyPath),
111
+ cert: fs_1.default.readFileSync(FileTransfer.certPath),
112
+ rejectUnauthorized: false,
113
+ };
114
+ const req = https_1.default.request(options, (res) => {
115
+ let data = "";
116
+ if (res.statusCode === 200) {
117
+ res.on("data", (chunk) => (data += chunk));
118
+ res.on("end", () => resolve(data));
119
+ }
120
+ else if (res.statusCode === 301 || res.statusCode === 302) {
121
+ const redirectUrl = res.headers.location;
122
+ if (redirectUrl) {
123
+ this.downloadData(redirectUrl).then(resolve).catch(reject);
124
+ }
125
+ else {
126
+ reject(new Error("Redirected without a location header"));
127
+ }
128
+ }
129
+ else {
130
+ reject(new Error(`Failed to retrieve data from ${url}. Status code: ${res.statusCode}`));
131
+ }
132
+ });
133
+ req.on("error", (error) => reject(error));
134
+ req.end();
135
+ });
136
+ }
137
+ /**
138
+ * Stream data from a URL.
139
+ * @param url - The URL to stream data from.
140
+ * @returns Promise<Readable>
141
+ */
142
+ async streamData(url) {
143
+ return new Promise((resolve, reject) => {
144
+ const urlObj = new url_1.URL(url);
145
+ const options = {
146
+ hostname: urlObj.hostname,
147
+ port: urlObj.port || 443,
148
+ path: urlObj.pathname + urlObj.search,
149
+ method: "GET",
150
+ key: fs_1.default.readFileSync(FileTransfer.keyPath),
151
+ cert: fs_1.default.readFileSync(FileTransfer.certPath),
152
+ rejectUnauthorized: false,
153
+ };
154
+ const req = https_1.default.request(options, (res) => {
155
+ if (res.statusCode === 200) {
156
+ resolve(res); // Return the readable stream
157
+ }
158
+ else if (res.statusCode === 301 || res.statusCode === 302) {
159
+ const redirectUrl = res.headers.location;
160
+ if (redirectUrl) {
161
+ this.streamData(redirectUrl).then(resolve).catch(reject);
162
+ }
163
+ else {
164
+ reject(new Error("Redirected without a location header"));
165
+ }
166
+ }
167
+ else {
168
+ reject(new Error(`Failed to retrieve stream from ${url}. Status code: ${res.statusCode}`));
169
+ }
170
+ });
171
+ req.on("error", (error) => reject(error));
172
+ req.end();
173
+ });
174
+ }
175
+ /** ------------------------ HEAD REQUEST FUNCTIONALITY ------------------------ **/
176
+ /**
177
+ * Perform a HEAD request to check if a resource exists on the server.
178
+ * @param url - The URL to check.
179
+ * @returns Promise<{ success: boolean; headers?: Record<string, string> }>
180
+ */
181
+ async headRequest(url) {
182
+ return new Promise((resolve, reject) => {
183
+ const urlObj = new url_1.URL(url);
184
+ const options = {
185
+ hostname: urlObj.hostname,
186
+ port: urlObj.port || 443,
187
+ path: urlObj.pathname,
188
+ method: "HEAD",
189
+ key: fs_1.default.readFileSync(FileTransfer.keyPath),
190
+ cert: fs_1.default.readFileSync(FileTransfer.certPath),
191
+ rejectUnauthorized: false,
192
+ };
193
+ const req = https_1.default.request(options, (res) => {
194
+ if (res.statusCode === 200) {
195
+ resolve({
196
+ success: true,
197
+ headers: res.headers,
198
+ });
199
+ }
200
+ else {
201
+ resolve({ success: false });
202
+ }
203
+ });
204
+ req.on("error", (err) => reject(err));
205
+ req.end();
206
+ });
207
+ }
208
+ }
209
+ exports.FileTransfer = FileTransfer;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Class for managing file archiving, extraction, and working with the 'data' folder.
3
+ */
4
+ declare class StoreArchiveManager {
5
+ private archivePath;
6
+ private outputStream;
7
+ /**
8
+ * Constructor that initializes the FileArchiveManager with a given path.
9
+ * @param archivePath - The path where the archive will be created.
10
+ */
11
+ constructor(archivePath: string);
12
+ /**
13
+ * Creates the archive at the specified path.
14
+ * @returns Promise<void>
15
+ */
16
+ createArchive(): Promise<void>;
17
+ /**
18
+ * Streams a file into the archive.
19
+ * @param filePath - The file to add to the archive.
20
+ * @param fileNameInArchive - The name the file should have inside the archive.
21
+ * @returns Promise<void>
22
+ */
23
+ addFileToArchive(filePath: string, fileNameInArchive: string): Promise<void>;
24
+ /**
25
+ * Extracts a file from the archive to a specified directory.
26
+ * @param extractToPath - The path where the file should be extracted.
27
+ * @returns Promise<void>
28
+ */
29
+ extractArchive(extractToPath: string): Promise<void>;
30
+ /**
31
+ * Merges another archive into the current one.
32
+ * Extracts files from the given archive and adds them into the current archive.
33
+ * @param archiveToMergePath - The path of the archive to be merged.
34
+ * @returns Promise<void>
35
+ */
36
+ mergeArchive(archiveToMergePath: string): Promise<void>;
37
+ /**
38
+ * Adds extracted files to the current archive.
39
+ * @param extractedFolderPath - The path of the folder containing extracted files.
40
+ * @returns Promise<void>
41
+ */
42
+ private addExtractedFilesToArchive;
43
+ }
44
+ export default StoreArchiveManager;
45
+ //# sourceMappingURL=StoreArchiveManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StoreArchiveManager.d.ts","sourceRoot":"","sources":["../../src/utils/StoreArchiveManager.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,cAAM,mBAAmB;IACrB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,YAAY,CAAwB;IAE5C;;;OAGG;gBACS,WAAW,EAAE,MAAM;IAK/B;;;OAGG;IACU,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB3C;;;;;OAKG;IACU,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBzF;;;;OAIG;IACU,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASjE;;;;;OAKG;IACU,YAAY,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiCpE;;;;OAIG;YACW,0BAA0B;CAkB3C;AAED,eAAe,mBAAmB,CAAC"}