GitBook: [alpha] 23 pages modified

This commit is contained in:
boneyard93501 2021-07-01 16:03:47 +00:00 committed by gitbook-bot
parent f236d822d8
commit f760b54680
No known key found for this signature in database
GPG Key ID: 07D2180C7B12D0FF
2 changed files with 15 additions and 36 deletions

View File

@ -8,7 +8,7 @@ At the core of Fluence is the open-source language **Aqua** that allows for the
This book is dedicated to all things Aqua and currently in its **alpha** version and we expect to expand both Aqua's breadth and depth coverage over the coming weeks.
You can stay in touch or contact us via the following channels:
Stay in touch or contact us via the following channels:
* [Discord](https://discord.gg/)
* [Telegram](https://t.me/fluence_project)

View File

@ -4,7 +4,7 @@ Every Fluence reference node comes with a set of builtin services that are acces
{% tabs %}
{% tab title="Timestamps With Aqua" %}
```haskell
```text
-- timestamp_getter.aqua
-- bring the builtin services into scope
import "builtin.aqua"
@ -38,35 +38,9 @@ func ts_getter(node: string) -> []u64:
<- res
```
{% endtab %}
{% tab title="Compiling Aqua Script" %}
```bash
aqua-cli -i aqua-scripts -o air-scripts -a
```
{% endtab %}
{% tab title="Result" %}
```bash
fldist run_air -p air-scripts/timestamp_getter.ts_getter.air -d '{"node":"12D3KooWHLxVhUQyAuZe6AHMB29P7wkvTNMn7eDMcsqimJYLKREf"}' --generated
[
[
1624928596292,
1624928596291,
1624928596291,
1624928596299,
1624928596295,
1624928596286,
1624928596295,
1624928596284,
1624928596293,
1624928596289
]
]
```
{% endtab %}
{% endtabs %}
The Aqua script essentially creates a workflow originating from our client peer to enumerate our neighbour peers from the Kademlia neighbourhood based on our reference node specification, calls on the builtin timestamp service on each peer in parallel, joins the results stream after we collect ten timestamps and return our u64 array of timestamps back to the client peer.
The Aqua script essentially creates a workflow originating from our client peer to enumerate neighbor peers for our reference node, calls on the builtin timestamp service on each peer in parallel, joins the results stream after we collect ten timestamps and return our u64 array of timestamps back to the client peer.
See the [ts-oracle example](https://github.com/fluencelabs/examples/tree/main/ts-oracle) for the corresponding Aqua files in the `aqua-script` directory. Now that we have our script, let's compile it with the `aqua-cli` tool and find our AIR file in the `air-scripts` directory:
@ -85,20 +59,18 @@ timestamp_getter.ts_getter.air
{% endtab %}
{% endtabs %}
Once we have our AIR file we can either use a Typescript or command-line client. Let's use the command line client `flidst`:
Once we have our AIR file we can either use a Typescript or command line client. Let's use the command line client `flidst`see third tab for installation instructions, if needed:
{% tabs %}
{% tab title="Run Air scripts" %}
```bash
# if you don't have fldist on your machine:
# npm -g install @fluencelabs/fldist
```text
# execute the AIR script from our compile phase with a peer id
fldist run_air -p air-scripts/timestamp_getter.ts_getter.air -d '{"node":"12D3KooWHLxVhUQyAuZe6AHMB29P7wkvTNMn7eDMcsqimJYLKREf"}' --generated
```
{% endtab %}
{% tab title="Output" %}
```bash
{% tab title="Result" %}
```
# here we go: ten timestamps in micro seconds obtained in parallel
[
[
@ -116,7 +88,14 @@ fldist run_air -p air-scripts/timestamp_getter.ts_getter.air -d '{"node":"12D3K
]
```
{% endtab %}
{% tab title="Installing fldist" %}
```
# if you don't have fldist on your machine:
npm -g install @fluencelabs/fldist
```
{% endtab %}
{% endtabs %}
And that's it. We now have ten timestamps right from our Kademlia neighbours.
And that's it. We now have ten timestamps right from our selected peer's neighbors.