mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-05 23:13:09 +00:00
chore: drop usage of upraises (#1348)
This commit is contained in:
parent
bd36032251
commit
9ac9f6ff3c
@ -926,7 +926,7 @@ iterator splitBatches[T](sequence: seq[T], batchSize: int): seq[T] =
|
|||||||
|
|
||||||
proc taskHandler*(
|
proc taskHandler*(
|
||||||
self: BlockExcEngine, peerCtx: BlockExcPeerCtx
|
self: BlockExcEngine, peerCtx: BlockExcPeerCtx
|
||||||
) {.gcsafe, async: (raises: [CancelledError, RetriesExhaustedError]).} =
|
) {.async: (raises: [CancelledError, RetriesExhaustedError]).} =
|
||||||
# Send to the peer blocks he wants to get,
|
# Send to the peer blocks he wants to get,
|
||||||
# if they present in our local store
|
# if they present in our local store
|
||||||
|
|
||||||
|
|||||||
@ -35,16 +35,14 @@ const
|
|||||||
DefaultMaxInflight* = 100
|
DefaultMaxInflight* = 100
|
||||||
|
|
||||||
type
|
type
|
||||||
WantListHandler* =
|
WantListHandler* = proc(peer: PeerId, wantList: WantList) {.async: (raises: []).}
|
||||||
proc(peer: PeerId, wantList: WantList) {.gcsafe, async: (raises: []).}
|
|
||||||
BlocksDeliveryHandler* =
|
BlocksDeliveryHandler* =
|
||||||
proc(peer: PeerId, blocks: seq[BlockDelivery]) {.gcsafe, async: (raises: []).}
|
proc(peer: PeerId, blocks: seq[BlockDelivery]) {.async: (raises: []).}
|
||||||
BlockPresenceHandler* =
|
BlockPresenceHandler* =
|
||||||
proc(peer: PeerId, precense: seq[BlockPresence]) {.gcsafe, async: (raises: []).}
|
proc(peer: PeerId, precense: seq[BlockPresence]) {.async: (raises: []).}
|
||||||
AccountHandler* = proc(peer: PeerId, account: Account) {.gcsafe, async: (raises: []).}
|
AccountHandler* = proc(peer: PeerId, account: Account) {.async: (raises: []).}
|
||||||
PaymentHandler* =
|
PaymentHandler* = proc(peer: PeerId, payment: SignedState) {.async: (raises: []).}
|
||||||
proc(peer: PeerId, payment: SignedState) {.gcsafe, async: (raises: []).}
|
PeerEventHandler* = proc(peer: PeerId) {.async: (raises: [CancelledError]).}
|
||||||
PeerEventHandler* = proc(peer: PeerId) {.gcsafe, async: (raises: [CancelledError]).}
|
|
||||||
|
|
||||||
BlockExcHandlers* = object
|
BlockExcHandlers* = object
|
||||||
onWantList*: WantListHandler
|
onWantList*: WantListHandler
|
||||||
@ -347,7 +345,7 @@ method init*(self: BlockExcNetwork) {.raises: [].} =
|
|||||||
|
|
||||||
proc peerEventHandler(
|
proc peerEventHandler(
|
||||||
peerId: PeerId, event: PeerEvent
|
peerId: PeerId, event: PeerEvent
|
||||||
): Future[void] {.gcsafe, async: (raises: [CancelledError]).} =
|
): Future[void] {.async: (raises: [CancelledError]).} =
|
||||||
if event.kind == PeerEventKind.Joined:
|
if event.kind == PeerEventKind.Joined:
|
||||||
await self.handlePeerJoined(peerId)
|
await self.handlePeerJoined(peerId)
|
||||||
elif event.kind == PeerEventKind.Left:
|
elif event.kind == PeerEventKind.Left:
|
||||||
|
|||||||
@ -24,10 +24,9 @@ logScope:
|
|||||||
const DefaultYieldInterval = 50.millis
|
const DefaultYieldInterval = 50.millis
|
||||||
|
|
||||||
type
|
type
|
||||||
ConnProvider* =
|
ConnProvider* = proc(): Future[Connection] {.async: (raises: [CancelledError]).}
|
||||||
proc(): Future[Connection] {.gcsafe, async: (raises: [CancelledError]).}
|
|
||||||
|
|
||||||
RPCHandler* = proc(peer: NetworkPeer, msg: Message) {.gcsafe, async: (raises: []).}
|
RPCHandler* = proc(peer: NetworkPeer, msg: Message) {.async: (raises: []).}
|
||||||
|
|
||||||
NetworkPeer* = ref object of RootObj
|
NetworkPeer* = ref object of RootObj
|
||||||
id*: PeerId
|
id*: PeerId
|
||||||
|
|||||||
@ -13,10 +13,7 @@ import std/hashes
|
|||||||
|
|
||||||
export tables
|
export tables
|
||||||
|
|
||||||
import pkg/upraises
|
{.push raises: [], gcsafe.}
|
||||||
|
|
||||||
push:
|
|
||||||
{.upraises: [].}
|
|
||||||
|
|
||||||
import pkg/libp2p/[cid, multicodec, multihash]
|
import pkg/libp2p/[cid, multicodec, multihash]
|
||||||
import pkg/stew/[byteutils, endians2]
|
import pkg/stew/[byteutils, endians2]
|
||||||
|
|||||||
@ -9,10 +9,7 @@
|
|||||||
|
|
||||||
# TODO: This is super inneficient and needs a rewrite, but it'll do for now
|
# TODO: This is super inneficient and needs a rewrite, but it'll do for now
|
||||||
|
|
||||||
import pkg/upraises
|
{.push raises: [], gcsafe.}
|
||||||
|
|
||||||
push:
|
|
||||||
{.upraises: [].}
|
|
||||||
|
|
||||||
import pkg/questionable
|
import pkg/questionable
|
||||||
import pkg/questionable/results
|
import pkg/questionable/results
|
||||||
@ -31,7 +28,7 @@ type
|
|||||||
ChunkerError* = object of CatchableError
|
ChunkerError* = object of CatchableError
|
||||||
ChunkBuffer* = ptr UncheckedArray[byte]
|
ChunkBuffer* = ptr UncheckedArray[byte]
|
||||||
Reader* = proc(data: ChunkBuffer, len: int): Future[int] {.
|
Reader* = proc(data: ChunkBuffer, len: int): Future[int] {.
|
||||||
gcsafe, async: (raises: [ChunkerError, CancelledError])
|
async: (raises: [ChunkerError, CancelledError])
|
||||||
.}
|
.}
|
||||||
|
|
||||||
# Reader that splits input data into fixed-size chunks
|
# Reader that splits input data into fixed-size chunks
|
||||||
@ -77,7 +74,7 @@ proc new*(
|
|||||||
|
|
||||||
proc reader(
|
proc reader(
|
||||||
data: ChunkBuffer, len: int
|
data: ChunkBuffer, len: int
|
||||||
): Future[int] {.gcsafe, async: (raises: [ChunkerError, CancelledError]).} =
|
): Future[int] {.async: (raises: [ChunkerError, CancelledError]).} =
|
||||||
var res = 0
|
var res = 0
|
||||||
try:
|
try:
|
||||||
while res < len:
|
while res < len:
|
||||||
@ -105,7 +102,7 @@ proc new*(
|
|||||||
|
|
||||||
proc reader(
|
proc reader(
|
||||||
data: ChunkBuffer, len: int
|
data: ChunkBuffer, len: int
|
||||||
): Future[int] {.gcsafe, async: (raises: [ChunkerError, CancelledError]).} =
|
): Future[int] {.async: (raises: [ChunkerError, CancelledError]).} =
|
||||||
var total = 0
|
var total = 0
|
||||||
try:
|
try:
|
||||||
while total < len:
|
while total < len:
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
import pkg/chronos
|
import pkg/chronos
|
||||||
import pkg/stew/endians2
|
import pkg/stew/endians2
|
||||||
import pkg/upraises
|
|
||||||
import pkg/stint
|
import pkg/stint
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -10,7 +9,7 @@ type
|
|||||||
SecondsSince1970* = int64
|
SecondsSince1970* = int64
|
||||||
Timeout* = object of CatchableError
|
Timeout* = object of CatchableError
|
||||||
|
|
||||||
method now*(clock: Clock): SecondsSince1970 {.base, gcsafe, upraises: [].} =
|
method now*(clock: Clock): SecondsSince1970 {.base, gcsafe, raises: [].} =
|
||||||
raiseAssert "not implemented"
|
raiseAssert "not implemented"
|
||||||
|
|
||||||
method waitUntil*(
|
method waitUntil*(
|
||||||
|
|||||||
@ -514,7 +514,7 @@ const
|
|||||||
|
|
||||||
proc parseCmdArg*(
|
proc parseCmdArg*(
|
||||||
T: typedesc[MultiAddress], input: string
|
T: typedesc[MultiAddress], input: string
|
||||||
): MultiAddress {.upraises: [ValueError].} =
|
): MultiAddress {.raises: [ValueError].} =
|
||||||
var ma: MultiAddress
|
var ma: MultiAddress
|
||||||
try:
|
try:
|
||||||
let res = MultiAddress.init(input)
|
let res = MultiAddress.init(input)
|
||||||
@ -619,7 +619,7 @@ proc parseCmdArg*(T: type Duration, val: string): T =
|
|||||||
|
|
||||||
proc readValue*(
|
proc readValue*(
|
||||||
r: var TomlReader, val: var EthAddress
|
r: var TomlReader, val: var EthAddress
|
||||||
) {.upraises: [SerializationError, IOError].} =
|
) {.raises: [SerializationError, IOError].} =
|
||||||
val = EthAddress.init(r.readValue(string)).get()
|
val = EthAddress.init(r.readValue(string)).get()
|
||||||
|
|
||||||
proc readValue*(r: var TomlReader, val: var SignedPeerRecord) =
|
proc readValue*(r: var TomlReader, val: var SignedPeerRecord) =
|
||||||
@ -647,7 +647,7 @@ proc readValue*(r: var TomlReader, val: var MultiAddress) =
|
|||||||
|
|
||||||
proc readValue*(
|
proc readValue*(
|
||||||
r: var TomlReader, val: var NBytes
|
r: var TomlReader, val: var NBytes
|
||||||
) {.upraises: [SerializationError, IOError].} =
|
) {.raises: [SerializationError, IOError].} =
|
||||||
var value = 0'i64
|
var value = 0'i64
|
||||||
var str = r.readValue(string)
|
var str = r.readValue(string)
|
||||||
let count = parseSize(str, value, alwaysBin = true)
|
let count = parseSize(str, value, alwaysBin = true)
|
||||||
@ -658,7 +658,7 @@ proc readValue*(
|
|||||||
|
|
||||||
proc readValue*(
|
proc readValue*(
|
||||||
r: var TomlReader, val: var ThreadCount
|
r: var TomlReader, val: var ThreadCount
|
||||||
) {.upraises: [SerializationError, IOError].} =
|
) {.raises: [SerializationError, IOError].} =
|
||||||
var str = r.readValue(string)
|
var str = r.readValue(string)
|
||||||
try:
|
try:
|
||||||
val = parseCmdArg(ThreadCount, str)
|
val = parseCmdArg(ThreadCount, str)
|
||||||
@ -667,7 +667,7 @@ proc readValue*(
|
|||||||
|
|
||||||
proc readValue*(
|
proc readValue*(
|
||||||
r: var TomlReader, val: var Duration
|
r: var TomlReader, val: var Duration
|
||||||
) {.upraises: [SerializationError, IOError].} =
|
) {.raises: [SerializationError, IOError].} =
|
||||||
var str = r.readValue(string)
|
var str = r.readValue(string)
|
||||||
var dur: Duration
|
var dur: Duration
|
||||||
let count = parseDuration(str, dur)
|
let count = parseDuration(str, dur)
|
||||||
@ -734,7 +734,7 @@ proc stripAnsi*(v: string): string =
|
|||||||
|
|
||||||
res
|
res
|
||||||
|
|
||||||
proc updateLogLevel*(logLevel: string) {.upraises: [ValueError].} =
|
proc updateLogLevel*(logLevel: string) {.raises: [ValueError].} =
|
||||||
# Updates log levels (without clearing old ones)
|
# Updates log levels (without clearing old ones)
|
||||||
let directives = logLevel.split(";")
|
let directives = logLevel.split(";")
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import std/strformat
|
import std/strformat
|
||||||
import std/strutils
|
import std/strutils
|
||||||
import pkg/ethers
|
import pkg/ethers
|
||||||
import pkg/upraises
|
|
||||||
import pkg/questionable
|
import pkg/questionable
|
||||||
import pkg/lrucache
|
import pkg/lrucache
|
||||||
import ../utils/exceptions
|
import ../utils/exceptions
|
||||||
@ -436,7 +435,7 @@ method canReserveSlot*(
|
|||||||
method subscribeRequests*(
|
method subscribeRequests*(
|
||||||
market: OnChainMarket, callback: OnRequest
|
market: OnChainMarket, callback: OnRequest
|
||||||
): Future[MarketSubscription] {.async.} =
|
): Future[MarketSubscription] {.async.} =
|
||||||
proc onEvent(eventResult: ?!StorageRequested) {.upraises: [].} =
|
proc onEvent(eventResult: ?!StorageRequested) {.raises: [].} =
|
||||||
without event =? eventResult, eventErr:
|
without event =? eventResult, eventErr:
|
||||||
error "There was an error in Request subscription", msg = eventErr.msg
|
error "There was an error in Request subscription", msg = eventErr.msg
|
||||||
return
|
return
|
||||||
@ -450,7 +449,7 @@ method subscribeRequests*(
|
|||||||
method subscribeSlotFilled*(
|
method subscribeSlotFilled*(
|
||||||
market: OnChainMarket, callback: OnSlotFilled
|
market: OnChainMarket, callback: OnSlotFilled
|
||||||
): Future[MarketSubscription] {.async.} =
|
): Future[MarketSubscription] {.async.} =
|
||||||
proc onEvent(eventResult: ?!SlotFilled) {.upraises: [].} =
|
proc onEvent(eventResult: ?!SlotFilled) {.raises: [].} =
|
||||||
without event =? eventResult, eventErr:
|
without event =? eventResult, eventErr:
|
||||||
error "There was an error in SlotFilled subscription", msg = eventErr.msg
|
error "There was an error in SlotFilled subscription", msg = eventErr.msg
|
||||||
return
|
return
|
||||||
@ -477,7 +476,7 @@ method subscribeSlotFilled*(
|
|||||||
method subscribeSlotFreed*(
|
method subscribeSlotFreed*(
|
||||||
market: OnChainMarket, callback: OnSlotFreed
|
market: OnChainMarket, callback: OnSlotFreed
|
||||||
): Future[MarketSubscription] {.async.} =
|
): Future[MarketSubscription] {.async.} =
|
||||||
proc onEvent(eventResult: ?!SlotFreed) {.upraises: [].} =
|
proc onEvent(eventResult: ?!SlotFreed) {.raises: [].} =
|
||||||
without event =? eventResult, eventErr:
|
without event =? eventResult, eventErr:
|
||||||
error "There was an error in SlotFreed subscription", msg = eventErr.msg
|
error "There was an error in SlotFreed subscription", msg = eventErr.msg
|
||||||
return
|
return
|
||||||
@ -491,7 +490,7 @@ method subscribeSlotFreed*(
|
|||||||
method subscribeSlotReservationsFull*(
|
method subscribeSlotReservationsFull*(
|
||||||
market: OnChainMarket, callback: OnSlotReservationsFull
|
market: OnChainMarket, callback: OnSlotReservationsFull
|
||||||
): Future[MarketSubscription] {.async.} =
|
): Future[MarketSubscription] {.async.} =
|
||||||
proc onEvent(eventResult: ?!SlotReservationsFull) {.upraises: [].} =
|
proc onEvent(eventResult: ?!SlotReservationsFull) {.raises: [].} =
|
||||||
without event =? eventResult, eventErr:
|
without event =? eventResult, eventErr:
|
||||||
error "There was an error in SlotReservationsFull subscription",
|
error "There was an error in SlotReservationsFull subscription",
|
||||||
msg = eventErr.msg
|
msg = eventErr.msg
|
||||||
@ -506,7 +505,7 @@ method subscribeSlotReservationsFull*(
|
|||||||
method subscribeFulfillment(
|
method subscribeFulfillment(
|
||||||
market: OnChainMarket, callback: OnFulfillment
|
market: OnChainMarket, callback: OnFulfillment
|
||||||
): Future[MarketSubscription] {.async.} =
|
): Future[MarketSubscription] {.async.} =
|
||||||
proc onEvent(eventResult: ?!RequestFulfilled) {.upraises: [].} =
|
proc onEvent(eventResult: ?!RequestFulfilled) {.raises: [].} =
|
||||||
without event =? eventResult, eventErr:
|
without event =? eventResult, eventErr:
|
||||||
error "There was an error in RequestFulfillment subscription", msg = eventErr.msg
|
error "There was an error in RequestFulfillment subscription", msg = eventErr.msg
|
||||||
return
|
return
|
||||||
@ -520,7 +519,7 @@ method subscribeFulfillment(
|
|||||||
method subscribeFulfillment(
|
method subscribeFulfillment(
|
||||||
market: OnChainMarket, requestId: RequestId, callback: OnFulfillment
|
market: OnChainMarket, requestId: RequestId, callback: OnFulfillment
|
||||||
): Future[MarketSubscription] {.async.} =
|
): Future[MarketSubscription] {.async.} =
|
||||||
proc onEvent(eventResult: ?!RequestFulfilled) {.upraises: [].} =
|
proc onEvent(eventResult: ?!RequestFulfilled) {.raises: [].} =
|
||||||
without event =? eventResult, eventErr:
|
without event =? eventResult, eventErr:
|
||||||
error "There was an error in RequestFulfillment subscription", msg = eventErr.msg
|
error "There was an error in RequestFulfillment subscription", msg = eventErr.msg
|
||||||
return
|
return
|
||||||
@ -535,7 +534,7 @@ method subscribeFulfillment(
|
|||||||
method subscribeRequestCancelled*(
|
method subscribeRequestCancelled*(
|
||||||
market: OnChainMarket, callback: OnRequestCancelled
|
market: OnChainMarket, callback: OnRequestCancelled
|
||||||
): Future[MarketSubscription] {.async.} =
|
): Future[MarketSubscription] {.async.} =
|
||||||
proc onEvent(eventResult: ?!RequestCancelled) {.upraises: [].} =
|
proc onEvent(eventResult: ?!RequestCancelled) {.raises: [].} =
|
||||||
without event =? eventResult, eventErr:
|
without event =? eventResult, eventErr:
|
||||||
error "There was an error in RequestCancelled subscription", msg = eventErr.msg
|
error "There was an error in RequestCancelled subscription", msg = eventErr.msg
|
||||||
return
|
return
|
||||||
@ -549,7 +548,7 @@ method subscribeRequestCancelled*(
|
|||||||
method subscribeRequestCancelled*(
|
method subscribeRequestCancelled*(
|
||||||
market: OnChainMarket, requestId: RequestId, callback: OnRequestCancelled
|
market: OnChainMarket, requestId: RequestId, callback: OnRequestCancelled
|
||||||
): Future[MarketSubscription] {.async.} =
|
): Future[MarketSubscription] {.async.} =
|
||||||
proc onEvent(eventResult: ?!RequestCancelled) {.upraises: [].} =
|
proc onEvent(eventResult: ?!RequestCancelled) {.raises: [].} =
|
||||||
without event =? eventResult, eventErr:
|
without event =? eventResult, eventErr:
|
||||||
error "There was an error in RequestCancelled subscription", msg = eventErr.msg
|
error "There was an error in RequestCancelled subscription", msg = eventErr.msg
|
||||||
return
|
return
|
||||||
@ -564,7 +563,7 @@ method subscribeRequestCancelled*(
|
|||||||
method subscribeRequestFailed*(
|
method subscribeRequestFailed*(
|
||||||
market: OnChainMarket, callback: OnRequestFailed
|
market: OnChainMarket, callback: OnRequestFailed
|
||||||
): Future[MarketSubscription] {.async.} =
|
): Future[MarketSubscription] {.async.} =
|
||||||
proc onEvent(eventResult: ?!RequestFailed) {.upraises: [].} =
|
proc onEvent(eventResult: ?!RequestFailed) {.raises: [].} =
|
||||||
without event =? eventResult, eventErr:
|
without event =? eventResult, eventErr:
|
||||||
error "There was an error in RequestFailed subscription", msg = eventErr.msg
|
error "There was an error in RequestFailed subscription", msg = eventErr.msg
|
||||||
return
|
return
|
||||||
@ -578,7 +577,7 @@ method subscribeRequestFailed*(
|
|||||||
method subscribeRequestFailed*(
|
method subscribeRequestFailed*(
|
||||||
market: OnChainMarket, requestId: RequestId, callback: OnRequestFailed
|
market: OnChainMarket, requestId: RequestId, callback: OnRequestFailed
|
||||||
): Future[MarketSubscription] {.async.} =
|
): Future[MarketSubscription] {.async.} =
|
||||||
proc onEvent(eventResult: ?!RequestFailed) {.upraises: [].} =
|
proc onEvent(eventResult: ?!RequestFailed) {.raises: [].} =
|
||||||
without event =? eventResult, eventErr:
|
without event =? eventResult, eventErr:
|
||||||
error "There was an error in RequestFailed subscription", msg = eventErr.msg
|
error "There was an error in RequestFailed subscription", msg = eventErr.msg
|
||||||
return
|
return
|
||||||
@ -593,7 +592,7 @@ method subscribeRequestFailed*(
|
|||||||
method subscribeProofSubmission*(
|
method subscribeProofSubmission*(
|
||||||
market: OnChainMarket, callback: OnProofSubmitted
|
market: OnChainMarket, callback: OnProofSubmitted
|
||||||
): Future[MarketSubscription] {.async.} =
|
): Future[MarketSubscription] {.async.} =
|
||||||
proc onEvent(eventResult: ?!ProofSubmitted) {.upraises: [].} =
|
proc onEvent(eventResult: ?!ProofSubmitted) {.raises: [].} =
|
||||||
without event =? eventResult, eventErr:
|
without event =? eventResult, eventErr:
|
||||||
error "There was an error in ProofSubmitted subscription", msg = eventErr.msg
|
error "There was an error in ProofSubmitted subscription", msg = eventErr.msg
|
||||||
return
|
return
|
||||||
|
|||||||
@ -158,7 +158,7 @@ method provide*(
|
|||||||
|
|
||||||
method removeProvider*(
|
method removeProvider*(
|
||||||
d: Discovery, peerId: PeerId
|
d: Discovery, peerId: PeerId
|
||||||
): Future[void] {.base, gcsafe, async: (raises: [CancelledError]).} =
|
): Future[void] {.base, async: (raises: [CancelledError]).} =
|
||||||
## Remove provider from providers table
|
## Remove provider from providers table
|
||||||
##
|
##
|
||||||
|
|
||||||
|
|||||||
@ -7,10 +7,7 @@
|
|||||||
## This file may not be copied, modified, or distributed except according to
|
## This file may not be copied, modified, or distributed except according to
|
||||||
## those terms.
|
## those terms.
|
||||||
|
|
||||||
import pkg/upraises
|
{.push raises: [], gcsafe.}
|
||||||
|
|
||||||
push:
|
|
||||||
{.upraises: [].}
|
|
||||||
|
|
||||||
import ../stores
|
import ../stores
|
||||||
|
|
||||||
|
|||||||
@ -7,10 +7,7 @@
|
|||||||
## This file may not be copied, modified, or distributed except according to
|
## This file may not be copied, modified, or distributed except according to
|
||||||
## those terms.
|
## those terms.
|
||||||
|
|
||||||
import pkg/upraises
|
{.push raises: [], gcsafe.}
|
||||||
|
|
||||||
push:
|
|
||||||
{.upraises: [].}
|
|
||||||
|
|
||||||
import std/[sugar, atomics, sequtils]
|
import std/[sugar, atomics, sequtils]
|
||||||
|
|
||||||
|
|||||||
@ -9,11 +9,9 @@
|
|||||||
|
|
||||||
# This module implements serialization and deserialization of Manifest
|
# This module implements serialization and deserialization of Manifest
|
||||||
|
|
||||||
import pkg/upraises
|
|
||||||
import times
|
import times
|
||||||
|
|
||||||
push:
|
{.push raises: [].}
|
||||||
{.upraises: [].}
|
|
||||||
|
|
||||||
import std/tables
|
import std/tables
|
||||||
import std/sequtils
|
import std/sequtils
|
||||||
|
|||||||
@ -9,10 +9,7 @@
|
|||||||
|
|
||||||
# This module defines all operations on Manifest
|
# This module defines all operations on Manifest
|
||||||
|
|
||||||
import pkg/upraises
|
{.push raises: [], gcsafe.}
|
||||||
|
|
||||||
push:
|
|
||||||
{.upraises: [].}
|
|
||||||
|
|
||||||
import pkg/libp2p/protobuf/minprotobuf
|
import pkg/libp2p/protobuf/minprotobuf
|
||||||
import pkg/libp2p/[cid, multihash, multicodec]
|
import pkg/libp2p/[cid, multihash, multicodec]
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import pkg/chronos
|
import pkg/chronos
|
||||||
import pkg/upraises
|
|
||||||
import pkg/questionable
|
import pkg/questionable
|
||||||
import pkg/ethers/erc20
|
import pkg/ethers/erc20
|
||||||
import ./contracts/requests
|
import ./contracts/requests
|
||||||
@ -23,15 +22,15 @@ type
|
|||||||
ProofInvalidError* = object of MarketError
|
ProofInvalidError* = object of MarketError
|
||||||
Subscription* = ref object of RootObj
|
Subscription* = ref object of RootObj
|
||||||
OnRequest* =
|
OnRequest* =
|
||||||
proc(id: RequestId, ask: StorageAsk, expiry: uint64) {.gcsafe, upraises: [].}
|
proc(id: RequestId, ask: StorageAsk, expiry: uint64) {.gcsafe, raises: [].}
|
||||||
OnFulfillment* = proc(requestId: RequestId) {.gcsafe, upraises: [].}
|
OnFulfillment* = proc(requestId: RequestId) {.gcsafe, raises: [].}
|
||||||
OnSlotFilled* = proc(requestId: RequestId, slotIndex: uint64) {.gcsafe, upraises: [].}
|
OnSlotFilled* = proc(requestId: RequestId, slotIndex: uint64) {.gcsafe, raises: [].}
|
||||||
OnSlotFreed* = proc(requestId: RequestId, slotIndex: uint64) {.gcsafe, upraises: [].}
|
OnSlotFreed* = proc(requestId: RequestId, slotIndex: uint64) {.gcsafe, raises: [].}
|
||||||
OnSlotReservationsFull* =
|
OnSlotReservationsFull* =
|
||||||
proc(requestId: RequestId, slotIndex: uint64) {.gcsafe, upraises: [].}
|
proc(requestId: RequestId, slotIndex: uint64) {.gcsafe, raises: [].}
|
||||||
OnRequestCancelled* = proc(requestId: RequestId) {.gcsafe, upraises: [].}
|
OnRequestCancelled* = proc(requestId: RequestId) {.gcsafe, raises: [].}
|
||||||
OnRequestFailed* = proc(requestId: RequestId) {.gcsafe, upraises: [].}
|
OnRequestFailed* = proc(requestId: RequestId) {.gcsafe, raises: [].}
|
||||||
OnProofSubmitted* = proc(id: SlotId) {.gcsafe, upraises: [].}
|
OnProofSubmitted* = proc(id: SlotId) {.gcsafe, raises: [].}
|
||||||
ProofChallenge* = array[32, byte]
|
ProofChallenge* = array[32, byte]
|
||||||
|
|
||||||
# Marketplace events -- located here due to the Market abstraction
|
# Marketplace events -- located here due to the Market abstraction
|
||||||
@ -275,7 +274,7 @@ method subscribeProofSubmission*(
|
|||||||
): Future[Subscription] {.base, async.} =
|
): Future[Subscription] {.base, async.} =
|
||||||
raiseAssert("not implemented")
|
raiseAssert("not implemented")
|
||||||
|
|
||||||
method unsubscribe*(subscription: Subscription) {.base, async, upraises: [].} =
|
method unsubscribe*(subscription: Subscription) {.base, async.} =
|
||||||
raiseAssert("not implemented")
|
raiseAssert("not implemented")
|
||||||
|
|
||||||
method queryPastSlotFilledEvents*(
|
method queryPastSlotFilledEvents*(
|
||||||
|
|||||||
@ -7,10 +7,7 @@
|
|||||||
## This file may not be copied, modified, or distributed except according to
|
## This file may not be copied, modified, or distributed except according to
|
||||||
## those terms.
|
## those terms.
|
||||||
|
|
||||||
import pkg/upraises
|
{.push raises: [], gcsafe.}
|
||||||
|
|
||||||
push:
|
|
||||||
{.upraises: [].}
|
|
||||||
|
|
||||||
import pkg/libp2p
|
import pkg/libp2p
|
||||||
import pkg/questionable
|
import pkg/questionable
|
||||||
|
|||||||
@ -81,9 +81,8 @@ type
|
|||||||
CodexNodeRef* = ref CodexNode
|
CodexNodeRef* = ref CodexNode
|
||||||
|
|
||||||
OnManifest* = proc(cid: Cid, manifest: Manifest): void {.gcsafe, raises: [].}
|
OnManifest* = proc(cid: Cid, manifest: Manifest): void {.gcsafe, raises: [].}
|
||||||
BatchProc* = proc(blocks: seq[bt.Block]): Future[?!void] {.
|
BatchProc* =
|
||||||
gcsafe, async: (raises: [CancelledError])
|
proc(blocks: seq[bt.Block]): Future[?!void] {.async: (raises: [CancelledError]).}
|
||||||
.}
|
|
||||||
OnBlockStoredProc = proc(chunk: seq[byte]): void {.gcsafe, raises: [].}
|
OnBlockStoredProc = proc(chunk: seq[byte]): void {.gcsafe, raises: [].}
|
||||||
|
|
||||||
func switch*(self: CodexNodeRef): Switch =
|
func switch*(self: CodexNodeRef): Switch =
|
||||||
|
|||||||
@ -7,10 +7,7 @@
|
|||||||
## This file may not be copied, modified, or distributed except according to
|
## This file may not be copied, modified, or distributed except according to
|
||||||
## those terms.
|
## those terms.
|
||||||
|
|
||||||
import pkg/upraises
|
{.push raises: [], gcsafe.}
|
||||||
|
|
||||||
push:
|
|
||||||
{.upraises: [].}
|
|
||||||
|
|
||||||
import std/sequtils
|
import std/sequtils
|
||||||
import std/mimetypes
|
import std/mimetypes
|
||||||
|
|||||||
@ -7,10 +7,7 @@
|
|||||||
## This file may not be copied, modified, or distributed except according to
|
## This file may not be copied, modified, or distributed except according to
|
||||||
## those terms.
|
## those terms.
|
||||||
|
|
||||||
import pkg/upraises
|
{.push raises: [], gcsafe.}
|
||||||
|
|
||||||
push:
|
|
||||||
{.upraises: [].}
|
|
||||||
|
|
||||||
import pkg/libp2p/crypto/crypto
|
import pkg/libp2p/crypto/crypto
|
||||||
import pkg/bearssl/rand
|
import pkg/bearssl/rand
|
||||||
|
|||||||
@ -27,9 +27,7 @@
|
|||||||
## | UInt256 | totalRemainingCollateral | |
|
## | UInt256 | totalRemainingCollateral | |
|
||||||
## +---------------------------------------------------+
|
## +---------------------------------------------------+
|
||||||
|
|
||||||
import pkg/upraises
|
{.push raises: [], gcsafe.}
|
||||||
push:
|
|
||||||
{.upraises: [].}
|
|
||||||
|
|
||||||
import std/sequtils
|
import std/sequtils
|
||||||
import std/sugar
|
import std/sugar
|
||||||
@ -92,14 +90,10 @@ type
|
|||||||
repo: RepoStore
|
repo: RepoStore
|
||||||
OnAvailabilitySaved: ?OnAvailabilitySaved
|
OnAvailabilitySaved: ?OnAvailabilitySaved
|
||||||
|
|
||||||
GetNext* = proc(): Future[?seq[byte]] {.
|
GetNext* = proc(): Future[?seq[byte]] {.async: (raises: [CancelledError]), closure.}
|
||||||
upraises: [], gcsafe, async: (raises: [CancelledError]), closure
|
IterDispose* = proc(): Future[?!void] {.async: (raises: [CancelledError]), closure.}
|
||||||
.}
|
OnAvailabilitySaved* =
|
||||||
IterDispose* =
|
proc(availability: Availability): Future[void] {.async: (raises: []).}
|
||||||
proc(): Future[?!void] {.gcsafe, async: (raises: [CancelledError]), closure.}
|
|
||||||
OnAvailabilitySaved* = proc(availability: Availability): Future[void] {.
|
|
||||||
upraises: [], gcsafe, async: (raises: [])
|
|
||||||
.}
|
|
||||||
StorableIter* = ref object
|
StorableIter* = ref object
|
||||||
finished*: bool
|
finished*: bool
|
||||||
next*: GetNext
|
next*: GetNext
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import pkg/chronos
|
|||||||
import pkg/questionable
|
import pkg/questionable
|
||||||
import pkg/questionable/results
|
import pkg/questionable/results
|
||||||
import pkg/stint
|
import pkg/stint
|
||||||
import pkg/upraises
|
|
||||||
import ../contracts/requests
|
import ../contracts/requests
|
||||||
import ../errors
|
import ../errors
|
||||||
import ../logutils
|
import ../logutils
|
||||||
@ -113,14 +112,12 @@ proc subscribeCancellation(agent: SalesAgent) {.async.} =
|
|||||||
|
|
||||||
method onFulfilled*(
|
method onFulfilled*(
|
||||||
agent: SalesAgent, requestId: RequestId
|
agent: SalesAgent, requestId: RequestId
|
||||||
) {.base, gcsafe, upraises: [].} =
|
) {.base, gcsafe, raises: [].} =
|
||||||
let cancelled = agent.data.cancelled
|
let cancelled = agent.data.cancelled
|
||||||
if agent.data.requestId == requestId and not cancelled.isNil and not cancelled.finished:
|
if agent.data.requestId == requestId and not cancelled.isNil and not cancelled.finished:
|
||||||
cancelled.cancelSoon()
|
cancelled.cancelSoon()
|
||||||
|
|
||||||
method onFailed*(
|
method onFailed*(agent: SalesAgent, requestId: RequestId) {.base, gcsafe, raises: [].} =
|
||||||
agent: SalesAgent, requestId: RequestId
|
|
||||||
) {.base, gcsafe, upraises: [].} =
|
|
||||||
without request =? agent.data.request:
|
without request =? agent.data.request:
|
||||||
return
|
return
|
||||||
if agent.data.requestId == requestId:
|
if agent.data.requestId == requestId:
|
||||||
@ -128,7 +125,7 @@ method onFailed*(
|
|||||||
|
|
||||||
method onSlotFilled*(
|
method onSlotFilled*(
|
||||||
agent: SalesAgent, requestId: RequestId, slotIndex: uint64
|
agent: SalesAgent, requestId: RequestId, slotIndex: uint64
|
||||||
) {.base, gcsafe, upraises: [].} =
|
) {.base, gcsafe, raises: [].} =
|
||||||
if agent.data.requestId == requestId and agent.data.slotIndex == slotIndex:
|
if agent.data.requestId == requestId and agent.data.slotIndex == slotIndex:
|
||||||
agent.schedule(slotFilledEvent(requestId, slotIndex))
|
agent.schedule(slotFilledEvent(requestId, slotIndex))
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import pkg/questionable
|
import pkg/questionable
|
||||||
import pkg/questionable/results
|
import pkg/questionable/results
|
||||||
import pkg/upraises
|
|
||||||
import pkg/libp2p/cid
|
import pkg/libp2p/cid
|
||||||
|
|
||||||
import ../market
|
import ../market
|
||||||
@ -24,21 +23,20 @@ type
|
|||||||
slotQueue*: SlotQueue
|
slotQueue*: SlotQueue
|
||||||
simulateProofFailures*: int
|
simulateProofFailures*: int
|
||||||
|
|
||||||
BlocksCb* = proc(blocks: seq[bt.Block]): Future[?!void] {.
|
BlocksCb* =
|
||||||
gcsafe, async: (raises: [CancelledError])
|
proc(blocks: seq[bt.Block]): Future[?!void] {.async: (raises: [CancelledError]).}
|
||||||
.}
|
|
||||||
OnStore* = proc(
|
OnStore* = proc(
|
||||||
request: StorageRequest,
|
request: StorageRequest,
|
||||||
expiry: SecondsSince1970,
|
expiry: SecondsSince1970,
|
||||||
slot: uint64,
|
slot: uint64,
|
||||||
blocksCb: BlocksCb,
|
blocksCb: BlocksCb,
|
||||||
isRepairing: bool,
|
isRepairing: bool,
|
||||||
): Future[?!void] {.gcsafe, async: (raises: [CancelledError]).}
|
): Future[?!void] {.async: (raises: [CancelledError]).}
|
||||||
OnProve* = proc(slot: Slot, challenge: ProofChallenge): Future[?!Groth16Proof] {.
|
OnProve* = proc(slot: Slot, challenge: ProofChallenge): Future[?!Groth16Proof] {.
|
||||||
gcsafe, async: (raises: [CancelledError])
|
async: (raises: [CancelledError])
|
||||||
.}
|
.}
|
||||||
OnExpiryUpdate* = proc(rootCid: Cid, expiry: SecondsSince1970): Future[?!void] {.
|
OnExpiryUpdate* = proc(rootCid: Cid, expiry: SecondsSince1970): Future[?!void] {.
|
||||||
gcsafe, async: (raises: [CancelledError])
|
async: (raises: [CancelledError])
|
||||||
.}
|
.}
|
||||||
OnClear* = proc(request: StorageRequest, slotIndex: uint64) {.gcsafe, raises: [].}
|
OnClear* = proc(request: StorageRequest, slotIndex: uint64) {.gcsafe, raises: [].}
|
||||||
OnSale* = proc(request: StorageRequest, slotIndex: uint64) {.gcsafe, raises: [].}
|
OnSale* = proc(request: StorageRequest, slotIndex: uint64) {.gcsafe, raises: [].}
|
||||||
|
|||||||
@ -15,8 +15,7 @@ logScope:
|
|||||||
topics = "marketplace slotqueue"
|
topics = "marketplace slotqueue"
|
||||||
|
|
||||||
type
|
type
|
||||||
OnProcessSlot* =
|
OnProcessSlot* = proc(item: SlotQueueItem): Future[void] {.async: (raises: []).}
|
||||||
proc(item: SlotQueueItem): Future[void] {.gcsafe, async: (raises: []).}
|
|
||||||
|
|
||||||
# Non-ref obj copies value when assigned, preventing accidental modification
|
# Non-ref obj copies value when assigned, preventing accidental modification
|
||||||
# of values which could cause an incorrect order (eg
|
# of values which could cause an incorrect order (eg
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import pkg/questionable
|
import pkg/questionable
|
||||||
import pkg/upraises
|
|
||||||
import ../errors
|
import ../errors
|
||||||
import ../utils/asyncstatemachine
|
import ../utils/asyncstatemachine
|
||||||
import ../market
|
import ../market
|
||||||
@ -16,17 +15,17 @@ type
|
|||||||
|
|
||||||
method onCancelled*(
|
method onCancelled*(
|
||||||
state: SaleState, request: StorageRequest
|
state: SaleState, request: StorageRequest
|
||||||
): ?State {.base, upraises: [].} =
|
): ?State {.base, raises: [].} =
|
||||||
discard
|
discard
|
||||||
|
|
||||||
method onFailed*(
|
method onFailed*(
|
||||||
state: SaleState, request: StorageRequest
|
state: SaleState, request: StorageRequest
|
||||||
): ?State {.base, upraises: [].} =
|
): ?State {.base, raises: [].} =
|
||||||
discard
|
discard
|
||||||
|
|
||||||
method onSlotFilled*(
|
method onSlotFilled*(
|
||||||
state: SaleState, requestId: RequestId, slotIndex: uint64
|
state: SaleState, requestId: RequestId, slotIndex: uint64
|
||||||
): ?State {.base, upraises: [].} =
|
): ?State {.base, raises: [].} =
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc cancelledEvent*(request: StorageRequest): Event =
|
proc cancelledEvent*(request: StorageRequest): Event =
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import pkg/questionable
|
import pkg/questionable
|
||||||
import pkg/questionable/results
|
import pkg/questionable/results
|
||||||
import pkg/upraises
|
|
||||||
|
|
||||||
import ../statemachine
|
import ../statemachine
|
||||||
import ../salesagent
|
import ../salesagent
|
||||||
|
|||||||
@ -29,7 +29,7 @@ type
|
|||||||
Block
|
Block
|
||||||
Both
|
Both
|
||||||
|
|
||||||
CidCallback* = proc(cid: Cid): Future[void] {.gcsafe, async: (raises: []).}
|
CidCallback* = proc(cid: Cid): Future[void] {.async: (raises: []).}
|
||||||
BlockStore* = ref object of RootObj
|
BlockStore* = ref object of RootObj
|
||||||
onBlockStored*: ?CidCallback
|
onBlockStored*: ?CidCallback
|
||||||
|
|
||||||
|
|||||||
@ -7,9 +7,7 @@
|
|||||||
## This file may not be copied, modified, or distributed except according to
|
## This file may not be copied, modified, or distributed except according to
|
||||||
## those terms.
|
## those terms.
|
||||||
|
|
||||||
import pkg/upraises
|
{.push raises: [], gcsafe.}
|
||||||
push:
|
|
||||||
{.upraises: [].}
|
|
||||||
|
|
||||||
import std/sugar
|
import std/sugar
|
||||||
import pkg/questionable/results
|
import pkg/questionable/results
|
||||||
|
|||||||
@ -7,10 +7,7 @@
|
|||||||
## This file may not be copied, modified, or distributed except according to
|
## This file may not be copied, modified, or distributed except according to
|
||||||
## those terms.
|
## those terms.
|
||||||
|
|
||||||
import pkg/upraises
|
{.push raises: [], gcsafe.}
|
||||||
|
|
||||||
push:
|
|
||||||
{.upraises: [].}
|
|
||||||
|
|
||||||
import std/sugar
|
import std/sugar
|
||||||
import pkg/chronos
|
import pkg/chronos
|
||||||
|
|||||||
@ -7,9 +7,7 @@
|
|||||||
## This file may not be copied, modified, or distributed except according to
|
## This file may not be copied, modified, or distributed except according to
|
||||||
## those terms.
|
## those terms.
|
||||||
|
|
||||||
import pkg/upraises
|
{.push raises: [], gcsafe.}
|
||||||
push:
|
|
||||||
{.upraises: [].}
|
|
||||||
|
|
||||||
import pkg/chronos
|
import pkg/chronos
|
||||||
import pkg/libp2p
|
import pkg/libp2p
|
||||||
|
|||||||
@ -9,10 +9,7 @@
|
|||||||
|
|
||||||
import std/options
|
import std/options
|
||||||
|
|
||||||
import pkg/upraises
|
{.push raises: [], gcsafe.}
|
||||||
|
|
||||||
push:
|
|
||||||
{.upraises: [].}
|
|
||||||
|
|
||||||
import pkg/chronos
|
import pkg/chronos
|
||||||
import pkg/stew/ptrops
|
import pkg/stew/ptrops
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
import std/times
|
import std/times
|
||||||
import pkg/upraises
|
|
||||||
import ./clock
|
import ./clock
|
||||||
|
|
||||||
type SystemClock* = ref object of Clock
|
type SystemClock* = ref object of Clock
|
||||||
|
|
||||||
method now*(clock: SystemClock): SecondsSince1970 {.upraises: [].} =
|
method now*(clock: SystemClock): SecondsSince1970 {.raises: [].} =
|
||||||
let now = times.now().utc
|
let now = times.now().utc
|
||||||
now.toTime().toUnix()
|
now.toTime().toUnix()
|
||||||
|
|||||||
@ -7,9 +7,7 @@
|
|||||||
## This file may not be copied, modified, or distributed except according to
|
## This file may not be copied, modified, or distributed except according to
|
||||||
## those terms.
|
## those terms.
|
||||||
|
|
||||||
import pkg/upraises
|
{.push raises: [], gcsafe.}
|
||||||
push:
|
|
||||||
{.upraises: [].}
|
|
||||||
|
|
||||||
import std/strutils
|
import std/strutils
|
||||||
import std/options
|
import std/options
|
||||||
|
|||||||
@ -9,10 +9,7 @@
|
|||||||
|
|
||||||
## Partially taken from nim beacon chain
|
## Partially taken from nim beacon chain
|
||||||
|
|
||||||
import pkg/upraises
|
{.push raises: [], gcsafe.}
|
||||||
|
|
||||||
push:
|
|
||||||
{.upraises: [].}
|
|
||||||
|
|
||||||
import std/strutils
|
import std/strutils
|
||||||
import pkg/stew/io2
|
import pkg/stew/io2
|
||||||
|
|||||||
@ -7,9 +7,7 @@
|
|||||||
## This file may not be copied, modified, or distributed except according to
|
## This file may not be copied, modified, or distributed except according to
|
||||||
## those terms.
|
## those terms.
|
||||||
|
|
||||||
import pkg/upraises
|
{.push raises: [], gcsafe.}
|
||||||
push:
|
|
||||||
{.upraises: [].}
|
|
||||||
|
|
||||||
import pkg/questionable/results
|
import pkg/questionable/results
|
||||||
import pkg/libp2p/crypto/crypto
|
import pkg/libp2p/crypto/crypto
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import pkg/chronos
|
|||||||
import ../logutils
|
import ../logutils
|
||||||
|
|
||||||
type
|
type
|
||||||
TimerCallback* = proc(): Future[void] {.gcsafe, async: (raises: []).}
|
TimerCallback* = proc(): Future[void] {.async: (raises: []).}
|
||||||
Timer* = ref object of RootObj
|
Timer* = ref object of RootObj
|
||||||
callback: TimerCallback
|
callback: TimerCallback
|
||||||
interval: Duration
|
interval: Duration
|
||||||
|
|||||||
@ -21,7 +21,7 @@ proc new*(
|
|||||||
var consumed = 0
|
var consumed = 0
|
||||||
proc reader(
|
proc reader(
|
||||||
data: ChunkBuffer, len: int
|
data: ChunkBuffer, len: int
|
||||||
): Future[int] {.gcsafe, async: (raises: [ChunkerError, CancelledError]).} =
|
): Future[int] {.async: (raises: [ChunkerError, CancelledError]).} =
|
||||||
if consumed >= dataset.len:
|
if consumed >= dataset.len:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|||||||
@ -75,7 +75,7 @@ asyncchecksuite "Test Node - Basic":
|
|||||||
batchSize = batchSize,
|
batchSize = batchSize,
|
||||||
proc(
|
proc(
|
||||||
blocks: seq[bt.Block]
|
blocks: seq[bt.Block]
|
||||||
): Future[?!void] {.gcsafe, async: (raises: [CancelledError]).} =
|
): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
check blocks.len > 0 and blocks.len <= batchSize
|
check blocks.len > 0 and blocks.len <= batchSize
|
||||||
return success(),
|
return success(),
|
||||||
)
|
)
|
||||||
@ -100,7 +100,7 @@ asyncchecksuite "Test Node - Basic":
|
|||||||
batchSize = batchSize,
|
batchSize = batchSize,
|
||||||
proc(
|
proc(
|
||||||
blocks: seq[bt.Block]
|
blocks: seq[bt.Block]
|
||||||
): Future[?!void] {.gcsafe, async: (raises: [CancelledError]).} =
|
): Future[?!void] {.async: (raises: [CancelledError]).} =
|
||||||
return failure("Should not be called"),
|
return failure("Should not be called"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@ -342,9 +342,7 @@ asyncchecksuite "Reservations module":
|
|||||||
|
|
||||||
test "OnAvailabilitySaved called when availability is created":
|
test "OnAvailabilitySaved called when availability is created":
|
||||||
var added: Availability
|
var added: Availability
|
||||||
reservations.OnAvailabilitySaved = proc(
|
reservations.OnAvailabilitySaved = proc(a: Availability) {.async: (raises: []).} =
|
||||||
a: Availability
|
|
||||||
) {.gcsafe, async: (raises: []).} =
|
|
||||||
added = a
|
added = a
|
||||||
|
|
||||||
let availability = createAvailability()
|
let availability = createAvailability()
|
||||||
@ -354,9 +352,7 @@ asyncchecksuite "Reservations module":
|
|||||||
test "OnAvailabilitySaved called when availability size is increased":
|
test "OnAvailabilitySaved called when availability size is increased":
|
||||||
var availability = createAvailability()
|
var availability = createAvailability()
|
||||||
var added: Availability
|
var added: Availability
|
||||||
reservations.OnAvailabilitySaved = proc(
|
reservations.OnAvailabilitySaved = proc(a: Availability) {.async: (raises: []).} =
|
||||||
a: Availability
|
|
||||||
) {.gcsafe, async: (raises: []).} =
|
|
||||||
added = a
|
added = a
|
||||||
availability.freeSize += 1
|
availability.freeSize += 1
|
||||||
discard await reservations.update(availability)
|
discard await reservations.update(availability)
|
||||||
@ -366,9 +362,7 @@ asyncchecksuite "Reservations module":
|
|||||||
test "OnAvailabilitySaved is not called when availability size is decreased":
|
test "OnAvailabilitySaved is not called when availability size is decreased":
|
||||||
var availability = createAvailability()
|
var availability = createAvailability()
|
||||||
var called = false
|
var called = false
|
||||||
reservations.OnAvailabilitySaved = proc(
|
reservations.OnAvailabilitySaved = proc(a: Availability) {.async: (raises: []).} =
|
||||||
a: Availability
|
|
||||||
) {.gcsafe, async: (raises: []).} =
|
|
||||||
called = true
|
called = true
|
||||||
availability.freeSize -= 1.uint64
|
availability.freeSize -= 1.uint64
|
||||||
discard await reservations.update(availability)
|
discard await reservations.update(availability)
|
||||||
@ -378,9 +372,7 @@ asyncchecksuite "Reservations module":
|
|||||||
test "OnAvailabilitySaved is not called when availability is disabled":
|
test "OnAvailabilitySaved is not called when availability is disabled":
|
||||||
var availability = createAvailability(enabled = false)
|
var availability = createAvailability(enabled = false)
|
||||||
var called = false
|
var called = false
|
||||||
reservations.OnAvailabilitySaved = proc(
|
reservations.OnAvailabilitySaved = proc(a: Availability) {.async: (raises: []).} =
|
||||||
a: Availability
|
|
||||||
) {.gcsafe, async: (raises: []).} =
|
|
||||||
called = true
|
called = true
|
||||||
availability.freeSize -= 1
|
availability.freeSize -= 1
|
||||||
discard await reservations.update(availability)
|
discard await reservations.update(availability)
|
||||||
|
|||||||
@ -18,7 +18,7 @@ type CrashingStreamWrapper* = ref object of LPStream
|
|||||||
|
|
||||||
method readOnce*(
|
method readOnce*(
|
||||||
self: CrashingStreamWrapper, pbytes: pointer, nbytes: int
|
self: CrashingStreamWrapper, pbytes: pointer, nbytes: int
|
||||||
): Future[int] {.gcsafe, async: (raises: [CancelledError, LPStreamError]).} =
|
): Future[int] {.async: (raises: [CancelledError, LPStreamError]).} =
|
||||||
self.toRaise()
|
self.toRaise()
|
||||||
|
|
||||||
asyncchecksuite "Chunking":
|
asyncchecksuite "Chunking":
|
||||||
@ -27,7 +27,7 @@ asyncchecksuite "Chunking":
|
|||||||
let contents = [1.byte, 2, 3, 4, 5, 6, 7, 8, 9, 0]
|
let contents = [1.byte, 2, 3, 4, 5, 6, 7, 8, 9, 0]
|
||||||
proc reader(
|
proc reader(
|
||||||
data: ChunkBuffer, len: int
|
data: ChunkBuffer, len: int
|
||||||
): Future[int] {.gcsafe, async: (raises: [ChunkerError, CancelledError]).} =
|
): Future[int] {.async: (raises: [ChunkerError, CancelledError]).} =
|
||||||
let read = min(contents.len - offset, len)
|
let read = min(contents.len - offset, len)
|
||||||
if read == 0:
|
if read == 0:
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import pkg/questionable
|
import pkg/questionable
|
||||||
import pkg/chronos
|
import pkg/chronos
|
||||||
import pkg/upraises
|
|
||||||
import codex/utils/asyncstatemachine
|
import codex/utils/asyncstatemachine
|
||||||
|
|
||||||
import ../../asynctest
|
import ../../asynctest
|
||||||
@ -36,7 +35,7 @@ method run(state: State2, machine: Machine): Future[?State] {.async: (raises: []
|
|||||||
method run(state: State3, machine: Machine): Future[?State] {.async: (raises: []).} =
|
method run(state: State3, machine: Machine): Future[?State] {.async: (raises: []).} =
|
||||||
inc runs[2]
|
inc runs[2]
|
||||||
|
|
||||||
method onMoveToNextStateEvent*(state: State): ?State {.base, upraises: [].} =
|
method onMoveToNextStateEvent*(state: State): ?State {.base, raises: [].} =
|
||||||
discard
|
discard
|
||||||
|
|
||||||
method onMoveToNextStateEvent(state: State2): ?State =
|
method onMoveToNextStateEvent(state: State2): ?State =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user