async fn handle_fetch_op_hashes_for_constraints(
        &self,
        sgd_arc: aingle_p2p::sgd_arc::SgdArc,
        since: Timestamp,
        until: Timestamp,
    ) -> CellResult<Vec<SgdOpHash>> {
        // FIXME: Test this query.
        let full = (sgd_arc.coverage() - 1.0).abs() < f64::EPSILON;
        let (storage_1, storage_2) = split_arc(&sgd_arc);
        // TODO: SQL_PERF: Really on the fence about this query.
        // It has the potential to be slow if data density is very high
        // but this is ideally not the case for most apps so is it
        // worth everyone paying the cost of asyncifying?
        let result = self
            .env()
            .async_reader(move |txn| {
                let r = if full {
                    txn.prepare_cached(aingle_sqlite::sql::sql_cell::FETCH_OP_HASHES_FULL)?
                        .query_map(
                            named_params! {
                            ":from": since.to_sql_ms_lossy(),
                            ":to": until.to_sql_ms_lossy(),
                            },
                            |row| row.get("hash"),
                        )?
                        .collect::<rusqlite::Result<Vec<_>>>()?
                } else {
                    match (storage_1, storage_2) {
                        (None, None) => Vec::with_capacity(0),
                        (None, Some(_)) => unreachable!("Cannot have only second arc"),
                        (Some(storage_1), None) => txn
                            .prepare_cached(
                                aingle_sqlite::sql::sql_cell::FETCH_OP_HASHES_SINGLE,
                            )?
                            .query_map(
                                named_params! {
                                ":from": since.to_sql_ms_lossy(),
                                ":to": until.to_sql_ms_lossy(),
                                ":storage_start_1": storage_1.0,
                                ":storage_end_1": storage_1.1,
                                },
                                |row| row.get("hash"),
                            )?
                            .collect::<rusqlite::Result<Vec<_>>>()?,
                        (Some(storage_1), Some(storage_2)) => txn
                            .prepare_cached(aingle_sqlite::sql::sql_cell::FETCH_OP_HASHES_WRAP)?
                            .query_map(
                                named_params! {
                                ":from": since.to_sql_ms_lossy(),
                                ":to": until.to_sql_ms_lossy(),
                                ":storage_start_1": storage_1.0,
                                ":storage_end_1": storage_1.1,
                                ":storage_start_2": storage_2.0,
                                ":storage_end_2": storage_2.1,
                                },
                                |row| row.get("hash"),
                            )?
                            .collect::<rusqlite::Result<Vec<_>>>()?,
                    }
                };
                DatabaseResult::Ok(r)
            })
            .await?;
        Ok(result)
    }
/// the network module is requesting a list of sgd op hashes
the network module is requesting a list of sgd op hashes
the network module is requesting a list of sgd op hashes
async fn handle_fetch_op_hashes_for_constraints(
        &self,
        sgd_arc: aingle_p2p::sgd_arc::SgdArc,
        since: Timestamp,
        until: Timestamp,
    ) -> CellResult<Vec<SgdOpHash>> {
        // FIXME: Test this query.
        let full = (sgd_arc.coverage() - 1.0).abs() < f64::EPSILON;
        let (storage_1, storage_2) = split_arc(&sgd_arc);
        // TODO: SQL_PERF: Really on the fence about this query.
        // It has the potential to be slow if data density is very high
        // but this is ideally not the case for most apps so is it
        // worth everyone paying the cost of asyncifying?
        let result = self
            .env()
            .async_reader(move |txn| {
                let r = if full {
                    txn.prepare_cached(aingle_sqlite::sql::sql_cell::FETCH_OP_HASHES_FULL)?
                        .query_map(
                            named_params! {
                            ":from": since.to_sql_ms_lossy(),
                            ":to": until.to_sql_ms_lossy(),
                            },
                            |row| row.get("hash"),
                        )?
                        .collect::<rusqlite::Result<Vec<_>>>()?
                } else {
                    match (storage_1, storage_2) {
                        (None, None) => Vec::with_capacity(0),
                        (None, Some(_)) => unreachable!("Cannot have only second arc"),
                        (Some(storage_1), None) => txn
                            .prepare_cached(
                                aingle_sqlite::sql::sql_cell::FETCH_OP_HASHES_SINGLE,
                            )?
                            .query_map(
                                named_params! {
                                ":from": since.to_sql_ms_lossy(),
                                ":to": until.to_sql_ms_lossy(),
                                ":storage_start_1": storage_1.0,
                                ":storage_end_1": storage_1.1,
                                },
                                |row| row.get("hash"),
                            )?
                            .collect::<rusqlite::Result<Vec<_>>>()?,
                        (Some(storage_1), Some(storage_2)) => txn
                            .prepare_cached(aingle_sqlite::sql::sql_cell::FETCH_OP_HASHES_WRAP)?
                            .query_map(
                                named_params! {
                                ":from": since.to_sql_ms_lossy(),
                                ":to": until.to_sql_ms_lossy(),
                                ":storage_start_1": storage_1.0,
                                ":storage_end_1": storage_1.1,
                                ":storage_start_2": storage_2.0,
                                ":storage_end_2": storage_2.1,
                                },
                                |row| row.get("hash"),
                            )?
                            .collect::<rusqlite::Result<Vec<_>>>()?,
                    }
                };
                DatabaseResult::Ok(r)
            })
            .await?;
        Ok(result)
    }
async fn handle_fetch_op_hashes_for_constraints ( & self , sgd_arc : aingle_p2p :: sgd_arc :: SgdArc , since : Timestamp , until : Timestamp , ) -> CellResult < Vec < SgdOpHash > > { // FIXME: Test this query. let full = ( sgd_arc . coverage ( ) - 1.0 ) . abs ( ) < f64 :: EPSILON ; let ( storage_1 , storage_2 ) = split_arc ( & sgd_arc ) ; // TODO: SQL_PERF: Really on the fence about this query. // It has the potential to be slow if data density is very high // but this is ideally not the case for most apps so is it // worth everyone paying the cost of asyncifying? let result = self . env ( ) . async_reader ( move | txn | { let r = if full { txn . prepare_cached ( aingle_sqlite :: sql :: sql_cell :: FETCH_OP_HASHES_FULL ) ? . query_map ( named_params ! { " " since to_sql_ms_lossy ( ) " " until to_sql_ms_lossy ( ) } , | row | row . get ( " " ) , ) ? . collect :: < rusqlite :: Result < Vec < _ > > > ( ) ? } else { match ( storage_1 , storage_2 ) { ( None , None ) => Vec :: with_capacity ( 0 ) , ( None , Some ( _ ) ) => unreachable ! ( " " ) , ( Some ( storage_1 ) , None ) => txn . prepare_cached ( aingle_sqlite :: sql :: sql_cell :: FETCH_OP_HASHES_SINGLE , ) ? . query_map ( named_params ! { " " since to_sql_ms_lossy ( ) " " until to_sql_ms_lossy ( ) " " storage_1 0 " " storage_1 1 } , | row | row . get ( " " ) , ) ? . collect :: < rusqlite :: Result < Vec < _ > > > ( ) ? , ( Some ( storage_1 ) , Some ( storage_2 ) ) => txn . prepare_cached ( aingle_sqlite :: sql :: sql_cell :: FETCH_OP_HASHES_WRAP ) ? . query_map ( named_params ! { " " since to_sql_ms_lossy ( ) " " until to_sql_ms_lossy ( ) " " storage_1 0 " " storage_1 1 " " storage_2 0 " " storage_2 1 } , | row | row . get ( " " ) , ) ? . collect :: < rusqlite :: Result < Vec < _ > > > ( ) ? , } } ; DatabaseResult :: Ok ( r ) } ) . await ? ; Ok ( result ) }
the network module is requesting a list of sgd op hashes
the network module is requesting a list of sgd op hashes
&self
sgd_arc
aingle_p2p::sgd_arc::SgdArc
since
Timestamp
until
Timestamp
&self
sgd_arc
aingle_p2p::sgd_arc::SgdArc
since
Timestamp
until
Timestamp