fix compilation issues with latest libp2p
This commit is contained in:
parent
2fb39ca4a3
commit
708eac1743
|
@ -16,4 +16,4 @@ requires "nim >= 1.2.6",
|
|||
"https://github.com/status-im/nim-nitro >= 0.4.0 & < 0.5.0",
|
||||
"questionable >= 0.9.1 & < 0.10.0",
|
||||
"upraises >= 0.1.0 & < 0.2.0",
|
||||
"asynctest >= 0.2.1 & < 0.3.0"
|
||||
"asynctest >= 0.3.0 & < 0.4.0"
|
||||
|
|
|
@ -300,11 +300,7 @@ method init*(b: BlockExcNetwork) =
|
|||
## Perform protocol initialization
|
||||
##
|
||||
|
||||
proc peerEventHandler(peerInfo: PeerInfo, event: PeerEvent) {.async.} =
|
||||
# TODO: temporary until libp2p moves back to PeerID
|
||||
let
|
||||
peerId = peerInfo.peerId
|
||||
|
||||
proc peerEventHandler(peerId: PeerID, event: PeerEvent) {.async.} =
|
||||
if event.kind == PeerEventKind.Joined:
|
||||
b.setupPeer(peerId)
|
||||
else:
|
||||
|
@ -314,7 +310,7 @@ method init*(b: BlockExcNetwork) =
|
|||
b.switch.addPeerEventHandler(peerEventHandler, PeerEventKind.Left)
|
||||
|
||||
proc handle(conn: Connection, proto: string) {.async, gcsafe, closure.} =
|
||||
let peerId = conn.peerInfo.peerId
|
||||
let peerId = conn.peerId
|
||||
let blockexcPeer = b.getOrCreatePeer(peerId)
|
||||
await blockexcPeer.readLoop(conn) # attach read loop
|
||||
|
||||
|
|
|
@ -132,11 +132,8 @@ proc new*(
|
|||
engine.scheduleTask = proc(task: BlockExcPeerCtx): bool {.gcsafe} =
|
||||
b.taskQueue.pushOrUpdateNoWait(task).isOk()
|
||||
|
||||
proc peerEventHandler(peerInfo: PeerInfo, event: PeerEvent) {.async.} =
|
||||
proc peerEventHandler(peerId: PeerID, event: PeerEvent) {.async.} =
|
||||
# TODO: temporary until libp2p moves back to PeerID
|
||||
let
|
||||
peerId = peerInfo.peerId
|
||||
|
||||
if event.kind == PeerEventKind.Joined:
|
||||
b.engine.setupPeer(peerId)
|
||||
else:
|
||||
|
|
|
@ -21,7 +21,7 @@ suite "BlockExc engine basic":
|
|||
let
|
||||
rng = Rng.instance()
|
||||
seckey = PrivateKey.random(rng[]).tryGet()
|
||||
peerId = PeerID.init(seckey.getKey().tryGet()).tryGet()
|
||||
peerId = PeerID.init(seckey.getPublicKey().tryGet()).tryGet()
|
||||
chunker = newRandomChunker(Rng.instance(), size = 1024, chunkSize = 256)
|
||||
blocks = chunker.mapIt( !bt.Block.new(it) )
|
||||
wallet = WalletRef.example
|
||||
|
@ -73,7 +73,7 @@ suite "BlockExc engine handlers":
|
|||
let
|
||||
rng = Rng.instance()
|
||||
seckey = PrivateKey.random(rng[]).tryGet()
|
||||
peerId = PeerID.init(seckey.getKey().tryGet()).tryGet()
|
||||
peerId = PeerID.init(seckey.getPublicKey().tryGet()).tryGet()
|
||||
chunker = newRandomChunker(Rng.instance(), size = 1024, chunkSize = 256)
|
||||
blocks = chunker.mapIt( !bt.Block.new(it) )
|
||||
wallet = WalletRef.example
|
||||
|
@ -203,7 +203,7 @@ suite "Task Handler":
|
|||
|
||||
for i in 0..3:
|
||||
let seckey = PrivateKey.random(rng[]).tryGet()
|
||||
peers.add(PeerID.init(seckey.getKey().tryGet()).tryGet())
|
||||
peers.add(PeerID.init(seckey.getPublicKey().tryGet()).tryGet())
|
||||
|
||||
peersCtx.add(BlockExcPeerCtx(
|
||||
id: peers[i]
|
||||
|
|
|
@ -21,7 +21,7 @@ suite "BlockExc network":
|
|||
let
|
||||
rng = Rng.instance()
|
||||
seckey = PrivateKey.random(rng[]).tryGet()
|
||||
peerId = PeerID.init(seckey.getKey().tryGet()).tryGet()
|
||||
peerId = PeerID.init(seckey.getPublicKey().tryGet()).tryGet()
|
||||
chunker = newRandomChunker(Rng.instance(), size = 1024, chunkSize = 256)
|
||||
blocks = chunker.mapIt( !bt.Block.new(it) )
|
||||
|
||||
|
@ -36,7 +36,7 @@ suite "BlockExc network":
|
|||
|
||||
setup:
|
||||
done = newFuture[void]()
|
||||
buffer = newBufferStream()
|
||||
buffer = BufferStream.new()
|
||||
network = BlockExcNetwork.new(
|
||||
switch = newStandardSwitch(),
|
||||
connProvider = getConn)
|
||||
|
|
|
@ -46,7 +46,7 @@ proc example*(_: type Block): Block =
|
|||
|
||||
proc example*(_: type PeerId): PeerID =
|
||||
let key = PrivateKey.random(Rng.instance[]).get
|
||||
PeerId.init(key.getKey().get).get
|
||||
PeerId.init(key.getPublicKey().get).get
|
||||
|
||||
proc example*(_: type BlockExcPeerCtx): BlockExcPeerCtx =
|
||||
BlockExcPeerCtx(id: PeerID.example)
|
||||
|
|
Loading…
Reference in New Issue