change signatures to async and add raw: true
This commit is contained in:
parent
ec9a9125d3
commit
7aa922b90f
|
@ -83,7 +83,7 @@ type
|
|||
proc scheduleTask(b: BlockExcEngine, task: BlockExcPeerCtx): bool {.gcsafe} =
|
||||
b.taskQueue.pushOrUpdateNoWait(task).isOk()
|
||||
|
||||
proc blockexcTaskRunner(b: BlockExcEngine): Future[void] {.gcsafe, raises: [].}
|
||||
proc blockexcTaskRunner(b: BlockExcEngine): Future[void] {.gcsafe, async.}
|
||||
|
||||
proc start*(b: BlockExcEngine) {.async.} =
|
||||
## Start the blockexc task
|
||||
|
|
|
@ -34,11 +34,11 @@ const
|
|||
MaxInflight* = 100
|
||||
|
||||
type
|
||||
WantListHandler* = proc(peer: PeerId, wantList: WantList): Future[void] {.gcsafe, raises: [].}
|
||||
BlocksDeliveryHandler* = proc(peer: PeerId, blocks: seq[BlockDelivery]): Future[void] {.gcsafe, raises: [].}
|
||||
BlockPresenceHandler* = proc(peer: PeerId, precense: seq[BlockPresence]): Future[void] {.gcsafe, raises: [].}
|
||||
AccountHandler* = proc(peer: PeerId, account: Account): Future[void] {.gcsafe, raises: [].}
|
||||
PaymentHandler* = proc(peer: PeerId, payment: SignedState): Future[void] {.gcsafe, raises: [].}
|
||||
WantListHandler* = proc(peer: PeerId, wantList: WantList): Future[void] {.gcsafe, async.}
|
||||
BlocksDeliveryHandler* = proc(peer: PeerId, blocks: seq[BlockDelivery]): Future[void] {.gcsafe, async.}
|
||||
BlockPresenceHandler* = proc(peer: PeerId, precense: seq[BlockPresence]): Future[void] {.gcsafe, async.}
|
||||
AccountHandler* = proc(peer: PeerId, account: Account): Future[void] {.gcsafe, async.}
|
||||
PaymentHandler* = proc(peer: PeerId, payment: SignedState): Future[void] {.gcsafe, async.}
|
||||
WantListSender* = proc(
|
||||
id: PeerId,
|
||||
addresses: seq[BlockAddress],
|
||||
|
@ -46,7 +46,7 @@ type
|
|||
cancel: bool = false,
|
||||
wantType: WantType = WantType.WantHave,
|
||||
full: bool = false,
|
||||
sendDontHave: bool = false): Future[void] {.gcsafe, raises: [].}
|
||||
sendDontHave: bool = false): Future[void] {.gcsafe, async.}
|
||||
|
||||
BlockExcHandlers* = object
|
||||
onWantList*: WantListHandler
|
||||
|
@ -55,10 +55,10 @@ type
|
|||
onAccount*: AccountHandler
|
||||
onPayment*: PaymentHandler
|
||||
|
||||
BlocksDeliverySender* = proc(peer: PeerId, blocksDelivery: seq[BlockDelivery]): Future[void] {.gcsafe, raises: [].}
|
||||
PresenceSender* = proc(peer: PeerId, presence: seq[BlockPresence]): Future[void] {.gcsafe, raises: [].}
|
||||
AccountSender* = proc(peer: PeerId, account: Account): Future[void] {.gcsafe, raises: [].}
|
||||
PaymentSender* = proc(peer: PeerId, payment: SignedState): Future[void] {.gcsafe, raises: [].}
|
||||
BlocksDeliverySender* = proc(peer: PeerId, blocksDelivery: seq[BlockDelivery]): Future[void] {.gcsafe, async.}
|
||||
PresenceSender* = proc(peer: PeerId, presence: seq[BlockPresence]): Future[void] {.gcsafe, async.}
|
||||
AccountSender* = proc(peer: PeerId, account: Account): Future[void] {.gcsafe, async.}
|
||||
PaymentSender* = proc(peer: PeerId, payment: SignedState): Future[void] {.gcsafe, async.}
|
||||
|
||||
BlockExcRequest* = object
|
||||
sendWantList*: WantListSender
|
||||
|
@ -122,7 +122,7 @@ proc sendWantList*(
|
|||
cancel: bool = false,
|
||||
wantType: WantType = WantType.WantHave,
|
||||
full: bool = false,
|
||||
sendDontHave: bool = false): Future[void] =
|
||||
sendDontHave: bool = false): Future[void] {.async: (raw: true).}=
|
||||
## Send a want message to peer
|
||||
##
|
||||
|
||||
|
@ -154,7 +154,7 @@ proc handleBlocksDelivery(
|
|||
proc sendBlocksDelivery*(
|
||||
b: BlockExcNetwork,
|
||||
id: PeerId,
|
||||
blocksDelivery: seq[BlockDelivery]): Future[void] =
|
||||
blocksDelivery: seq[BlockDelivery]): Future[void] {.async: (raw: true).} =
|
||||
## Send blocks to remote
|
||||
##
|
||||
|
||||
|
@ -174,7 +174,7 @@ proc handleBlockPresence(
|
|||
proc sendBlockPresence*(
|
||||
b: BlockExcNetwork,
|
||||
id: PeerId,
|
||||
presence: seq[BlockPresence]): Future[void] =
|
||||
presence: seq[BlockPresence]): Future[void] {.async: (raw: true).} =
|
||||
## Send presence to remote
|
||||
##
|
||||
|
||||
|
@ -193,7 +193,7 @@ proc handleAccount(
|
|||
proc sendAccount*(
|
||||
b: BlockExcNetwork,
|
||||
id: PeerId,
|
||||
account: Account): Future[void] =
|
||||
account: Account): Future[void] {.async: (raw: true).} =
|
||||
## Send account info to remote
|
||||
##
|
||||
|
||||
|
@ -202,7 +202,7 @@ proc sendAccount*(
|
|||
proc sendPayment*(
|
||||
b: BlockExcNetwork,
|
||||
id: PeerId,
|
||||
payment: SignedState): Future[void] =
|
||||
payment: SignedState): Future[void] {.async: (raw: true).} =
|
||||
## Send payment to remote
|
||||
##
|
||||
|
||||
|
@ -259,7 +259,7 @@ proc getOrCreatePeer(b: BlockExcNetwork, peer: PeerId): NetworkPeer =
|
|||
if not isNil(b.getConn):
|
||||
getConn = b.getConn
|
||||
|
||||
let rpcHandler = proc (p: NetworkPeer, msg: Message): Future[void] =
|
||||
let rpcHandler = proc (p: NetworkPeer, msg: Message): Future[void] {.async: (raw: true).}=
|
||||
b.rpcHandler(p, msg)
|
||||
|
||||
# create new pubsub peer
|
||||
|
@ -340,16 +340,16 @@ proc new*(
|
|||
id, cids, priority, cancel,
|
||||
wantType, full, sendDontHave)
|
||||
|
||||
proc sendBlocksDelivery(id: PeerId, blocksDelivery: seq[BlockDelivery]): Future[void] {.gcsafe.} =
|
||||
proc sendBlocksDelivery(id: PeerId, blocksDelivery: seq[BlockDelivery]): Future[void] {.gcsafe, async: (raw: true).} =
|
||||
self.sendBlocksDelivery(id, blocksDelivery)
|
||||
|
||||
proc sendPresence(id: PeerId, presence: seq[BlockPresence]): Future[void] {.gcsafe.} =
|
||||
proc sendPresence(id: PeerId, presence: seq[BlockPresence]): Future[void] {.gcsafe, async: (raw: true).} =
|
||||
self.sendBlockPresence(id, presence)
|
||||
|
||||
proc sendAccount(id: PeerId, account: Account): Future[void] {.gcsafe.} =
|
||||
proc sendAccount(id: PeerId, account: Account): Future[void] {.gcsafe, async: (raw: true).} =
|
||||
self.sendAccount(id, account)
|
||||
|
||||
proc sendPayment(id: PeerId, payment: SignedState): Future[void] {.gcsafe.} =
|
||||
proc sendPayment(id: PeerId, payment: SignedState): Future[void] {.gcsafe, async: (raw: true).} =
|
||||
self.sendPayment(id, payment)
|
||||
|
||||
self.request = BlockExcRequest(
|
||||
|
|
|
@ -22,9 +22,9 @@ logScope:
|
|||
topics = "codex blockexcnetworkpeer"
|
||||
|
||||
type
|
||||
ConnProvider* = proc (): Future[Connection] {.gcsafe, closure, raises: [].}
|
||||
ConnProvider* = proc (): Future[Connection] {.gcsafe, closure, async.}
|
||||
|
||||
RPCHandler* = proc (peer: NetworkPeer, msg: Message): Future[void] {.gcsafe, raises: [].}
|
||||
RPCHandler* = proc (peer: NetworkPeer, msg: Message): Future[void] {.gcsafe, async.}
|
||||
|
||||
NetworkPeer* = ref object of RootObj
|
||||
id*: PeerId
|
||||
|
|
|
@ -29,7 +29,7 @@ const
|
|||
type
|
||||
# default reader type
|
||||
ChunkBuffer* = ptr UncheckedArray[byte]
|
||||
Reader* = proc(data: ChunkBuffer, len: int): Future[int] {.gcsafe, raises: [Defect].}
|
||||
Reader* = proc(data: ChunkBuffer, len: int): Future[int] {.gcsafe, async.}
|
||||
|
||||
# Reader that splits input data into fixed-size chunks
|
||||
Chunker* = ref object
|
||||
|
|
|
@ -129,7 +129,7 @@ method provide*(d: Discovery, host: ca.Address) {.async, base.} =
|
|||
|
||||
method removeProvider*(
|
||||
d: Discovery,
|
||||
peerId: PeerId): Future[void] {.base, raises: [].} =
|
||||
peerId: PeerId): Future[void] {.base, async: (raw: true).} =
|
||||
## Remove provider from providers table
|
||||
##
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ type
|
|||
CodexNodeRef* = ref CodexNode
|
||||
|
||||
OnManifest* = proc(cid: Cid, manifest: Manifest): void {.gcsafe, raises: [].}
|
||||
BatchProc* = proc(blocks: seq[bt.Block]): Future[?!void] {.gcsafe, raises: [].}
|
||||
BatchProc* = proc(blocks: seq[bt.Block]): Future[?!void] {.gcsafe, async.}
|
||||
|
||||
func switch*(self: CodexNodeRef): Switch =
|
||||
return self.switch
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import pkg/questionable
|
||||
import pkg/questionable/results
|
||||
import pkg/upraises
|
||||
|
||||
import ../market
|
||||
import ../clock
|
||||
|
@ -23,13 +22,13 @@ type
|
|||
slotQueue*: SlotQueue
|
||||
simulateProofFailures*: int
|
||||
|
||||
BlocksCb* = proc(blocks: seq[bt.Block]): Future[?!void] {.gcsafe, raises: [].}
|
||||
BlocksCb* = proc(blocks: seq[bt.Block]): Future[?!void] {.gcsafe, async.}
|
||||
OnStore* = proc(request: StorageRequest,
|
||||
slot: UInt256,
|
||||
blocksCb: BlocksCb): Future[?!void] {.gcsafe, upraises: [].}
|
||||
OnProve* = proc(slot: Slot, challenge: ProofChallenge): Future[?!seq[byte]] {.gcsafe, upraises: [].}
|
||||
OnExpiryUpdate* = proc(rootCid: string, expiry: SecondsSince1970): Future[?!void] {.gcsafe, upraises: [].}
|
||||
blocksCb: BlocksCb): Future[?!void] {.gcsafe, async.}
|
||||
OnProve* = proc(slot: Slot, challenge: ProofChallenge): Future[seq[byte]] {.gcsafe, async.}
|
||||
OnExpiryUpdate* = proc(rootCid: string, expiry: SecondsSince1970): Future[?!void] {.gcsafe, async.}
|
||||
OnClear* = proc(request: StorageRequest,
|
||||
slotIndex: UInt256) {.gcsafe, upraises: [].}
|
||||
slotIndex: UInt256) {.gcsafe, raises: [].}
|
||||
OnSale* = proc(request: StorageRequest,
|
||||
slotIndex: UInt256) {.gcsafe, upraises: [].}
|
||||
slotIndex: UInt256) {.gcsafe, raises: [].}
|
||||
|
|
|
@ -19,23 +19,23 @@ proc new*(
|
|||
## Create a chunker that produces data
|
||||
##
|
||||
|
||||
let
|
||||
let
|
||||
chunkSize = chunkSize.NBytes
|
||||
dataset = @dataset
|
||||
|
||||
|
||||
var consumed = 0
|
||||
proc reader(data: ChunkBuffer, len: int): Future[int] {.async, gcsafe, raises: [Defect].} =
|
||||
proc reader(data: ChunkBuffer, len: int): Future[int] {.async, gcsafe.} =
|
||||
|
||||
if consumed >= dataset.len:
|
||||
return 0
|
||||
|
||||
var read = 0
|
||||
while read < len and
|
||||
while read < len and
|
||||
read < chunkSize.int and
|
||||
(consumed + read) < dataset.len:
|
||||
data[read] = dataset[consumed + read]
|
||||
read.inc
|
||||
|
||||
|
||||
consumed += read
|
||||
return read
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@ import pkg/contractabi/address as ca
|
|||
type
|
||||
MockDiscovery* = ref object of Discovery
|
||||
findBlockProvidersHandler*: proc(d: MockDiscovery, cid: Cid):
|
||||
Future[seq[SignedPeerRecord]] {.gcsafe, raises: [].}
|
||||
Future[seq[SignedPeerRecord]] {.gcsafe, async.}
|
||||
publishBlockProvideHandler*: proc(d: MockDiscovery, cid: Cid):
|
||||
Future[void] {.gcsafe, raises: [].}
|
||||
Future[void] {.gcsafe, async.}
|
||||
findHostProvidersHandler*: proc(d: MockDiscovery, host: ca.Address):
|
||||
Future[seq[SignedPeerRecord]] {.gcsafe, raises: [].}
|
||||
Future[seq[SignedPeerRecord]] {.gcsafe, async.}
|
||||
publishHostProvideHandler*: proc(d: MockDiscovery, host: ca.Address):
|
||||
Future[void] {.gcsafe, raises: [].}
|
||||
Future[void] {.gcsafe, async.}
|
||||
|
||||
proc new*(T: type MockDiscovery): MockDiscovery =
|
||||
MockDiscovery()
|
||||
|
|
Loading…
Reference in New Issue