-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ts
More file actions
113 lines (112 loc) · 7.31 KB
/
Copy pathconfig.ts
File metadata and controls
113 lines (112 loc) · 7.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
export const defaultCommunityListSources = [
'https://api.github.com/repos/bitsocialnet/lists/contents/5chan-directories?ref=master',
'https://api.github.com/repos/bitsocialnet/lists/contents/seedit-directories?ref=master'
]
// The published 5chan directory manifest. Seeding votes is on by default: a directory
// contest is only as live as the seeders holding its checkpoint, and a network of
// community seeders that all opted out of votes leaves cold-joining browser voters with
// nobody to pull from.
export const defaultVotesManifestSources = [
'https://raw.githubusercontent.com/bitsocialnet/lists/master/5chan-directory-criteria.jsonc'
]
// The delegated Routing V1 HTTP routers pkc-js clients query by default (pkc-js schema.ts
// httpRoutersOptions — keep in sync); the votes library's built-in announcer
// (PubsubVoterOptions.httpRouterUrls) announces the embedded libp2p peer to the same set
// so voters' findProviders() can find it.
const defaultVotesHttpRouterUrls = 'https://peers.pleb.bot,https://routing.lol,https://peers.forumindex.com,https://peers.plebpubsub.xyz,https://routerofbitsocial.xyz,https://bsotracker.online'
// An unset or empty env var falls through to the defaults below, so "I want zero sources"
// needs a spelling of its own: `none` (case-insensitive). COMMUNITY_LIST_SOURCES=none is a
// votes-only seeder, VOTES_MANIFEST_SOURCES=none a communities-only one.
export const parseSourceList = (value = '') => value.trim().toLowerCase() === 'none'
? []
: value
.split(',')
.map(source => source.trim())
.filter(Boolean)
export default {
seeding: {
// JSON URLs, local JSON files, or directories of JSON files to monitor.
// The defaults poll the official 5chan and Seedit directory candidate
// folders, so additions and list changes do not require a seeder release.
communityListSources: parseSourceList(process.env.COMMUNITY_LIST_SOURCES || defaultCommunityListSources.join(',')),
// Operator-specific JSON URLs, local JSON files, or directories to add on
// top of the public list sources. Extras are not capped by MAX_COMMUNITIES.
communityExtraListSources: parseSourceList(process.env.COMMUNITY_EXTRA_LIST_SOURCES || ''),
discoverIntervalMs: Number(process.env.DISCOVER_INTERVAL_MS || 10 * 60 * 1000),
maxCommunities: process.env.MAX_COMMUNITIES ? Number(process.env.MAX_COMMUNITIES) : undefined,
pinConcurrency: Number(process.env.PIN_CONCURRENCY || 2),
pubsubRoutingProvideIntervalMs: Number(process.env.PUBSUB_ROUTING_PROVIDE_INTERVAL_MS || 6 * 60 * 60 * 1000),
},
votes: {
// JSONC/JSON directory-manifest URLs, local files, or directories of manifest files
// ({ defaults, contests } shape, e.g. 5chan-directory-criteria.jsonc). Defaults to the
// published 5chan directory manifest; VOTES_MANIFEST_SOURCES=none disables votes seeding.
manifestSources: parseSourceList(process.env.VOTES_MANIFEST_SOURCES || defaultVotesManifestSources.join(',')),
// Routing V1 HTTP routers to announce the votes peer to (and to look up other peers
// through). Passed to the library's built-in announcer (hourly + debounced on checkpoint
// changes; announces criteria CIDs, checkpoint roots, and chunk CIDs). Defaults to the
// routers pkc-js clients query.
httpRouterUrls: parseSourceList(process.env.VOTES_HTTP_ROUTER_URLS || defaultVotesHttpRouterUrls),
// Listen host/ports for the embedded votes libp2p node. Listening on 0.0.0.0 makes
// libp2p expand to the machine's interface addrs, so a host with a public interface IP
// announces it without further config.
listenHost: process.env.VOTES_LIBP2P_HOST || '0.0.0.0',
tcpPort: Number(process.env.VOTES_LIBP2P_TCP_PORT || 6742),
wsPort: Number(process.env.VOTES_LIBP2P_WS_PORT || 6743),
reconcileIntervalMs: Number(process.env.VOTES_RECONCILE_INTERVAL_MS || 10 * 60 * 1000),
// Per-chain RPC override, JSON keyed by chain id: {"8453": ["https://my-base-rpc"]}.
// RPC endpoints are the client's own setting (deliberately NOT in the criteria document —
// swapping endpoints must not fork topics); chains without an override use the viem
// chain's default public RPC. Pre-0.5.0 configs keyed this by ticker ("base", "eth"),
// back when the criteria carried one; lib/votes/chains.ts still accepts those spellings.
chainRpcUrls: JSON.parse(process.env.VOTES_CHAIN_RPC_URLS || '{}'),
// ETH mainnet RPC URL(s), used everywhere ETH mainnet is needed: .bso community-name
// resolution (one BsoResolver per URL — votes carry community names, and a bundle whose
// name cannot be verified is never counted) and the default endpoints for eth-gated
// contest verification (an explicit VOTES_CHAIN_RPC_URLS "eth" entry still wins there).
// Empty = the same six-RPC default list bitsocial-cli gives pkc-js.
ethRpcUrls: parseSourceList(process.env.VOTES_ETH_RPC_URLS || ''),
// The embedded node's persistent peer identity (announced to the routers; the AutoTLS
// domain embeds it). The keychain password guarding the certificate key lives next to
// it as votes-keychain.pass.
peerKeyPath: process.env.VOTES_PEER_KEY_PATH || 'votes-peer.key',
// The embedded Helia node's on-disk blockstore (verified bundle blocks + checkpoint
// chunks, served over the votes network's bitswap).
blockstorePath: process.env.VOTES_BLOCKSTORE_PATH || 'votes-blockstore',
// The embedded libp2p node's datastore (AutoTLS certificate + keychain persist here,
// so restarts don't re-run ACME).
datastorePath: process.env.VOTES_DATASTORE_PATH || 'votes-datastore',
// The votes library's persistent state: gate-result and name-resolution caches, plus
// each contest's checkpoint snapshot (checkpoints.db) — what keeps the tally across
// restarts. Unset = the library default, {cwd}/.bitsocial-pubsub-voting.
dataPath: process.env.VOTES_DATA_PATH,
// libp2p-fetch stream cap: the default 32 inbound streams strands a directory-sized
// cold join (63 concurrent checkpoint pulls) — raise it on a public seeder.
fetchMaxStreams: Number(process.env.VOTES_FETCH_MAX_STREAMS || 256),
// How many contests cold-join concurrently on reconcile.
updateConcurrency: Number(process.env.VOTES_UPDATE_CONCURRENCY || 8)
},
updateCheck: {
enabled: process.env.SEEDER_UPDATE_CHECK_ENABLED !== 'false',
intervalMs: Number(process.env.SEEDER_UPDATE_CHECK_INTERVAL_MS || 24 * 60 * 60 * 1000),
timeoutMs: Number(process.env.SEEDER_UPDATE_CHECK_TIMEOUT_MS || 5000)
},
seederState: {
path: process.env.SEEDER_STATE_PATH || 'seederState.json',
writeFile: process.env.SEEDER_STATE_WRITE_FILE !== 'false'
},
db: {
path: process.env.SEEDER_DB_PATH || 'seeder.db'
},
daemon: {
autostart: process.env.SEEDER_DAEMON_AUTOSTART !== 'false',
dataPath: process.env.SEEDER_DAEMON_DATA_PATH,
logPath: process.env.SEEDER_DAEMON_LOG_PATH,
readyTimeoutMs: Number(process.env.SEEDER_DAEMON_READY_TIMEOUT_MS || 2 * 60 * 1000),
readyStableMs: Number(process.env.SEEDER_DAEMON_READY_STABLE_MS || 2500)
},
pkcRpcUrl: process.env.PKC_RPC_URL || 'ws://127.0.0.1:9138',
kuboRpcUrl: process.env.KUBO_RPC_URL || 'http://127.0.0.1:50019/api/v0',
pubsubKuboRpcUrl: process.env.PUBSUB_KUBO_RPC_URL || process.env.KUBO_RPC_URL || 'http://127.0.0.1:50019/api/v0',
ipfsGatewayUrl: process.env.IPFS_GATEWAY_URL || 'http://127.0.0.1:6473'
}