1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use crate::avm::parser::Context;
use crate::pvm::parser::atomic_block_parser::Transaction;
use crate::pvm::parser::base_tx_parser::BaseTx;
use crate::utils::conversion::{pop_i16, pop_i64};
use std::borrow::Borrow;
use std::error::Error;
use tracing::{instrument, trace};
#[derive(Serialize, Deserialize, Debug)]
pub struct AdvanceTimeTx {
pub time_proposal: i64,
}
#[instrument(fields(block_id = % _context.tx_id, tx_type = "advance_time"))]
pub fn advance_time_tx_parser(
_raw_msg: &[u8],
_tx_id: String,
_context: &mut Context,
) -> Result<Transaction, Box<dyn Error>> {
let codec_id = pop_i16(_raw_msg[*_context.offset..=(*_context.offset + 1)].borrow());
trace!("Codec_id : {:?}", codec_id);
*_context.offset += 2;
*_context.offset += 4;
let time = pop_i64(_raw_msg[*_context.offset..=(*_context.offset + 7)].borrow());
trace!("Time : {:?}", time);
*_context.offset += 8;
let advance_time = AdvanceTimeTx {
time_proposal: time,
};
Ok(Transaction {
base_tx: BaseTx {
type_id: 19,
network_id: 0,
blockchain_id: "".to_string(),
transferable_outputs: vec![],
transferable_inputs: vec![],
memo: vec![],
},
tx_id: _tx_id,
add_validator_tx: None,
import_tx: None,
export_tx: None,
add_subnet_validator_tx: None,
add_delegator_tx: None,
create_blockchain_tx: None,
create_subnet_tx: None,
advance_time_tx: Some(advance_time),
reward_validator_tx: None,
credentials: vec![],
})
}