14
14
// You should have received a copy of the GNU General Public License
15
15
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
16
16
17
- //! A graph utility for managing fragments
17
+ //! A graph utility for managing unbacked parachain fragments.
18
18
//!
19
19
//! Each node in the graph represents a candidate. Nodes do not uniquely refer to a parachain
20
20
//! block for two reasons.
32
32
//! attribute of a path, not a candidate.
33
33
//!
34
34
//! We also need to handle cycles, including nodes for candidates which produce a header
35
- //! which is the same as the parent's.
35
+ //! which is the same as its parent's.
36
+ //!
37
+ //! The graph exposes a 'frontier' of nodes which appear to be the best to build upon
38
+ //! and is the primary means for higher-level code to select candidates to build upon.
36
39
37
40
use std:: {
38
41
collections:: { hash_map:: Entry as HEntry , HashMap , HashSet } ,
@@ -54,18 +57,19 @@ use polkadot_primitives::vstaging::{
54
57
GroupIndex , GroupRotationInfo , Hash , Header , Id as ParaId , SessionIndex , ValidatorIndex ,
55
58
} ;
56
59
60
+ // TODO [now]: separate graph per relay-parent (constraints)?
61
+ // TODO [now]: keep nodes and graphs separate? recompute / prune graphs
62
+ // on every new relay parent?
63
+ // TODO [now]: API for selecting backed candidates
57
64
pub ( crate ) struct FragmentGraph {
58
65
para : ParaId ,
59
- // Fragment nodes based on fragment head-data.
60
- nodes : HashMap < Hash , FragmentNode > ,
66
+ relay_parent : RelayChainBlockInfo ,
67
+ base_constraints : Constraints ,
61
68
}
62
69
63
- impl FragmentGraph {
64
- fn is_empty ( & self ) -> bool {
65
- self . nodes . is_empty ( )
66
- }
67
-
68
- // TODO [now]: pruning
70
+ struct CandidateGraph {
71
+ // TODO [now]: semi-ordered pile of candidates.
72
+ // we'll need to support some kinds of traversal and insertions
69
73
}
70
74
71
75
enum FragmentState {
@@ -76,24 +80,21 @@ enum FragmentState {
76
80
}
77
81
78
82
struct FragmentNode {
79
- // Head -data of the parent node.
80
- parent_fragment : CandidateHash ,
83
+ // The hash of the head -data of the parent node
84
+ parent : Hash ,
81
85
// Candidate hashes of children.
82
86
children : Vec < CandidateHash > ,
83
87
fragment : Fragment ,
84
88
erasure_root : Hash ,
85
89
state : FragmentState ,
86
- depth : usize ,
87
90
}
88
91
89
92
impl FragmentNode {
90
93
fn relay_parent ( & self ) -> Hash {
91
94
self . fragment . relay_parent ( ) . hash
92
95
}
93
96
94
- fn depth ( & self ) -> usize {
95
- self . depth
96
- }
97
+
97
98
98
99
/// Produce a candidate receipt from this fragment node.
99
100
fn produce_candidate_receipt ( & self , para_id : ParaId ) -> CommittedCandidateReceipt {
0 commit comments