service Op("op"):
    -- does nothing
    noop()

-- service interface for Wasm module
service AddOne:
    add_one: u64 -> u64

-- convenience struc for (Peer Id, Service Id) tuples
data NodeServiceTuple:
    node_id: string
    service_id: string

func add_one(value: u64, node: string, service_id: string) -> u64:
    on node:
        AddOne service_id
        res <- AddOne.add_one(value)
    <- res

func add_one_three_times(value: u64, ns_tuples: []NodeServiceTuple) -> u64:
    on ns_tuples!0.node_id:
        AddOne ns_tuples!0.service_id
        res1 <- AddOne.add_one(value)

    on ns_tuples!1.node_id:
        AddOne ns_tuples!1.service_id
        res2 <- AddOne.add_one(res1)

    on ns_tuples!2.node_id:
        AddOne ns_tuples!2.service_id
        res3 <- AddOne.add_one(res2)
    <- res3

func add_one_par(value: u64, ns_tuples: []NodeServiceTuple) -> []u64:
    res: *u64
    for ns <- ns_tuples par:
        on ns.node_id:
            AddOne ns.service_id
            res <- AddOne.add_one(value)
        Op.noop()
    join res[2]
    <- res

data ValueNodeService:
    node_id: string
    service_id: string
    value: u64

func add_one_par_alt(payload: []ValueNodeService) -> []u64:
    res: *u64
    for vns <- payload par:
        on vns.node_id:
            AddOne vns.service_id
            res <- AddOne.add_one(vns.value)
        Op.noop()
    join res[2]
    <- res
