pub fn read_inflation(
    asset: &SqlAsset,
    connection: &SqliteConnection,
) -> Result<
    (BTreeMap<OutPoint, AccountingAmount>, AccountingAmount),
    SqlCacheError,
> {
    let inflations =
        SqlInflation::belonging_to(asset).load::<SqlInflation>(connection)?;

    let mut known_inflation_map = BTreeMap::new();

    let mut unknown = AccountingAmount::default();

    for known_inflation in inflations {
        match (known_inflation.outpoint_txid, known_inflation.outpoint_vout) {
            // If both txid and vout are present add them to known_inflation_map
            (Some(txid), Some(vout)) => {
                known_inflation_map.insert(
                    OutPoint {
                        txid: Txid::from_hex(&txid[..])?,
                        vout: vout as u32,
                    },
                    AccountingAmount::from_fractioned_accounting_value(
                        asset.fractional_bits[0],
                        known_inflation.accounting_amount as AccountingValue,
                    ),
                );
            }
            // For everything else, add them to unknown inflation
            _ => {
                unknown = AccountingAmount::from_fractioned_accounting_value(
                    asset.fractional_bits[0],
                    known_inflation.accounting_amount as AccountingValue,
                );
            }
        }
    }

    Ok((known_inflation_map, unknown))
}
/// Read Inflation data associated to a table Asset entry
/// found at a given database connection
/// This returns the known_inflation and unknown inflation data structures
/// for the given asset in tupple. Which then can be directly used as fields
/// in Asset data structure.
Read Inflation data associated to a table Asset entry
found at a given database connection
This returns the known_inflation and unknown inflation data structures
for the given asset in tupple. Which then can be directly used as fields
in Asset data structure.
Read Inflation data associated to a table Asset entry found at a given database connection This returns the known_inflation and unknown inflation data structures for the given asset in tupple . Which then can be directly used as fields in Asset data structure .
pub fn read_inflation(
    asset: &SqlAsset,
    connection: &SqliteConnection,
) -> Result<
    (BTreeMap<OutPoint, AccountingAmount>, AccountingAmount),
    SqlCacheError,
> {
    let inflations =
        SqlInflation::belonging_to(asset).load::<SqlInflation>(connection)?;
    let mut known_inflation_map = BTreeMap::new();
    let mut unknown = AccountingAmount::default();
    for known_inflation in inflations {
        match (known_inflation.outpoint_txid, known_inflation.outpoint_vout) {
            // If both txid and vout are present add them to known_inflation_map
            (Some(txid), Some(vout)) => {
                known_inflation_map.insert(
                    OutPoint {
                        txid: Txid::from_hex(&txid[..])?,
                        vout: vout as u32,
                    },
                    AccountingAmount::from_fractioned_accounting_value(
                        asset.fractional_bits[0],
                        known_inflation.accounting_amount as AccountingValue,
                    ),
                );
            }
            // For everything else, add them to unknown inflation
            _ => {
                unknown = AccountingAmount::from_fractioned_accounting_value(
                    asset.fractional_bits[0],
                    known_inflation.accounting_amount as AccountingValue,
                );
            }
        }
    }
    Ok((known_inflation_map, unknown))
}
pub fn read_inflation ( asset : & SqlAsset , connection : & SqliteConnection , ) -> Result < ( BTreeMap < OutPoint , AccountingAmount > , AccountingAmount ) , SqlCacheError , > { let inflations = SqlInflation :: belonging_to ( asset ) . load :: < SqlInflation > ( connection ) ? ; let mut known_inflation_map = BTreeMap :: new ( ) ; let mut unknown = AccountingAmount :: default ( ) ; for known_inflation in inflations { match ( known_inflation . outpoint_txid , known_inflation . outpoint_vout ) { // If both txid and vout are present add them to known_inflation_map ( Some ( txid ) , Some ( vout ) ) => { known_inflation_map . insert ( OutPoint { txid : Txid :: from_hex ( & txid [ .. ] ) ? , vout : vout as u32 , } , AccountingAmount :: from_fractioned_accounting_value ( asset . fractional_bits [ 0 ] , known_inflation . accounting_amount as AccountingValue , ) , ) ; } // For everything else, add them to unknown inflation _ => { unknown = AccountingAmount :: from_fractioned_accounting_value ( asset . fractional_bits [ 0 ] , known_inflation . accounting_amount as AccountingValue , ) ; } } } Ok ( ( known_inflation_map , unknown ) ) }
Read Inflation data associated to a table Asset entry
found at a given database connection
This returns the known_inflation and unknown inflation data structures
for the given asset in tupple.
Read Inflation data associated to a table Asset entry found at a given database connection This returns the known_inflation and unknown inflation data structures for the given asset in tupple .
asset
&SqlAsset
connection
&SqliteConnection
asset
&SqlAsset
connection
&SqliteConnection