diff --git a/dagger/node.nim b/dagger/node.nim index 202b607e..8a40baaf 100644 --- a/dagger/node.nim +++ b/dagger/node.nim @@ -212,7 +212,8 @@ proc requestStorage*(self: DaggerNodeRef, duration: UInt256, nodes: uint, tolerance: uint, - maxPrice: UInt256): Future[?!array[32, byte]] {.async.} = + maxPrice: UInt256, + expiry = UInt256.none): Future[?!array[32, byte]] {.async.} = ## Initiate a request for storage sequence, this might ## be a multistep procedure. ## @@ -280,7 +281,8 @@ proc requestStorage*(self: DaggerNodeRef, publicKey: @[], # TODO: PoR setup name: @[] # TODO: PoR setup ) - ) + ), + expiry: expiry |? 0.u256 ) let purchase = contracts.purchasing.purchase(request) diff --git a/dagger/rest/api.nim b/dagger/rest/api.nim index 7cce3729..d0aef0ae 100644 --- a/dagger/rest/api.nim +++ b/dagger/rest/api.nim @@ -208,7 +208,8 @@ proc initRestApi*(node: DaggerNodeRef, conf: DaggerConf): RestRouter = params.duration, nodes, tolerance, - params.maxPrice), error: + params.maxPrice, + params.expiry), error: return RestApiResponse.error(Http500, error.msg) return RestApiResponse.response(purchaseId.toHex) diff --git a/dagger/rest/json.nim b/dagger/rest/json.nim index 2c1d1249..49c6cbb9 100644 --- a/dagger/rest/json.nim +++ b/dagger/rest/json.nim @@ -9,6 +9,7 @@ type StorageRequestParams* = object duration*: UInt256 maxPrice*: UInt256 + expiry*: ?UInt256 proc fromJson*(_: type Availability, bytes: seq[byte]): ?!Availability = let json = ?catch parseJson(string.fromBytes(bytes)) @@ -22,7 +23,12 @@ proc fromJson*(_: type StorageRequestParams, let json = ?catch parseJson(string.fromBytes(bytes)) let duration = ?catch UInt256.fromHex(json["duration"].getStr) let maxPrice = ?catch UInt256.fromHex(json["maxPrice"].getStr) - success StorageRequestParams(duration: duration, maxPrice: maxPrice) + let expiry = UInt256.fromHex(json["expiry"].getStr).catch.option + success StorageRequestParams( + duration: duration, + maxPrice: maxPrice, + expiry: expiry + ) func `%`*(address: Address): JsonNode = % $address