async fn handle_fetch_op_hash_data(
        &self,
        op_hashes: Vec<ai_hash::SgdOpHash>,
    ) -> CellResult<
        Vec<(
            ai_hash::AnySgdHash,
            ai_hash::SgdOpHash,
            aingle_types::sgd_op::SgdOp,
        )>,
    > {
        // FIXME: Test this query.
        // 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 results = self
            .env()
            .async_reader(move |txn| {
                let mut positions = "?,".repeat(op_hashes.len());
                positions.pop();
                let sql = format!(
                    "
                SELECT SgdOp.hash, SgdOp.basis_hash, SgdOp.type AS sgd_type,
                Header.blob AS header_blob, Entry.blob AS entry_blob
                FROM SGdOp
                JOIN Header ON SgdOp.header_hash = Header.hash
                LEFT JOIN Entry ON Header.entry_hash = Entry.hash
                WHERE
                SgdOp.when_integrated IS NOT NULL
                AND
                SgdOp.hash in ({})
                ",
                    positions
                );
                let mut stmt = txn.prepare(&sql)?;
                let r = stmt
                    .query_and_then(rusqlite::params_from_iter(op_hashes.into_iter()), |row| {
                        let basis_hash: AnySgdHash = row.get("basis_hash")?;
                        let header = from_blob::<SignedHeader>(row.get("header_blob")?)?;
                        let op_type: SgdOpType = row.get("sgd_type")?;
                        let hash: SgdOpHash = row.get("hash")?;
                        // Check the entry isn't private before gossiping it.
                        let mut entry: Option<Entry> = None;
                        if header
                            .0
                            .entry_type()
                            .filter(|et| *et.visibility() == EntryVisibility::Public)
                            .is_some()
                        {
                            let e: Option<Vec<u8>> = row.get("entry_blob")?;
                            entry = match e {
                                Some(entry) => Some(from_blob::<Entry>(entry)?),
                                None => None,
                            };
                        }
                        let op = SgdOp::from_type(op_type, header, entry)?;
                        StateQueryResult::Ok((basis_hash, hash, op))
                    })?
                    .collect::<StateQueryResult<Vec<_>>>()?;
                StateQueryResult::Ok(r)
            })
            .await?;
        Ok(results)
    }
/// The network module is requesting the content for sgd ops
The network module is requesting the content for sgd ops
The network module is requesting the content for sgd ops
async fn handle_fetch_op_hash_data(
        &self,
        op_hashes: Vec<ai_hash::SgdOpHash>,
    ) -> CellResult<
        Vec<(
            ai_hash::AnySgdHash,
            ai_hash::SgdOpHash,
            aingle_types::sgd_op::SgdOp,
        )>,
    > {
        // FIXME: Test this query.
        // 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 results = self
            .env()
            .async_reader(move |txn| {
                let mut positions = "?,".repeat(op_hashes.len());
                positions.pop();
                let sql = format!(
                    "
                SELECT SgdOp.hash, SgdOp.basis_hash, SgdOp.type AS sgd_type,
                Header.blob AS header_blob, Entry.blob AS entry_blob
                FROM SGdOp
                JOIN Header ON SgdOp.header_hash = Header.hash
                LEFT JOIN Entry ON Header.entry_hash = Entry.hash
                WHERE
                SgdOp.when_integrated IS NOT NULL
                AND
                SgdOp.hash in ({})
                ",
                    positions
                );
                let mut stmt = txn.prepare(&sql)?;
                let r = stmt
                    .query_and_then(rusqlite::params_from_iter(op_hashes.into_iter()), |row| {
                        let basis_hash: AnySgdHash = row.get("basis_hash")?;
                        let header = from_blob::<SignedHeader>(row.get("header_blob")?)?;
                        let op_type: SgdOpType = row.get("sgd_type")?;
                        let hash: SgdOpHash = row.get("hash")?;
                        // Check the entry isn't private before gossiping it.
                        let mut entry: Option<Entry> = None;
                        if header
                            .0
                            .entry_type()
                            .filter(|et| *et.visibility() == EntryVisibility::Public)
                            .is_some()
                        {
                            let e: Option<Vec<u8>> = row.get("entry_blob")?;
                            entry = match e {
                                Some(entry) => Some(from_blob::<Entry>(entry)?),
                                None => None,
                            };
                        }
                        let op = SgdOp::from_type(op_type, header, entry)?;
                        StateQueryResult::Ok((basis_hash, hash, op))
                    })?
                    .collect::<StateQueryResult<Vec<_>>>()?;
                StateQueryResult::Ok(r)
            })
            .await?;
        Ok(results)
    }
async fn handle_fetch_op_hash_data ( & self , op_hashes : Vec < ai_hash :: SgdOpHash > , ) -> CellResult < Vec < ( ai_hash :: AnySgdHash , ai_hash :: SgdOpHash , aingle_types :: sgd_op :: SgdOp , ) > , > { // FIXME: Test this query. // 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 results = self . env ( ) . async_reader ( move | txn | { let mut positions = " " . repeat ( op_hashes . len ( ) ) ; positions . pop ( ) ; let sql = format ! ( " " positions ) ; let mut stmt = txn . prepare ( & sql ) ? ; let r = stmt . query_and_then ( rusqlite :: params_from_iter ( op_hashes . into_iter ( ) ) , | row | { let basis_hash : AnySgdHash = row . get ( " " ) ? ; let header = from_blob :: < SignedHeader > ( row . get ( " " ) ? ) ? ; let op_type : SgdOpType = row . get ( " " ) ? ; let hash : SgdOpHash = row . get ( " " ) ? ; // Check the entry isn't private before gossiping it. let mut entry : Option < Entry > = None ; if header . 0 . entry_type ( ) . filter ( | et | * et . visibility ( ) == EntryVisibility :: Public ) . is_some ( ) { let e : Option < Vec < u8 > > = row . get ( " " ) ? ; entry = match e { Some ( entry ) => Some ( from_blob :: < Entry > ( entry ) ? ) , None => None , } ; } let op = SgdOp :: from_type ( op_type , header , entry ) ? ; StateQueryResult :: Ok ( ( basis_hash , hash , op ) ) } ) ? . collect :: < StateQueryResult < Vec < _ > > > ( ) ? ; StateQueryResult :: Ok ( r ) } ) . await ? ; Ok ( results ) }
The network module is requesting the content for sgd ops
The network module is requesting the content for sgd ops
&self
op_hashes
Vec<ai_hash::SgdOpHash>
&self
op_hashes
Vec<ai_hash::SgdOpHash>