fix compilation issues with latest libp2p (#27)
* fix compilation issues with latest libp2p * change package description * fix CI compiler * try with nim 1.4.2 * try with 1.4.2 * use more standardized ci config * set reasonable log level * remove nim version dependency * reverting to 1.4.6 as otherwise it fails on amd64
This commit is contained in:
parent
2fb39ca4a3
commit
ce66e43440
|
@ -7,7 +7,7 @@ jobs:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
max-parallel: 20
|
max-parallel: 20
|
||||||
matrix:
|
matrix:
|
||||||
branch: [v1.2.6]
|
branch: [v1.4.6]
|
||||||
target:
|
target:
|
||||||
# Unit tests
|
# Unit tests
|
||||||
- os: linux
|
- os: linux
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
author = "Dagger Team"
|
author = "Dagger Team"
|
||||||
description = "The hardrive for Web3"
|
description = "p2p data durability engine"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
requires "nim >= 1.2.6",
|
requires "libp2p#unstable",
|
||||||
"libp2p#unstable",
|
|
||||||
"nimcrypto >= 0.4.1",
|
"nimcrypto >= 0.4.1",
|
||||||
"bearssl >= 0.1.4",
|
"bearssl >= 0.1.4",
|
||||||
"chronicles >= 0.7.2",
|
"chronicles >= 0.7.2",
|
||||||
|
@ -16,4 +15,4 @@ requires "nim >= 1.2.6",
|
||||||
"https://github.com/status-im/nim-nitro >= 0.4.0 & < 0.5.0",
|
"https://github.com/status-im/nim-nitro >= 0.4.0 & < 0.5.0",
|
||||||
"questionable >= 0.9.1 & < 0.10.0",
|
"questionable >= 0.9.1 & < 0.10.0",
|
||||||
"upraises >= 0.1.0 & < 0.2.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
|
## Perform protocol initialization
|
||||||
##
|
##
|
||||||
|
|
||||||
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:
|
if event.kind == PeerEventKind.Joined:
|
||||||
b.setupPeer(peerId)
|
b.setupPeer(peerId)
|
||||||
else:
|
else:
|
||||||
|
@ -314,7 +310,7 @@ method init*(b: BlockExcNetwork) =
|
||||||
b.switch.addPeerEventHandler(peerEventHandler, PeerEventKind.Left)
|
b.switch.addPeerEventHandler(peerEventHandler, PeerEventKind.Left)
|
||||||
|
|
||||||
proc handle(conn: Connection, proto: string) {.async, gcsafe, closure.} =
|
proc handle(conn: Connection, proto: string) {.async, gcsafe, closure.} =
|
||||||
let peerId = conn.peerInfo.peerId
|
let peerId = conn.peerId
|
||||||
let blockexcPeer = b.getOrCreatePeer(peerId)
|
let blockexcPeer = b.getOrCreatePeer(peerId)
|
||||||
await blockexcPeer.readLoop(conn) # attach read loop
|
await blockexcPeer.readLoop(conn) # attach read loop
|
||||||
|
|
||||||
|
|
|
@ -132,11 +132,8 @@ proc new*(
|
||||||
engine.scheduleTask = proc(task: BlockExcPeerCtx): bool {.gcsafe} =
|
engine.scheduleTask = proc(task: BlockExcPeerCtx): bool {.gcsafe} =
|
||||||
b.taskQueue.pushOrUpdateNoWait(task).isOk()
|
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
|
# TODO: temporary until libp2p moves back to PeerID
|
||||||
let
|
|
||||||
peerId = peerInfo.peerId
|
|
||||||
|
|
||||||
if event.kind == PeerEventKind.Joined:
|
if event.kind == PeerEventKind.Joined:
|
||||||
b.engine.setupPeer(peerId)
|
b.engine.setupPeer(peerId)
|
||||||
else:
|
else:
|
||||||
|
|
2
nim.cfg
2
nim.cfg
|
@ -1 +1 @@
|
||||||
-d:"chronicles_enabled=on" # disable logging by default
|
-d:"chronicles_log_level=INFO"
|
||||||
|
|
|
@ -21,7 +21,7 @@ suite "BlockExc engine basic":
|
||||||
let
|
let
|
||||||
rng = Rng.instance()
|
rng = Rng.instance()
|
||||||
seckey = PrivateKey.random(rng[]).tryGet()
|
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)
|
chunker = newRandomChunker(Rng.instance(), size = 1024, chunkSize = 256)
|
||||||
blocks = chunker.mapIt( !bt.Block.new(it) )
|
blocks = chunker.mapIt( !bt.Block.new(it) )
|
||||||
wallet = WalletRef.example
|
wallet = WalletRef.example
|
||||||
|
@ -73,7 +73,7 @@ suite "BlockExc engine handlers":
|
||||||
let
|
let
|
||||||
rng = Rng.instance()
|
rng = Rng.instance()
|
||||||
seckey = PrivateKey.random(rng[]).tryGet()
|
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)
|
chunker = newRandomChunker(Rng.instance(), size = 1024, chunkSize = 256)
|
||||||
blocks = chunker.mapIt( !bt.Block.new(it) )
|
blocks = chunker.mapIt( !bt.Block.new(it) )
|
||||||
wallet = WalletRef.example
|
wallet = WalletRef.example
|
||||||
|
@ -203,7 +203,7 @@ suite "Task Handler":
|
||||||
|
|
||||||
for i in 0..3:
|
for i in 0..3:
|
||||||
let seckey = PrivateKey.random(rng[]).tryGet()
|
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(
|
peersCtx.add(BlockExcPeerCtx(
|
||||||
id: peers[i]
|
id: peers[i]
|
||||||
|
|
|
@ -21,7 +21,7 @@ suite "BlockExc network":
|
||||||
let
|
let
|
||||||
rng = Rng.instance()
|
rng = Rng.instance()
|
||||||
seckey = PrivateKey.random(rng[]).tryGet()
|
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)
|
chunker = newRandomChunker(Rng.instance(), size = 1024, chunkSize = 256)
|
||||||
blocks = chunker.mapIt( !bt.Block.new(it) )
|
blocks = chunker.mapIt( !bt.Block.new(it) )
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ suite "BlockExc network":
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
done = newFuture[void]()
|
done = newFuture[void]()
|
||||||
buffer = newBufferStream()
|
buffer = BufferStream.new()
|
||||||
network = BlockExcNetwork.new(
|
network = BlockExcNetwork.new(
|
||||||
switch = newStandardSwitch(),
|
switch = newStandardSwitch(),
|
||||||
connProvider = getConn)
|
connProvider = getConn)
|
||||||
|
|
|
@ -46,7 +46,7 @@ proc example*(_: type Block): Block =
|
||||||
|
|
||||||
proc example*(_: type PeerId): PeerID =
|
proc example*(_: type PeerId): PeerID =
|
||||||
let key = PrivateKey.random(Rng.instance[]).get
|
let key = PrivateKey.random(Rng.instance[]).get
|
||||||
PeerId.init(key.getKey().get).get
|
PeerId.init(key.getPublicKey().get).get
|
||||||
|
|
||||||
proc example*(_: type BlockExcPeerCtx): BlockExcPeerCtx =
|
proc example*(_: type BlockExcPeerCtx): BlockExcPeerCtx =
|
||||||
BlockExcPeerCtx(id: PeerID.example)
|
BlockExcPeerCtx(id: PeerID.example)
|
||||||
|
|
Loading…
Reference in New Issue