mirror of
https://github.com/logos-storage/logos-storage-network-crawler.git
synced 2026-01-02 13:33:08 +00:00
Renames crawler to dhtcrawler
This commit is contained in:
parent
9f8ba85d35
commit
fe9c29760c
@ -26,7 +26,7 @@ proc step(c: ChainMetrics): Future[?!void] {.async: (raises: []).} =
|
||||
return success()
|
||||
|
||||
method start*(c: ChainMetrics): Future[?!void] {.async.} =
|
||||
info "Starting..."
|
||||
info "starting..."
|
||||
|
||||
proc onStep(): Future[?!void] {.async: (raises: []), gcsafe.} =
|
||||
return await c.step()
|
||||
|
||||
@ -12,15 +12,15 @@ import ../state
|
||||
import ../utils/asyncdataevent
|
||||
|
||||
logScope:
|
||||
topics = "crawler"
|
||||
topics = "dhtcrawler"
|
||||
|
||||
type Crawler* = ref object of Component
|
||||
type DhtCrawler* = ref object of Component
|
||||
state: State
|
||||
dht: Dht
|
||||
todo: TodoList
|
||||
|
||||
proc raiseCheckEvent(
|
||||
c: Crawler, nid: Nid, success: bool
|
||||
c: DhtCrawler, nid: Nid, success: bool
|
||||
): Future[?!void] {.async: (raises: []).} =
|
||||
let event = DhtNodeCheckEventData(id: nid, isOk: success)
|
||||
if err =? (await c.state.events.dhtNodeCheck.fire(event)).errorOption:
|
||||
@ -28,7 +28,7 @@ proc raiseCheckEvent(
|
||||
return failure(err)
|
||||
return success()
|
||||
|
||||
proc step(c: Crawler): Future[?!void] {.async: (raises: []).} =
|
||||
proc step(c: DhtCrawler): Future[?!void] {.async: (raises: []).} =
|
||||
without nid =? (await c.todo.pop()), err:
|
||||
error "failed to pop todolist", err = err.msg
|
||||
return failure(err)
|
||||
@ -46,8 +46,8 @@ proc step(c: Crawler): Future[?!void] {.async: (raises: []).} =
|
||||
|
||||
return success()
|
||||
|
||||
method start*(c: Crawler): Future[?!void] {.async.} =
|
||||
info "Starting crawler..."
|
||||
method start*(c: DhtCrawler): Future[?!void] {.async.} =
|
||||
info "starting..."
|
||||
|
||||
proc onStep(): Future[?!void] {.async: (raises: []), gcsafe.} =
|
||||
await c.step()
|
||||
@ -57,8 +57,8 @@ method start*(c: Crawler): Future[?!void] {.async.} =
|
||||
|
||||
return success()
|
||||
|
||||
method stop*(c: Crawler): Future[?!void] {.async.} =
|
||||
method stop*(c: DhtCrawler): Future[?!void] {.async.} =
|
||||
return success()
|
||||
|
||||
proc new*(T: type Crawler, state: State, dht: Dht, todo: TodoList): Crawler =
|
||||
Crawler(state: state, dht: dht, todo: todo)
|
||||
proc new*(T: type DhtCrawler, state: State, dht: Dht, todo: TodoList): DhtCrawler =
|
||||
DhtCrawler(state: state, dht: dht, todo: todo)
|
||||
@ -46,7 +46,7 @@ proc handleDeleteEvent(d: DhtMetrics, nids: seq[Nid]): Future[?!void] {.async.}
|
||||
return success()
|
||||
|
||||
method start*(d: DhtMetrics): Future[?!void] {.async.} =
|
||||
info "Starting..."
|
||||
info "starting..."
|
||||
?await d.ok.load()
|
||||
?await d.nok.load()
|
||||
|
||||
|
||||
@ -203,7 +203,7 @@ method deleteEntries*(
|
||||
return success()
|
||||
|
||||
method start*(s: NodeStore): Future[?!void] {.async.} =
|
||||
info "Starting..."
|
||||
info "starting..."
|
||||
|
||||
proc onNodesFound(nids: seq[Nid]): Future[?!void] {.async.} =
|
||||
return await s.processFoundNodes(nids)
|
||||
|
||||
@ -119,7 +119,7 @@ method iterateAll*(
|
||||
return success()
|
||||
|
||||
method start*(s: RequestStore): Future[?!void] {.async.} =
|
||||
info "Starting..."
|
||||
info "starting..."
|
||||
return success()
|
||||
|
||||
method stop*(s: RequestStore): Future[?!void] {.async.} =
|
||||
|
||||
@ -57,7 +57,7 @@ proc raiseRoutingTableNodes(t: TimeTracker): Future[?!void] {.async: (raises: []
|
||||
return success()
|
||||
|
||||
method start*(t: TimeTracker): Future[?!void] {.async.} =
|
||||
info "Starting..."
|
||||
info "starting..."
|
||||
|
||||
proc onCheckRevisitAndExpiry(): Future[?!void] {.async: (raises: []), gcsafe.} =
|
||||
await t.checkRevisitsAndExpiry()
|
||||
|
||||
@ -9,7 +9,7 @@ import ./services/dht
|
||||
import ./services/marketplace
|
||||
|
||||
import ./component
|
||||
import ./components/crawler
|
||||
import ./components/dhtcrawler
|
||||
import ./components/timetracker
|
||||
import ./components/nodestore
|
||||
import ./components/dhtmetrics
|
||||
@ -38,7 +38,7 @@ proc createComponents*(state: State): Future[?!seq[Component]] {.async.} =
|
||||
components.add(dht)
|
||||
components.add(todoList)
|
||||
components.add(nodeStore)
|
||||
components.add(Crawler.new(state, dht, todoList))
|
||||
components.add(DhtCrawler.new(state, dht, todoList))
|
||||
components.add(TimeTracker.new(state, nodeStore, dht, clock))
|
||||
components.add(dhtMetrics)
|
||||
components.add(marketplace)
|
||||
|
||||
@ -3,7 +3,7 @@ import pkg/questionable
|
||||
import pkg/questionable/results
|
||||
import pkg/asynctest/chronos/unittest
|
||||
|
||||
import ../../../codexcrawler/components/crawler
|
||||
import ../../../codexcrawler/components/dhtcrawler
|
||||
import ../../../codexcrawler/services/dht
|
||||
import ../../../codexcrawler/utils/asyncdataevent
|
||||
import ../../../codexcrawler/types
|
||||
@ -13,14 +13,14 @@ import ../mocks/mockdht
|
||||
import ../mocks/mocktodolist
|
||||
import ../helpers
|
||||
|
||||
suite "Crawler":
|
||||
suite "DhtCrawler":
|
||||
var
|
||||
nid1: Nid
|
||||
nid2: Nid
|
||||
state: MockState
|
||||
todo: MockTodoList
|
||||
dht: MockDht
|
||||
crawler: Crawler
|
||||
crawler: DhtCrawler
|
||||
|
||||
setup:
|
||||
nid1 = genNid()
|
||||
@ -29,7 +29,7 @@ suite "Crawler":
|
||||
todo = createMockTodoList()
|
||||
dht = createMockDht()
|
||||
|
||||
crawler = Crawler.new(state, dht, todo)
|
||||
crawler = DhtCrawler.new(state, dht, todo)
|
||||
|
||||
(await crawler.start()).tryGet()
|
||||
|
||||
@ -107,9 +107,20 @@ suite "Requeststore":
|
||||
|
||||
check:
|
||||
entries.len == 3
|
||||
entries[0].id == rid1
|
||||
|
||||
let
|
||||
ids = @[entries[0].id, entries[1].id, entries[2].id]
|
||||
all = @[rid1, rid2, rid3]
|
||||
|
||||
for id in ids:
|
||||
check:
|
||||
id in all
|
||||
|
||||
for id in all:
|
||||
check:
|
||||
id in ids
|
||||
|
||||
check:
|
||||
entries[0].lastSeen == clock.setNow
|
||||
entries[1].id == rid2
|
||||
entries[1].lastSeen == clock.setNow
|
||||
entries[2].id == rid3
|
||||
entries[2].lastSeen == clock.setNow
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import ./components/testchainmetrics
|
||||
import ./components/testcrawler
|
||||
import ./components/testdhtcrawler
|
||||
import ./components/testdhtmetrics
|
||||
import ./components/testnodestore
|
||||
import ./components/testrequeststore
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user