mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-06-28 13:29:28 +00:00
feat(mix): support running as pure relay + DHT proxy
Part of https://github.com/logos-storage/logos-storage-pm/issues/13 Signed-off-by: Chrysostomos Nanakos <chris@include.gr>
This commit is contained in:
parent
ca89ebd935
commit
cefd06371e
@ -65,14 +65,6 @@ when isMainModule:
|
||||
echo "Invalid value for --log-level. " & err.msg
|
||||
quit QuitFailure
|
||||
|
||||
if config.mixEnabled:
|
||||
if config.mixPoolDir.len == 0:
|
||||
fatal "mix-enabled requires --mix-pool-dir"
|
||||
quit QuitFailure
|
||||
if config.bootstrapNodes.len > 0 and config.dhtMixProxies.len == 0:
|
||||
fatal "mix-enabled requires at least one --dht-mix-proxy"
|
||||
quit QuitFailure
|
||||
|
||||
if err =? config.setupMetrics().errorOption:
|
||||
fatal "Failed to start metrics server", err = err.msg
|
||||
quit QuitFailure
|
||||
|
||||
@ -116,7 +116,7 @@ method find*(
|
||||
d: Discovery, cid: Cid
|
||||
): Future[seq[SignedPeerRecord]] {.async: (raises: [CancelledError]), base.} =
|
||||
let providers =
|
||||
if not d.mixProto.isNil:
|
||||
if not d.mixProto.isNil and d.dhtMixProxies.len > 0:
|
||||
(await d.findViaMix(cid)).valueOr:
|
||||
warn "Mix lookup failed", cid, err = error.msg
|
||||
return @[]
|
||||
|
||||
@ -103,6 +103,9 @@ proc buildMixNodeInfo*(
|
||||
)
|
||||
|
||||
proc loadRelayPubInfoTable*(mixPoolDir: string): ?!Table[PeerId, MixPubInfo] =
|
||||
if mixPoolDir.len == 0:
|
||||
return success initTable[PeerId, MixPubInfo]()
|
||||
|
||||
let pubInfoDir = mixPoolDir / "pubInfo"
|
||||
if not dirExists(pubInfoDir):
|
||||
return failure("Relay pubInfo directory does not exist: " & pubInfoDir)
|
||||
@ -124,9 +127,6 @@ proc loadRelayPubInfoTable*(mixPoolDir: string): ?!Table[PeerId, MixPubInfo] =
|
||||
t[info.peerId] = info
|
||||
inc i
|
||||
|
||||
if t.len == 0:
|
||||
return failure("No relay entries found in " & pubInfoDir)
|
||||
|
||||
success t
|
||||
|
||||
{.pop.}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user