mirror of
https://github.com/fluencelabs/gitbook-docs
synced 2024-12-04 15:20:24 +00:00
GitBook: [#267] No subject
This commit is contained in:
parent
4d6b0a5d89
commit
52b46faeed
@ -26,14 +26,14 @@ git clone https://github.com/fluencelabs/examples
|
||||
|
||||
#### Timestamp Acquisition
|
||||
|
||||
Each Fluence peer, i.e. node in the Fluence peer-to-peer network, has the ability to provide a timestamp from a [builtin service](https://github.com/fluencelabs/aqua-lib/blob/b90f2dddc335c155995a74d8d97de8dbe6a029d2/builtin.aqua#L127). In Aqua, we can call a [timestamp function](https://github.com/fluencelabs/fluence/blob/527e26e08f3905e53208b575792712eeaee5deca/particle-closures/src/host\_closures.rs#L124) with the desired granularity, i.e., seconds or milliseconds for further processing:
|
||||
Each Fluence peer, i.e. node in the Fluence peer-to-peer network, has the ability to provide a timestamp from a [builtin service](https://github.com/fluencelabs/aqua-lib/blob/b90f2dddc335c155995a74d8d97de8dbe6a029d2/builtin.aqua#L127). In Aqua, we can call a [timestamp function](https://github.com/fluencelabs/fluence/blob/527e26e08f3905e53208b575792712eeaee5deca/particle-closures/src/host\_closures.rs#L124) with the desired granularity, i.e., [seconds](https://github.com/fluencelabs/aqua-lib/blob/3298a0e23cfc67aca5b896798f8fb4008bd0a74f/builtin.aqua#L133) or [milliseconds](https://github.com/fluencelabs/aqua-lib/blob/3298a0e23cfc67aca5b896798f8fb4008bd0a74f/builtin.aqua#L130) for further processing:
|
||||
|
||||
```python
|
||||
-- aqua timestamp sourcing
|
||||
on peer:
|
||||
ts_ms_result <- peer.timestamp_ms()
|
||||
on node:
|
||||
ts_ms_result <- Peer.timestamp_ms()
|
||||
-- or
|
||||
ts_sec_result <- peer.timestamp_sec()
|
||||
ts_sec_result <- Peer.timestamp_sec()
|
||||
-- ...
|
||||
```
|
||||
|
||||
@ -43,9 +43,9 @@ In order to decentralize our timestamp oracle, we want to poll multiple peers in
|
||||
-- multi-peer timestamp sourcing
|
||||
-- ...
|
||||
results: *u64
|
||||
for peer <- many_peers_list par:
|
||||
for node <- many_peers_list par:
|
||||
on peer:
|
||||
results <- peer.timestamp_ms()
|
||||
results <- Peer.timestamp_ms()
|
||||
-- ...
|
||||
```
|
||||
|
||||
@ -64,7 +64,7 @@ The last thing to pin down concerning our timestamp acquisition is which peers t
|
||||
for node <- nodes par:
|
||||
on node:
|
||||
try:
|
||||
results <- node.timestamp_ms()
|
||||
results <- Peer.timestamp_ms()
|
||||
-- ...
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user