Add kad merge, resolve_aliad, sha256_string (#3)

This commit is contained in:
folex 2021-06-03 16:36:34 +03:00 committed by GitHub
parent e5be5d2e98
commit 580cb7f596
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,6 +66,10 @@ service Op("op"):
string_from_b58(b: string) -> string
bytes_to_b58(bs: []u8) -> string
bytes_from_b58(b: string) -> []u8
-- 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
service Peer("peer"):
-- Checks if there is a direct connection to the peer identified by a given PeerId
@ -97,6 +101,14 @@ service Kademlia("kad"):
-- Instructs node to return the locally-known nodes
-- in the Kademlia neighborhood for a given key
neighborhood(key: PeerId, already_hashed: bool) -> []PeerId
-- 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
service Srv("srv"):
-- Used to create a service on a certain node
@ -120,6 +132,11 @@ service Srv("srv"):
-- service_id ID of the service whose interface you want to name.
add_alias(alias: string, service_id: string)
-- 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
-- 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.