2021-04-30 10:36:55 +00:00
|
|
|
|
-- Default public interface of Fluence nodes
|
|
|
|
|
|
2021-04-29 12:22:39 +00:00
|
|
|
|
alias Field : []string
|
|
|
|
|
alias Argument : []string
|
|
|
|
|
alias Bytes : []u8
|
|
|
|
|
alias PeerId : string
|
|
|
|
|
|
|
|
|
|
data Service:
|
|
|
|
|
id: string
|
|
|
|
|
blueprint_id: string
|
|
|
|
|
owner_id: string
|
|
|
|
|
|
|
|
|
|
data FunctionSignature:
|
|
|
|
|
arguments: []Argument
|
|
|
|
|
name: string
|
|
|
|
|
output_types: []string
|
|
|
|
|
|
|
|
|
|
data RecordType:
|
|
|
|
|
fields: []Field
|
|
|
|
|
id: u64
|
|
|
|
|
name: string
|
|
|
|
|
|
|
|
|
|
data Interface:
|
|
|
|
|
function_signatures: []FunctionSignature
|
|
|
|
|
record_types: []RecordType
|
|
|
|
|
|
|
|
|
|
data ServiceInfo:
|
|
|
|
|
blueprint_id: string
|
|
|
|
|
service_id: string
|
|
|
|
|
interface: Interface
|
|
|
|
|
|
|
|
|
|
data Info:
|
|
|
|
|
external_addresses: []string
|
|
|
|
|
|
|
|
|
|
data ModuleConfig:
|
|
|
|
|
name: string
|
|
|
|
|
|
|
|
|
|
data Module:
|
|
|
|
|
name: string
|
|
|
|
|
hash: string
|
|
|
|
|
config: ModuleConfig
|
|
|
|
|
|
|
|
|
|
data AddBlueprint:
|
|
|
|
|
name: string
|
|
|
|
|
dependencies: []string
|
|
|
|
|
|
|
|
|
|
data Blueprint:
|
|
|
|
|
id: string
|
|
|
|
|
name: string
|
|
|
|
|
dependencies: []string
|
|
|
|
|
|
|
|
|
|
data ScriptInfo:
|
|
|
|
|
id: string
|
|
|
|
|
src: string
|
|
|
|
|
failures: u32
|
|
|
|
|
interval: string
|
|
|
|
|
owner: string
|
|
|
|
|
|
|
|
|
|
data Contact:
|
|
|
|
|
peer_id: string
|
|
|
|
|
addresses: []string
|
|
|
|
|
|
|
|
|
|
service Op("op"):
|
2021-06-03 14:57:39 +00:00
|
|
|
|
-- does nothing
|
|
|
|
|
noop()
|
|
|
|
|
-- takes any number of arguments and wraps them into a single array
|
|
|
|
|
array(a: string, b: string, c: string) -> []string
|
|
|
|
|
-- takes any number of arrays and flattens them by concatenating
|
|
|
|
|
concat(a: []string, b: []string, c: []string) -> []string
|
|
|
|
|
-- takes a single argument and returns it back
|
|
|
|
|
identity(s: ?string) -> ?string
|
2021-05-27 13:12:11 +00:00
|
|
|
|
string_to_b58(s: string) -> string
|
|
|
|
|
string_from_b58(b: string) -> string
|
|
|
|
|
bytes_to_b58(bs: []u8) -> string
|
|
|
|
|
bytes_from_b58(b: string) -> []u8
|
2021-06-03 13:36:34 +00:00
|
|
|
|
-- Applies SHA256 to the given string
|
|
|
|
|
-- Argument: s - string to apply sha256 to
|
|
|
|
|
-- Returns: returns sha256 multihash encoded as base58
|
|
|
|
|
sha256_string(s: string) -> string
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
service Peer("peer"):
|
|
|
|
|
-- Checks if there is a direct connection to the peer identified by a given PeerId
|
|
|
|
|
-- Argument: PeerId – id of the peer to check if there's a connection with
|
|
|
|
|
-- Returns: bool - true if connected to the peer, false otherwise
|
2021-04-30 10:36:55 +00:00
|
|
|
|
is_connected(peer: PeerId) -> bool
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Initiates a connection to the specified peer
|
|
|
|
|
-- Arguments:
|
|
|
|
|
-- PeerId – id of the target peer
|
|
|
|
|
-- [Multiaddr] – an array of target peer's addresses
|
|
|
|
|
-- Returns: bool - true if connection was successful
|
2021-04-30 10:36:55 +00:00
|
|
|
|
connect(id: PeerId, multiaddrs: []string) -> bool
|
2021-04-29 12:22:39 +00:00
|
|
|
|
-- Resolves the contact of a peer via Kademlia
|
|
|
|
|
-- Argument: PeerId – id of the target peer
|
|
|
|
|
-- Returns: Contact - true if connection was successful
|
2021-04-30 10:36:55 +00:00
|
|
|
|
get_contact(peer: PeerId) -> Contact
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Get information about the peer
|
2021-04-30 10:36:55 +00:00
|
|
|
|
identify() -> Info
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Get Unix timestamp in milliseconds
|
2021-04-30 10:36:55 +00:00
|
|
|
|
timestamp_ms() -> u64
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Get Unix timestamp in seconds
|
2021-04-30 10:36:55 +00:00
|
|
|
|
timestamp_sec() -> u64
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
service Kademlia("kad"):
|
|
|
|
|
-- Instructs node to return the locally-known nodes
|
|
|
|
|
-- in the Kademlia neighborhood for a given key
|
2021-05-27 13:12:11 +00:00
|
|
|
|
neighborhood(key: PeerId, already_hashed: bool) -> []PeerId
|
2021-06-03 13:36:34 +00:00
|
|
|
|
-- Merges given lists and sorts them by distance to target
|
|
|
|
|
-- Arguments:
|
|
|
|
|
-- target – base58 string; result is sorted by XOR distance to target
|
|
|
|
|
-- left – list of base58 strings
|
|
|
|
|
-- right – list of base58 strings
|
|
|
|
|
-- count – how many items to return
|
|
|
|
|
-- Returns: list of base58 strings sorted by distance to target; list will contain at most count elements
|
|
|
|
|
merge(target: string, left: []string, right: []string, count: u32) -> []string
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
service Srv("srv"):
|
|
|
|
|
-- Used to create a service on a certain node
|
|
|
|
|
-- Arguments:
|
|
|
|
|
-- blueprint_id – ID of the blueprint that has been added to the node specified in the service call by the dist add_blueprint service.
|
|
|
|
|
-- Returns: service_id – the service ID of the created service.
|
2021-04-30 10:36:55 +00:00
|
|
|
|
create(blueprint_id: string) -> string
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
2021-04-29 15:01:10 +00:00
|
|
|
|
-- Used to remove a service from a certain node
|
|
|
|
|
-- Arguments:
|
|
|
|
|
-- service_id – ID of the service to remove
|
2021-04-30 10:36:55 +00:00
|
|
|
|
remove(service_id: string)
|
2021-04-29 15:01:10 +00:00
|
|
|
|
|
2021-04-29 12:22:39 +00:00
|
|
|
|
-- Returns a list of services running on a peer
|
2021-04-30 10:36:55 +00:00
|
|
|
|
list() -> []Service
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Adds an alias on service, so, service could be called
|
|
|
|
|
-- not only by service_id but by alias as well.
|
|
|
|
|
-- Argument:
|
|
|
|
|
-- alias - settable service name
|
|
|
|
|
-- service_id – ID of the service whose interface you want to name.
|
2021-04-30 10:36:55 +00:00
|
|
|
|
add_alias(alias: string, service_id: string)
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
2021-06-03 13:36:34 +00:00
|
|
|
|
-- Resolves given alias to a service id
|
|
|
|
|
-- If there's no such alias, throws an error
|
|
|
|
|
-- Returns: service id associated with the given alias
|
|
|
|
|
resolve_alias(alias: string) -> string
|
|
|
|
|
|
2021-04-29 12:22:39 +00:00
|
|
|
|
-- Retrieves the functional interface of a service running
|
|
|
|
|
-- on the node specified in the service call
|
|
|
|
|
-- Argument: service_id – ID of the service whose interface you want to retrieve.
|
2021-04-30 10:36:55 +00:00
|
|
|
|
get_interface(service_id: string) -> ServiceInfo
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
service Dist("dist"):
|
|
|
|
|
-- Used to add modules to the node specified in the service call
|
|
|
|
|
-- Arguments:
|
|
|
|
|
-- bytes – a base64 string containing the .wasm module to add.
|
|
|
|
|
-- config – module info
|
|
|
|
|
-- Returns: blake3 hash of the module
|
2021-04-30 10:36:55 +00:00
|
|
|
|
add_module(wasm_b56_content: Bytes, conf: ModuleConfig) -> string
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Get a list of modules available on the node
|
2021-04-30 10:36:55 +00:00
|
|
|
|
list_modules() -> []Module
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Get the interface of a module
|
2021-04-30 10:36:55 +00:00
|
|
|
|
get_interface(module_id: string) -> Interface
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Used to add a blueprint to the node specified in the service call
|
2021-04-30 10:36:55 +00:00
|
|
|
|
add_blueprint(blueprint: AddBlueprint) -> string
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Used to get the blueprints available on the node specified in the service call.
|
|
|
|
|
-- A blueprint is an object of the following structure
|
2021-04-30 10:36:55 +00:00
|
|
|
|
list_blueprints() -> []Blueprint
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
service Script("script"):
|
|
|
|
|
-- Adds the given script to a node
|
2021-04-30 10:36:55 +00:00
|
|
|
|
add(air_content: string, run_every: string) -> string
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Removes recurring script from a node. Only a creator of the script can delete it
|
2021-04-30 10:36:55 +00:00
|
|
|
|
remove(script_id: string) -> bool
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Returns a list of existing scripts on the node.
|
|
|
|
|
-- Each object in the list is of the following structure
|
2021-04-30 10:36:55 +00:00
|
|
|
|
list() -> ScriptInfo
|