feat: introduce default torrent node config

This commit is contained in:
Pascal Precht 2022-04-08 12:44:50 +02:00 committed by r4bbit.eth
parent 0a8429bc3f
commit 1ee631c04e
3 changed files with 19 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import json, os, chronicles, utils
import ../../constants as main_constants
# set via `nim c` param `-d:INFURA_TOKEN:[token]`; should be set in CI/release builds
const INFURA_TOKEN {.strdefine.} = ""
@ -21,6 +22,9 @@ let OPENSEA_API_KEY_RESOLVED* =
else:
OPENSEA_API_KEY
let DEFAULT_TORRENT_CONFIG_PORT* = 9025
let DEFAULT_TORRENT_CONFIG_DATADIR* = joinPath(main_constants.defaultDataDir(), "data", "archivedata")
let DEFAULT_TORRENT_CONFIG_TORRENTDIR* = joinPath(main_constants.defaultDataDir(), "data", "torrents")
const DEFAULT_NETWORK_NAME* = "mainnet_rpc"
@ -253,7 +257,13 @@ var NODE_CONFIG* = %* {
"layer": 2,
"enabled": true,
}
]
],
"TorrentConfig": {
"Enabled": false,
"Port": DEFAULT_TORRENT_CONFIG_PORT,
"DataDir": DEFAULT_TORRENT_CONFIG_DATADIR,
"TorrentDir": DEFAULT_TORRENT_CONFIG_TORRENTDIR
}
}
proc getNetworkConfig*(currentNetwork: string): JsonNode =

View File

@ -1,4 +1,4 @@
import json, sequtils, strutils, uuids
import json, sequtils, strutils, uuids, os
import json_serialization, chronicles
import ./dto/accounts as dto_accounts
@ -334,6 +334,12 @@ proc login*(self: Service, account: AccountDto, password: string): string =
"Enabled": true,
"OpenseaAPIKey": OPENSEA_API_KEY_RESOLVED
},
"TorrentConfig": {
"Enabled": false,
"DataDir": DEFAULT_TORRENT_CONFIG_DATADIR,
"TorrentDir": DEFAULT_TORRENT_CONFIG_TORRENTDIR,
"Port": DEFAULT_TORRENT_CONFIG_PORT
}
}
let response = status_account.login(account.name, account.keyUid, hashedPassword, thumbnailImage,

View File

@ -5,7 +5,7 @@ import # vendor libs
const sep = when defined(windows): "\\" else: "/"
proc defaultDataDir(): string =
proc defaultDataDir*(): string =
let homeDir = getHomeDir()
let parentDir =
if defined(development):