fn(remote$0, content_limit$1, event$2, then$3) =>
let request$4 = #object<@definy.json>([{key: "signedEventBytes", value: #string<@definy.json>($2.signed_event_bytes)}]);
@definy.sync-local(
io: @definy.mirror-submit(request: $4),
then: fn(result$5) =>
match $5 {
#error(message$6) =>
$3(result: #failed($6)),
#ok(json$7) =>
match @definy.json-get-string(value: $7, key: "status") {
#some("missing_content") =>
@definy.sync-remote-rpc(
remote: $0,
method: "GetContent",
request: #object<@definy.json>([
{
key: "contentHashes",
value: #array<@definy.json>(@definy.json-string-array(
items: @definy.strings-take(
items: match @definy.json-get-strings(value: $7, key: "missingContentHashes") {
#some(hashes$8) =>
$8,
#none(_) =>
[]
},
count: $1,
index: 0,
acc: []
),
index: 0
))
}
]),
then: fn(result$9) =>
match $9 {
#error(message$10) =>
$3(result: #failed($10)),
#ok(json$11) =>
@definy.sync-local(
io: @definy.upload-content(
request: #object<@definy.json>([{key: "items", value: #array<@definy.json>(@definy.json-get-array(value: $11, key: "items"))}])
),
then: fn(result$12) =>
match $12 {
#error(message$13) =>
$3(result: #failed($13)),
#ok(_) =>
@definy.sync-local(
io: @definy.mirror-submit(request: $4),
then: fn(result$14) =>
match $14 {
#error(message$15) =>
$3(result: #failed($15)),
#ok(json$16) =>
match @definy.json-get-string(value: $16, key: "status") {
#some("missing_content") =>
$3(result: #partial("some contents of the event are still missing (stored the first ones)")),
_ =>
$3(result: #stored)
}
}
)
}
)
}
),
_ =>
$3(result: #stored)
}
}
)