diff --git a/dagger.nimble b/dagger.nimble index d794b933..c1cf68a9 100644 --- a/dagger.nimble +++ b/dagger.nimble @@ -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" diff --git a/dagger/blockexchange/network.nim b/dagger/blockexchange/network.nim index 6338dd00..1db4395e 100644 --- a/dagger/blockexchange/network.nim +++ b/dagger/blockexchange/network.nim @@ -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 diff --git a/dagger/stores/blockexchange.nim b/dagger/stores/blockexchange.nim index 4652437f..450074fd 100644 --- a/dagger/stores/blockexchange.nim +++ b/dagger/stores/blockexchange.nim @@ -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: diff --git a/tests/dagger/blockexc/testengine.nim b/tests/dagger/blockexc/testengine.nim index 381d3c83..2852636a 100644 --- a/tests/dagger/blockexc/testengine.nim +++ b/tests/dagger/blockexc/testengine.nim @@ -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] diff --git a/tests/dagger/blockexc/testnetwork.nim b/tests/dagger/blockexc/testnetwork.nim index 56609335..f9e6d943 100644 --- a/tests/dagger/blockexc/testnetwork.nim +++ b/tests/dagger/blockexc/testnetwork.nim @@ -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) diff --git a/tests/dagger/examples.nim b/tests/dagger/examples.nim index 199a653b..178911c4 100644 --- a/tests/dagger/examples.nim +++ b/tests/dagger/examples.nim @@ -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)