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
use crate::proto::abci::{Event as ProtoEvent, RequestBeginBlock, ResponseBeginBlock};
use crate::types::{Event, Evidence, Header, LastCommitInfo};
#[derive(Debug, Default)]
pub struct BeginBlockRequest {
pub hash: Vec<u8>,
pub header: Option<Header>,
pub last_commit_info: Option<LastCommitInfo>,
pub byzantine_validators: Vec<Evidence>,
}
impl From<RequestBeginBlock> for BeginBlockRequest {
fn from(request_begin_block: RequestBeginBlock) -> BeginBlockRequest {
BeginBlockRequest {
hash: request_begin_block.hash,
header: request_begin_block.header.into_option().map(Into::into),
last_commit_info: request_begin_block
.last_commit_info
.into_option()
.map(Into::into),
byzantine_validators: request_begin_block
.byzantine_validators
.into_iter()
.map(Into::into)
.collect(),
}
}
}
#[derive(Debug, Default)]
pub struct BeginBlockResponse {
pub events: Vec<Event>,
}
impl From<BeginBlockResponse> for ResponseBeginBlock {
fn from(begin_block_response: BeginBlockResponse) -> ResponseBeginBlock {
let mut response_begin_block = ResponseBeginBlock::new();
response_begin_block.events = begin_block_response
.events
.into_iter()
.map(Into::into)
.collect::<Vec<ProtoEvent>>()
.into();
response_begin_block
}
}