-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy pathocean.rs
More file actions
39 lines (36 loc) · 1.24 KB
/
Copy pathocean.rs
File metadata and controls
39 lines (36 loc) · 1.24 KB
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
use crate::ffi::{BlockV2Info as BlockV2InfoFFI, CrossBoundaryResult};
use ain_ocean::BlockV2Info;
// manually convert since BlockV2InfoFFI is belongs to CPP which can't impl From -> Into
pub fn convert(b: &BlockV2InfoFFI) -> BlockV2Info {
BlockV2Info {
height: b.height,
difficulty: b.difficulty,
version: b.version,
median_time: b.median_time,
minter_block_count: b.minter_block_count,
size: b.size,
size_stripped: b.size_stripped,
weight: b.weight,
stake_modifier: b.stake_modifier.to_owned(),
minter: b.minter.to_owned(),
masternode: b.masternode.to_owned(),
}
}
pub fn ocean_index_block(result: &mut CrossBoundaryResult, block: String, b: &BlockV2InfoFFI) {
match ain_ocean::index_block(block, &convert(b)) {
Ok(()) => result.ok = true,
Err(e) => {
result.ok = false;
result.reason = e.to_string()
}
}
}
pub fn ocean_invalidate_block(result: &mut CrossBoundaryResult, block: String, b: &BlockV2InfoFFI) {
match ain_ocean::invalidate_block(block, &convert(b)) {
Ok(()) => result.ok = true,
Err(e) => {
result.ok = false;
result.reason = e.to_string()
}
}
}