diff --git a/CHANGELOG.md b/CHANGELOG.md index b050d11..85c5536 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [0.0.1-alpha.174](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.173...v0.0.1-alpha.174) (2024-10-26) + ### [0.0.1-alpha.173](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.172...v0.0.1-alpha.173) (2024-10-26) diff --git a/package-lock.json b/package-lock.json index a3f332d..80c3b0d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@dignetwork/dig-sdk", - "version": "0.0.1-alpha.173", + "version": "0.0.1-alpha.174", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@dignetwork/dig-sdk", - "version": "0.0.1-alpha.173", + "version": "0.0.1-alpha.174", "license": "ISC", "dependencies": { "@dignetwork/datalayer-driver": "^0.1.29", diff --git a/package.json b/package.json index f215528..66d1b48 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dignetwork/dig-sdk", - "version": "0.0.1-alpha.173", + "version": "0.0.1-alpha.174", "description": "", "type": "commonjs", "main": "./dist/index.js", diff --git a/src/DigNetwork/ContentServer.ts b/src/DigNetwork/ContentServer.ts index 1fc3e1a..d60c90b 100644 --- a/src/DigNetwork/ContentServer.ts +++ b/src/DigNetwork/ContentServer.ts @@ -2,10 +2,11 @@ import fs from "fs"; import http from "http"; import { URL } from "url"; import { Readable } from "stream"; -import { formatHost, DigCache, getOrCreateSSLCerts } from "../utils"; +import { formatHost, getOrCreateSSLCerts } from "../utils"; +import NodeCache from "node-cache"; -const hasRootHashCache = new DigCache({ stdTTL: 86400 }); -const wellKnownCache = new DigCache({ stdTTL: 86400 }); +const hasRootHashCache = new NodeCache({ stdTTL: 86400 }); +const wellKnownCache = new NodeCache({ stdTTL: 86400 }); export class ContentServer { private ipAddress: string; diff --git a/src/DigNetwork/PropagationServer.ts b/src/DigNetwork/PropagationServer.ts index eca99a1..316f106 100644 --- a/src/DigNetwork/PropagationServer.ts +++ b/src/DigNetwork/PropagationServer.ts @@ -18,11 +18,12 @@ import { PassThrough } from "stream"; import { promptCredentials } from "../utils/credentialsUtils"; import { STORE_PATH } from "../utils/config"; import { Wallet, DataStore } from "../blockchain"; -import { formatHost, DigCache, getOrCreateSSLCerts } from "../utils"; +import { formatHost, getOrCreateSSLCerts } from "../utils"; +import NodeCache from "node-cache"; // Initialize cache with a TTL of 1 week (604800 seconds) -const storeExistsCache = new DigCache({ stdTTL: 86400 }); -const pingUpdatecache = new DigCache({ stdTTL: 86400 }); +const storeExistsCache = new NodeCache({ stdTTL: 86400 }); +const pingUpdatecache = new NodeCache({ stdTTL: 86400 }); // Helper function to trim long filenames with ellipsis and ensure consistent padding function formatFilename(filename: string | undefined, maxLength = 30): string { diff --git a/src/blockchain/DataStore.ts b/src/blockchain/DataStore.ts index 662f45b..f15d8d2 100644 --- a/src/blockchain/DataStore.ts +++ b/src/blockchain/DataStore.ts @@ -37,10 +37,10 @@ import { FileCache } from "../utils/FileCache"; import { DataStoreSerializer } from "./DataStoreSerializer"; import { MAIN_NET_GENISES_CHALLENGE } from "../utils/config"; import { StoreMonitorRegistry } from "./StoreMonitorRegistry"; -import { DigCache } from "../utils"; +import NodeCache from "node-cache"; // Initialize the cache with a TTL of 180 seconds (3 minutes) -const rootHistoryCache = new DigCache({ stdTTL: 180 }); +const rootHistoryCache = new NodeCache({ stdTTL: 180 }); const stat = promisify(fs.stat); const readdir = promisify(fs.readdir); diff --git a/src/blockchain/FullNodePeer.ts b/src/blockchain/FullNodePeer.ts index 3b95917..2129ab9 100644 --- a/src/blockchain/FullNodePeer.ts +++ b/src/blockchain/FullNodePeer.ts @@ -7,7 +7,7 @@ import net from "net"; import { createSpinner } from "nanospinner"; import { MIN_HEIGHT, MIN_HEIGHT_HEADER_HASH } from "../utils/config"; import { Environment } from "../utils/Environment"; -import { DigCache } from "../utils"; +import NodeCache from "node-cache"; import Bottleneck from "bottleneck"; const FULLNODE_PORT = 8444; @@ -41,12 +41,12 @@ export class FullNodePeer { private static instance: FullNodePeer | null = null; // Cooldown cache to exclude faulty peers temporarily - private static cooldownCache = new DigCache({ + private static cooldownCache = new NodeCache({ stdTTL: COOLDOWN_DURATION / 1000, }); // Failed DNS hosts cooldown cache - private static failedDNSCache = new DigCache({ stdTTL: 86400 }); + private static failedDNSCache = new NodeCache({ stdTTL: 86400 }); // Peer reliability weights private static peerWeights: Map = new Map(); @@ -58,10 +58,10 @@ export class FullNodePeer { private static peerInfos: Map = new Map(); // Cache for fetched peer IPs - private static peerIPCache = new DigCache({ stdTTL: CACHE_DURATION / 1000 }); + private static peerIPCache = new NodeCache({ stdTTL: CACHE_DURATION / 1000 }); // Cache for DNS_HOST resolved IPs with a TTL of 3 days (259200 seconds) - private static dnsCache = new DigCache({ + private static dnsCache = new NodeCache({ stdTTL: 259200, checkperiod: 3600, }); diff --git a/src/blockchain/ServerCoin.ts b/src/blockchain/ServerCoin.ts index 1aca8a3..8aee49b 100644 --- a/src/blockchain/ServerCoin.ts +++ b/src/blockchain/ServerCoin.ts @@ -13,12 +13,13 @@ import { Wallet } from "./Wallet"; import { NconfManager } from "../utils/NconfManager"; import { CoinData, ServerCoinData } from "../types"; import { DataStore } from "./DataStore"; -import { getPublicHost, DigCache, Environment } from "../utils"; +import { getPublicHost, Environment } from "../utils"; +import NodeCache from "node-cache"; const serverCoinCollateral = 300_000_000; // Initialize the cache with a TTL of 300 seconds (5 minutes) -const serverCoinPeersCache = new DigCache({ stdTTL: 300 }); +const serverCoinPeersCache = new NodeCache({ stdTTL: 300 }); export class ServerCoin { private storeId: string; diff --git a/src/utils/PeerRanker.ts b/src/utils/PeerRanker.ts index 8b411a7..b146f08 100644 --- a/src/utils/PeerRanker.ts +++ b/src/utils/PeerRanker.ts @@ -1,12 +1,12 @@ import axios, { AxiosRequestConfig } from 'axios'; import fs from 'fs'; import https from 'https'; -import { DigCache } from './DigCache'; import { getOrCreateSSLCerts } from './ssl'; import { asyncPool } from './promiseUtils'; +import NodeCache from "node-cache"; // Cache with TTL of 1 day (86400 seconds) -const peerCache = new DigCache({ stdTTL: 86400 }); +const peerCache = new NodeCache({ stdTTL: 86400 }); export interface PeerMetrics { ip: string;