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