/// Converts replicated state into a lazy tree.
Converts replicated state into a lazy tree.
Converts replicated state into a lazy tree .
fn state_as_tree(state: &ReplicatedState) -> LazyTree<'_> {
    let certification_version = state.metadata.certification_version;
    assert!(
        certification_version <= MAX_SUPPORTED_CERTIFICATION_VERSION,
        "Unable to certify state with version {}. Maximum supported certification version is {}",
        certification_version,
        MAX_SUPPORTED_CERTIFICATION_VERSION
    );
    fork(
        FiniteMap::default()
            .with("metadata", move || system_metadata_as_tree(&state.metadata))
            .with("streams", move || {
                streams_as_tree(state.streams(), certification_version)
            })
            .with("canister", move || {
                canisters_as_tree(&state.canister_states, certification_version)
            })
            .with_tree(
                "request_status",
                fork(IngressHistoryFork(&state.metadata.ingress_history)),
            )
            .with("subnet", move || {
                let inverted_routing_table = Arc::new(invert_routing_table(
                    &state.metadata.network_topology.routing_table,
                ));
                subnets_as_tree(
                    &state.metadata.network_topology.subnets,
                    inverted_routing_table,
                    certification_version,
                )
            })
            .with_tree(
                "time",
                num(state.metadata.batch_time.as_nanos_since_unix_epoch()),
            ),
    )
}
fn state_as_tree ( state : & ReplicatedState ) -> LazyTree < ' _ > { let certification_version = state . metadata . certification_version ; assert ! ( certification_version MAX_SUPPORTED_CERTIFICATION_VERSION " " certification_version MAX_SUPPORTED_CERTIFICATION_VERSION ) ; fork ( FiniteMap :: default ( ) . with ( " " , move | | system_metadata_as_tree ( & state . metadata ) ) . with ( " " , move | | { streams_as_tree ( state . streams ( ) , certification_version ) } ) . with ( " " , move | | { canisters_as_tree ( & state . canister_states , certification_version ) } ) . with_tree ( " " , fork ( IngressHistoryFork ( & state . metadata . ingress_history ) ) , ) . with ( " " , move | | { let inverted_routing_table = Arc :: new ( invert_routing_table ( & state . metadata . network_topology . routing_table , ) ) ; subnets_as_tree ( & state . metadata . network_topology . subnets , inverted_routing_table , certification_version , ) } ) . with_tree ( " " , num ( state . metadata . batch_time . as_nanos_since_unix_epoch ( ) ) , ) , ) }
Converts replicated state into a lazy tree.
Converts replicated state into a lazy tree .
state
&ReplicatedState