mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-02 21:43:11 +00:00
* rework discovery with async queues * increase max message size for large manifests * increase sleep time to 100 millis * pass config * check for nil on start/stop * fix tests and split out discovery tests * don't auto mount network * add discovery tests * rework moc discovery * move discovery moc to disc dir * don't force logging syncs * don't force moc discovery on all tests * rework discovery with methods * add top level utils file * don't use asyncCheck * don't pass entire blocks to list blocks calback * spelling * - don't send want reqs to peers reporting the cid - Don't request blocks directly on presense update, use `requestBlock` * bug, nodes should not have blocks in local store * Add failing test * prefetch blocks so that download isn't serial * if request already pending, return the handle * fire discovery if no peers report block as have * only query discovery if not enough nodes for cid * wrap async req in template * use non awaiting version of queue routines * rework E2E tests as unittest * re-add chronicles sinks Co-authored-by: Tanguy <tanguy@status.im>
34 lines
1013 B
Nim
34 lines
1013 B
Nim
import std/sequtils
|
|
|
|
import pkg/chronos
|
|
import pkg/libp2p
|
|
|
|
import pkg/dagger/discovery
|
|
import pkg/dagger/stores
|
|
import pkg/dagger/blocktype as bt
|
|
|
|
import ../examples
|
|
|
|
proc generateNodes*(
|
|
num: Natural,
|
|
blocks: openArray[bt.Block] = []):
|
|
seq[tuple[switch: Switch, blockexc: NetworkStore]] =
|
|
for i in 0..<num:
|
|
let
|
|
switch = newStandardSwitch(transportFlags = {ServerFlags.ReuseAddr})
|
|
discovery = Discovery.new(switch.peerInfo, Port(0))
|
|
wallet = WalletRef.example
|
|
network = BlockExcNetwork.new(switch)
|
|
localStore = CacheStore.new(blocks.mapIt( it ))
|
|
engine = BlockExcEngine.new(localStore, wallet, network, discovery)
|
|
networkStore = NetworkStore.new(engine, localStore)
|
|
|
|
switch.mount(network)
|
|
result.add((switch, networkStore))
|
|
|
|
proc connectNodes*(nodes: seq[Switch]) {.async.} =
|
|
for dialer in nodes:
|
|
for node in nodes:
|
|
if dialer.peerInfo.peerId != node.peerInfo.peerId:
|
|
await dialer.connect(node.peerInfo.peerId, node.peerInfo.addrs)
|