mirror of
https://github.com/fluencelabs/aquavm
synced 2025-06-27 13:41:32 +00:00
introduce %timestamp% (#250)
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "air-interpreter-interface"
|
||||
description = "Interface of the AIR interpreter"
|
||||
version = "0.8.0"
|
||||
version = "0.9.0"
|
||||
authors = ["Fluence Labs"]
|
||||
edition = "2018"
|
||||
license = "Apache-2.0"
|
||||
|
@ -14,6 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
use fluence_it_types::ne_vec::NEVec;
|
||||
use fluence_it_types::IValue;
|
||||
use marine_rs_sdk::marine;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
@ -27,4 +29,29 @@ pub struct RunParameters {
|
||||
|
||||
/// Peer id of a current peer.
|
||||
pub current_peer_id: String,
|
||||
|
||||
/// Unix timestamp from a particle in milliseconds.
|
||||
/// It represents time when this particle was sent from the init peer id.
|
||||
pub timestamp: u64,
|
||||
}
|
||||
|
||||
impl RunParameters {
|
||||
pub fn new(init_peer_id: String, current_peer_id: String, timestamp: u64) -> Self {
|
||||
Self {
|
||||
init_peer_id,
|
||||
current_peer_id,
|
||||
timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn into_ivalue(self) -> IValue {
|
||||
let run_parameters = vec![
|
||||
IValue::String(self.init_peer_id),
|
||||
IValue::String(self.current_peer_id),
|
||||
IValue::U64(self.timestamp),
|
||||
];
|
||||
// unwrap is safe here because run_parameters is non-empty array
|
||||
let run_parameters = NEVec::new(run_parameters).unwrap();
|
||||
IValue::Record(run_parameters)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user