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
59
60
61
62
63
64
65
66
use std::mem;
use casper_hashing::Digest;
use casper_types::{ProtocolVersion, PublicKey, SecretKey};
use super::deploy_item::DeployItem;
#[derive(Debug)]
pub struct ExecuteRequest {
pub parent_state_hash: Digest,
pub block_time: u64,
pub deploys: Vec<DeployItem>,
pub protocol_version: ProtocolVersion,
pub proposer: PublicKey,
}
impl ExecuteRequest {
pub fn new(
parent_state_hash: Digest,
block_time: u64,
deploys: Vec<DeployItem>,
protocol_version: ProtocolVersion,
proposer: PublicKey,
) -> Self {
Self {
parent_state_hash,
block_time,
deploys,
protocol_version,
proposer,
}
}
pub fn take_deploys(&mut self) -> Vec<DeployItem> {
mem::take(&mut self.deploys)
}
pub fn deploys(&self) -> &Vec<DeployItem> {
&self.deploys
}
}
impl Default for ExecuteRequest {
fn default() -> Self {
let proposer_secret_key =
SecretKey::ed25519_from_bytes([0; SecretKey::ED25519_LENGTH]).unwrap();
let proposer = PublicKey::from(&proposer_secret_key);
Self {
parent_state_hash: Digest::hash(&[]),
block_time: 0,
deploys: vec![],
protocol_version: Default::default(),
proposer,
}
}
}