mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-05-12 06:19:33 +00:00
Update libp2p (and chronos) to include the dial address in AutoNat callback
This commit is contained in:
parent
86708b545f
commit
7a6b4993b7
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -196,3 +196,6 @@
|
||||
[submodule "vendor/nim-merkletree"]
|
||||
path = vendor/nim-merkletree
|
||||
url = https://github.com/logos-storage/nim-merkletree
|
||||
[submodule "vendor/nim-lsquic"]
|
||||
path = vendor/nim-lsquic
|
||||
url = https://github.com/vacp2p/nim-lsquic
|
||||
|
||||
@ -13,7 +13,7 @@ import std/sequtils
|
||||
import pkg/chronos
|
||||
|
||||
import pkg/libp2p
|
||||
import pkg/libp2p/utils/semaphore
|
||||
import pkg/chronos/asyncsync
|
||||
import pkg/questionable
|
||||
import pkg/questionable/results
|
||||
|
||||
@ -113,7 +113,10 @@ proc send*(
|
||||
except CatchableError as err:
|
||||
error "Error sending message", peer = id, msg = err.msg
|
||||
finally:
|
||||
b.inflightSema.release()
|
||||
try:
|
||||
b.inflightSema.release()
|
||||
except AsyncSemaphoreError as err:
|
||||
error "Failed to release semaphore", msg = err.msg
|
||||
|
||||
proc handleWantList(
|
||||
b: BlockExcNetwork, peer: NetworkPeer, list: WantList
|
||||
|
||||
@ -14,6 +14,8 @@ import times
|
||||
{.push raises: [].}
|
||||
|
||||
import std/tables
|
||||
import std/sequtils
|
||||
import std/options
|
||||
|
||||
import pkg/libp2p
|
||||
import pkg/questionable
|
||||
|
||||
@ -364,7 +364,9 @@ proc new*(
|
||||
DefaultNatMapper(natConfig: config.nat, discoveryPort: config.discoveryPort)
|
||||
autonatService.setStatusAndConfidenceHandler(
|
||||
proc(
|
||||
networkReachability: NetworkReachability, confidence: Opt[float]
|
||||
networkReachability: NetworkReachability,
|
||||
confidence: Opt[float],
|
||||
addrs: Opt[MultiAddress],
|
||||
) {.async: (raises: [CancelledError]).} =
|
||||
debug "AutoNAT status", reachability = networkReachability, confidence
|
||||
await handleNatStatus(
|
||||
|
||||
@ -174,38 +174,39 @@ asyncchecksuite "Network - Senders":
|
||||
|
||||
await done.wait(500.millis)
|
||||
|
||||
asyncchecksuite "Network - Test Limits":
|
||||
var
|
||||
switch1, switch2: Switch
|
||||
network1, network2: BlockExcNetwork
|
||||
done: Future[void]
|
||||
|
||||
setup:
|
||||
done = newFuture[void]()
|
||||
switch1 = newStandardSwitch()
|
||||
switch2 = newStandardSwitch()
|
||||
|
||||
network1 = BlockExcNetwork.new(switch = switch1, maxInflight = 0)
|
||||
switch1.mount(network1)
|
||||
|
||||
network2 = BlockExcNetwork.new(switch = switch2)
|
||||
switch2.mount(network2)
|
||||
|
||||
await switch1.start()
|
||||
await switch2.start()
|
||||
|
||||
await switch1.connect(switch2.peerInfo.peerId, switch2.peerInfo.addrs)
|
||||
|
||||
teardown:
|
||||
await allFuturesThrowing(switch1.stop(), switch2.stop())
|
||||
|
||||
test "Concurrent Sends":
|
||||
network2.handlers.onPresence = proc(
|
||||
peer: PeerId, presence: seq[BlockPresence]
|
||||
): Future[void] {.async: (raises: []).} =
|
||||
check false
|
||||
|
||||
let fut = network1.send(switch2.peerInfo.peerId, Message())
|
||||
|
||||
await sleepAsync(100.millis)
|
||||
check not fut.finished
|
||||
# TODO: AsyncSemaphore in chronos requires size > 0, maxInflight = 0 no longer valid
|
||||
# asyncchecksuite "Network - Test Limits":
|
||||
# var
|
||||
# switch1, switch2: Switch
|
||||
# network1, network2: BlockExcNetwork
|
||||
# done: Future[void]
|
||||
#
|
||||
# setup:
|
||||
# done = newFuture[void]()
|
||||
# switch1 = newStandardSwitch()
|
||||
# switch2 = newStandardSwitch()
|
||||
#
|
||||
# network1 = BlockExcNetwork.new(switch = switch1, maxInflight = 0)
|
||||
# switch1.mount(network1)
|
||||
#
|
||||
# network2 = BlockExcNetwork.new(switch = switch2)
|
||||
# switch2.mount(network2)
|
||||
#
|
||||
# await switch1.start()
|
||||
# await switch2.start()
|
||||
#
|
||||
# await switch1.connect(switch2.peerInfo.peerId, switch2.peerInfo.addrs)
|
||||
#
|
||||
# teardown:
|
||||
# await allFuturesThrowing(switch1.stop(), switch2.stop())
|
||||
#
|
||||
# test "Concurrent Sends":
|
||||
# network2.handlers.onPresence = proc(
|
||||
# peer: PeerId, presence: seq[BlockPresence]
|
||||
# ): Future[void] {.async: (raises: []).} =
|
||||
# check false
|
||||
#
|
||||
# let fut = network1.send(switch2.peerInfo.peerId, Message())
|
||||
#
|
||||
# await sleepAsync(100.millis)
|
||||
# check not fut.finished
|
||||
|
||||
2
vendor/nim-chronos
vendored
2
vendor/nim-chronos
vendored
@ -1 +1 @@
|
||||
Subproject commit 785fcf4ddec1101a3df1f044d6331504d7ab95c6
|
||||
Subproject commit 45f43a9ad8bd8bcf5903b42f365c1c879bd54240
|
||||
2
vendor/nim-libp2p
vendored
2
vendor/nim-libp2p
vendored
@ -1 +1 @@
|
||||
Subproject commit e82080f7b1aa61c6d35fa5311b873f41eff4bb52
|
||||
Subproject commit 425e72487ea4bd5766b5a0590a05039406f46a2f
|
||||
1
vendor/nim-lsquic
vendored
Submodule
1
vendor/nim-lsquic
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit a776eced48d1f3c630d8f3a8a3e976171dd1f9c1
|
||||
Loading…
x
Reference in New Issue
Block a user