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:
Chrysostomos Nanakos 2026-06-12 19:50:40 +03:00
parent ca89ebd935
commit cefd06371e
No known key found for this signature in database
3 changed files with 4 additions and 12 deletions

View File

@ -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

View File

@ -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 @[]

View File

@ -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.}