fn validate_payload(
    now: Time,
    payload: &Payload,
    pool_reader: &PoolReader<'_>,
    tip: &Block,
    payload_builder: &dyn PayloadBuilder,
) -> ValidationResult<PayloadValidationError> {
    let past_payloads =
        pool_reader.get_payloads_from_height(Height::from(CERTIFIED_HEIGHT + 1), tip.clone());
    assert!(past_payloads.len() == (PAST_PAYLOAD_HEIGHT + 1) as usize);
    assert!(
        past_payloads.first().unwrap().0
            == Height::from(CERTIFIED_HEIGHT + PAST_PAYLOAD_HEIGHT + 1)
    );
    assert!(past_payloads.last().unwrap().0 == Height::from(CERTIFIED_HEIGHT + 1));

    let validation_context = ValidationContext {
        time: now,
        registry_version: RegistryVersion::from(1),
        certified_height: Height::from(CERTIFIED_HEIGHT),
    };

    payload_builder.validate_payload(payload, &past_payloads, &validation_context)
}
/// Reads the past payloads from the pool and invokes the payload builder
/// validate function
Reads the past payloads from the pool and invokes the payload builder
validate function
Reads the past payloads from the pool and invokes the payload builder validate function
fn validate_payload(
    now: Time,
    payload: &Payload,
    pool_reader: &PoolReader<'_>,
    tip: &Block,
    payload_builder: &dyn PayloadBuilder,
) -> ValidationResult<PayloadValidationError> {
    let past_payloads =
        pool_reader.get_payloads_from_height(Height::from(CERTIFIED_HEIGHT + 1), tip.clone());
    assert!(past_payloads.len() == (PAST_PAYLOAD_HEIGHT + 1) as usize);
    assert!(
        past_payloads.first().unwrap().0
            == Height::from(CERTIFIED_HEIGHT + PAST_PAYLOAD_HEIGHT + 1)
    );
    assert!(past_payloads.last().unwrap().0 == Height::from(CERTIFIED_HEIGHT + 1));
    let validation_context = ValidationContext {
        time: now,
        registry_version: RegistryVersion::from(1),
        certified_height: Height::from(CERTIFIED_HEIGHT),
    };
    payload_builder.validate_payload(payload, &past_payloads, &validation_context)
}
fn validate_payload ( now : Time , payload : & Payload , pool_reader : & PoolReader < ' _ > , tip : & Block , payload_builder : & dyn PayloadBuilder , ) -> ValidationResult < PayloadValidationError > { let past_payloads = pool_reader . get_payloads_from_height ( Height :: from ( CERTIFIED_HEIGHT + 1 ) , tip . clone ( ) ) ; assert ! ( past_payloads len ( ) ( PAST_PAYLOAD_HEIGHT 1 ) as usize ) ; assert ! ( past_payloads first ( ) unwrap ( ) 0 Height from ( CERTIFIED_HEIGHT PAST_PAYLOAD_HEIGHT 1 ) ) ; assert ! ( past_payloads last ( ) unwrap ( ) 0 Height from ( CERTIFIED_HEIGHT 1 ) ) ; let validation_context = ValidationContext { time : now , registry_version : RegistryVersion :: from ( 1 ) , certified_height : Height :: from ( CERTIFIED_HEIGHT ) , } ; payload_builder . validate_payload ( payload , & past_payloads , & validation_context ) }
Reads the past payloads from the pool and invokes the payload builder
validate function
Reads the past payloads from the pool and invokes the payload builder validate function
now
Time
payload
&Payload
pool_reader
&PoolReader<'_>
tip
&Block
payload_builder
&dyn PayloadBuilder
now
Time
payload
&Payload
pool_reader
&PoolReader<'_>
tip
&Block
payload_builder
&dyn PayloadBuilder