mirror of
https://github.com/logos-storage/logos-storage-network-crawler.git
synced 2026-01-07 07:53:11 +00:00
activates dht. disables discv5 logging
This commit is contained in:
parent
44f7c9fc5d
commit
cc36252a45
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,3 +15,4 @@ NimBinaries
|
||||
.vscode/*
|
||||
*.exe
|
||||
crawler_data
|
||||
dht
|
||||
|
||||
@ -72,7 +72,7 @@ proc initializeLists(app: Application): Future[?!void] {.async.} =
|
||||
|
||||
return success()
|
||||
|
||||
proc initializeDht(app: Application): ?!void =
|
||||
proc initializeDht(app: Application): Future[?!void] {.async.} =
|
||||
without dhtStore =? app.createDatastore("dht"), err:
|
||||
return failure(err)
|
||||
let keyPath = app.config.dataDir / "privatekey"
|
||||
@ -86,8 +86,10 @@ proc initializeDht(app: Application): ?!void =
|
||||
bindPort = app.config.discPort,
|
||||
announceAddrs = announceAddresses,
|
||||
bootstrapNodes = app.config.bootNodes,
|
||||
store = dhtStore
|
||||
store = dhtStore,
|
||||
)
|
||||
|
||||
await app.dht.start()
|
||||
return success()
|
||||
|
||||
proc initializeApp(app: Application): Future[?!void] {.async.} =
|
||||
@ -95,7 +97,7 @@ proc initializeApp(app: Application): Future[?!void] {.async.} =
|
||||
error "Failed to initialize lists", err = err.msg
|
||||
return failure(err)
|
||||
|
||||
if err =? app.initializeDht().errorOption:
|
||||
if err =? (await app.initializeDht()).errorOption:
|
||||
error "Failed to initialize DHT", err = err.msg
|
||||
return failure(err)
|
||||
|
||||
@ -103,6 +105,7 @@ proc initializeApp(app: Application): Future[?!void] {.async.} =
|
||||
|
||||
proc stop*(app: Application) =
|
||||
app.status = ApplicationStatus.Stopping
|
||||
waitFor app.dht.stop()
|
||||
|
||||
proc run*(app: Application) =
|
||||
app.config = parseConfig()
|
||||
|
||||
@ -54,7 +54,7 @@ proc getBootNodeStrings(input: string): seq[string] =
|
||||
return getDefaultTestnetBootNodes()
|
||||
return input.split(";")
|
||||
|
||||
proc stringToSpr(uri: string): SignedPeerRecord =
|
||||
proc stringToSpr(uri: string): SignedPeerRecord =
|
||||
var res: SignedPeerRecord
|
||||
try:
|
||||
if not res.fromURI(uri):
|
||||
|
||||
@ -86,8 +86,7 @@ proc new*(
|
||||
bootstrapNodes: openArray[SignedPeerRecord] = [],
|
||||
store: Datastore = SQLiteDatastore.new(Memory).expect("Should not fail!"),
|
||||
): Dht =
|
||||
var self =
|
||||
Dht(key: key, peerId: PeerId.init(key).expect("Should construct PeerId"))
|
||||
var self = Dht(key: key, peerId: PeerId.init(key).expect("Should construct PeerId"))
|
||||
|
||||
self.updateAnnounceRecord(announceAddrs)
|
||||
|
||||
|
||||
@ -44,8 +44,7 @@ proc checkSecureFile*(path: string): IoResult[bool] =
|
||||
else:
|
||||
ok (?getPermissionsSet(path) == {UserRead, UserWrite})
|
||||
|
||||
type
|
||||
KeyError* = object of CatchableError
|
||||
type KeyError* = object of CatchableError
|
||||
|
||||
proc setupKey*(path: string): ?!PrivateKey =
|
||||
if not path.fileAccessible({AccessFlags.Find}):
|
||||
@ -60,9 +59,7 @@ proc setupKey*(path: string): ?!PrivateKey =
|
||||
info "Found a network private key"
|
||||
if not ?checkSecureFile(path).mapFailure(KeyError):
|
||||
warn "The network private key file is not safe, aborting"
|
||||
return failure newException(
|
||||
KeyError, "The network private key file is not safe"
|
||||
)
|
||||
return failure newException(KeyError, "The network private key file is not safe")
|
||||
|
||||
let kb = ?path.readAllBytes().mapFailure(KeyError)
|
||||
return PrivateKey.init(kb).mapFailure(KeyError)
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
--define:
|
||||
metrics
|
||||
|
||||
# switch("define", "chronicles_runtime_filtering=true")
|
||||
# Sets TRACE logging for everything except DHT
|
||||
switch("define", "chronicles_log_level=TRACE")
|
||||
switch("define", "chronicles_disabled_topics:discv5")
|
||||
|
||||
when (NimMajor, NimMinor) >= (2, 0):
|
||||
--mm:refc
|
||||
--mm:
|
||||
refc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user