Skip to content

Commit 07c4879

Browse files
revert: digcache
1 parent 0f02762 commit 07c4879

File tree

6 files changed

+20
-17
lines changed

6 files changed

+20
-17
lines changed

src/DigNetwork/ContentServer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import fs from "fs";
22
import http from "http";
33
import { URL } from "url";
44
import { Readable } from "stream";
5-
import { formatHost, DigCache, getOrCreateSSLCerts } from "../utils";
5+
import { formatHost, getOrCreateSSLCerts } from "../utils";
6+
import NodeCache from "node-cache";
67

7-
const hasRootHashCache = new DigCache({ stdTTL: 86400 });
8-
const wellKnownCache = new DigCache({ stdTTL: 86400 });
8+
const hasRootHashCache = new NodeCache({ stdTTL: 86400 });
9+
const wellKnownCache = new NodeCache({ stdTTL: 86400 });
910

1011
export class ContentServer {
1112
private ipAddress: string;

src/DigNetwork/PropagationServer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ import { PassThrough } from "stream";
1818
import { promptCredentials } from "../utils/credentialsUtils";
1919
import { STORE_PATH } from "../utils/config";
2020
import { Wallet, DataStore } from "../blockchain";
21-
import { formatHost, DigCache, getOrCreateSSLCerts } from "../utils";
21+
import { formatHost, getOrCreateSSLCerts } from "../utils";
22+
import NodeCache from "node-cache";
2223

2324
// Initialize cache with a TTL of 1 week (604800 seconds)
24-
const storeExistsCache = new DigCache({ stdTTL: 86400 });
25-
const pingUpdatecache = new DigCache({ stdTTL: 86400 });
25+
const storeExistsCache = new NodeCache({ stdTTL: 86400 });
26+
const pingUpdatecache = new NodeCache({ stdTTL: 86400 });
2627

2728
// Helper function to trim long filenames with ellipsis and ensure consistent padding
2829
function formatFilename(filename: string | undefined, maxLength = 30): string {

src/blockchain/DataStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ import { FileCache } from "../utils/FileCache";
3737
import { DataStoreSerializer } from "./DataStoreSerializer";
3838
import { MAIN_NET_GENISES_CHALLENGE } from "../utils/config";
3939
import { StoreMonitorRegistry } from "./StoreMonitorRegistry";
40-
import { DigCache } from "../utils";
40+
import NodeCache from "node-cache";
4141

4242
// Initialize the cache with a TTL of 180 seconds (3 minutes)
43-
const rootHistoryCache = new DigCache({ stdTTL: 180 });
43+
const rootHistoryCache = new NodeCache({ stdTTL: 180 });
4444

4545
const stat = promisify(fs.stat);
4646
const readdir = promisify(fs.readdir);

src/blockchain/FullNodePeer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import net from "net";
77
import { createSpinner } from "nanospinner";
88
import { MIN_HEIGHT, MIN_HEIGHT_HEADER_HASH } from "../utils/config";
99
import { Environment } from "../utils/Environment";
10-
import { DigCache } from "../utils";
10+
import NodeCache from "node-cache";
1111
import Bottleneck from "bottleneck";
1212

1313
const FULLNODE_PORT = 8444;
@@ -41,12 +41,12 @@ export class FullNodePeer {
4141
private static instance: FullNodePeer | null = null;
4242

4343
// Cooldown cache to exclude faulty peers temporarily
44-
private static cooldownCache = new DigCache({
44+
private static cooldownCache = new NodeCache({
4545
stdTTL: COOLDOWN_DURATION / 1000,
4646
});
4747

4848
// Failed DNS hosts cooldown cache
49-
private static failedDNSCache = new DigCache({ stdTTL: 86400 });
49+
private static failedDNSCache = new NodeCache({ stdTTL: 86400 });
5050

5151
// Peer reliability weights
5252
private static peerWeights: Map<string, number> = new Map();
@@ -58,10 +58,10 @@ export class FullNodePeer {
5858
private static peerInfos: Map<string, PeerInfo> = new Map();
5959

6060
// Cache for fetched peer IPs
61-
private static peerIPCache = new DigCache({ stdTTL: CACHE_DURATION / 1000 });
61+
private static peerIPCache = new NodeCache({ stdTTL: CACHE_DURATION / 1000 });
6262

6363
// Cache for DNS_HOST resolved IPs with a TTL of 3 days (259200 seconds)
64-
private static dnsCache = new DigCache({
64+
private static dnsCache = new NodeCache({
6565
stdTTL: 259200,
6666
checkperiod: 3600,
6767
});

src/blockchain/ServerCoin.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ import { Wallet } from "./Wallet";
1313
import { NconfManager } from "../utils/NconfManager";
1414
import { CoinData, ServerCoinData } from "../types";
1515
import { DataStore } from "./DataStore";
16-
import { getPublicHost, DigCache, Environment } from "../utils";
16+
import { getPublicHost, Environment } from "../utils";
17+
import NodeCache from "node-cache";
1718

1819
const serverCoinCollateral = 300_000_000;
1920

2021
// Initialize the cache with a TTL of 300 seconds (5 minutes)
21-
const serverCoinPeersCache = new DigCache({ stdTTL: 300 });
22+
const serverCoinPeersCache = new NodeCache({ stdTTL: 300 });
2223

2324
export class ServerCoin {
2425
private storeId: string;

src/utils/PeerRanker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import axios, { AxiosRequestConfig } from 'axios';
22
import fs from 'fs';
33
import https from 'https';
4-
import { DigCache } from './DigCache';
54
import { getOrCreateSSLCerts } from './ssl';
65
import { asyncPool } from './promiseUtils';
6+
import NodeCache from "node-cache";
77

88
// Cache with TTL of 1 day (86400 seconds)
9-
const peerCache = new DigCache({ stdTTL: 86400 });
9+
const peerCache = new NodeCache({ stdTTL: 86400 });
1010

1111
export interface PeerMetrics {
1212
ip: string;

0 commit comments

Comments
 (0)