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
67
68
69
70
71
crate::ix!();

pub trait FindBlock {

    /**
      | Return whether node has the block and
      | optionally return block metadata or
      | contents.
      |
      */
    fn find_block(&mut self, 
        hash:  &u256,
        block: &FoundBlock) -> bool;
}

pub trait FindFirstBlockWithTimeAndHeight {

    /**
      | Find first block in the chain with
      | timestamp >= the given time and height >=
      | than the given height, return false if
      | there is no block with a high enough
      | timestamp and height. Optionally return
      | block information.
      */
    fn find_first_block_with_time_and_height(&mut self, 
        min_time:   i64,
        min_height: i32,
        block:      &FoundBlock) -> bool;
}

pub trait FindAncestorByHeight {

    /**
      | Find ancestor of block at specified height
      | and optionally return ancestor
      | information.
      */
    fn find_ancestor_by_height(&mut self, 
        block_hash:      &u256,
        ancestor_height: i32,
        ancestor_out:    &FoundBlock) -> bool;
}

pub trait FindAncestorByHash {

    /**
      | Return whether block descends from
      | a specified ancestor, and optionally
      | return ancestor information.
      */
    fn find_ancestor_by_hash(&mut self, 
        block_hash:    &u256,
        ancestor_hash: &u256,
        ancestor_out:  &FoundBlock) -> bool;
}

pub trait FindCommonAncestor {

    /**
      | Find most recent common ancestor between
      | two blocks and optionally return block
      | information.
      */
    fn find_common_ancestor(&mut self, 
        block_hash1:  &u256,
        block_hash2:  &u256,
        ancestor_out: &FoundBlock,
        block1_out:   &FoundBlock,
        block2_out:   &FoundBlock) -> bool;
}