Broadcast pricing
This commit is contained in:
parent
e02c40db80
commit
6e7220efbb
|
@ -208,6 +208,15 @@ proc handlePricing(network: BitswapNetwork,
|
|||
return
|
||||
network.handlers.onPricing(peer.id, pricing)
|
||||
|
||||
proc broadcastPricing*(network: BitswapNetwork,
|
||||
id: PeerId,
|
||||
pricing: Pricing) =
|
||||
if id notin network.peers:
|
||||
return
|
||||
|
||||
let message = Message(pricing: PricingMessage.init(pricing))
|
||||
asyncSpawn network.peers[id].send(message)
|
||||
|
||||
proc handlePayment(network: BitswapNetwork,
|
||||
peer: NetworkPeer,
|
||||
payment: SignedState) =
|
||||
|
|
|
@ -225,3 +225,16 @@ suite "Bitswap Network - e2e":
|
|||
)))
|
||||
|
||||
await done.wait(500.millis)
|
||||
|
||||
test "broadcasts pricing":
|
||||
let pricing = Pricing.example
|
||||
|
||||
proc handlePricing(peer: PeerID, received: Pricing) =
|
||||
check received == pricing
|
||||
done.complete()
|
||||
|
||||
network2.handlers.onPricing = handlePricing
|
||||
|
||||
network1.broadcastPricing(switch2.peerInfo.peerId, pricing)
|
||||
|
||||
await done.wait(100.millis)
|
||||
|
|
Loading…
Reference in New Issue