pub fn add_block_to_ledger_db(
    ledger_db: &mut LedgerDB,
    recipients: &[PublicAddress],
    key_images: &[KeyImage],
    rng: &mut (impl CryptoRng + RngCore),
) -> u64 {
    // Each initial account gets 5k MOB, which are each 10^12 picoMOB.
    let value: u64 = PER_RECIPIENT_AMOUNT;

    let outputs: Vec<_> = recipients
        .iter()
        .map(|recipient| {
            TxOut::new(
                // TODO: allow for subaddress index!
                value,
                recipient,
                &RistrettoPrivate::from_random(rng),
                Default::default(),
                rng,
            )
            .unwrap()
        })
        .collect();

    let block_contents = BlockContents::new(key_images.to_vec(), outputs.clone());

    let num_blocks = ledger_db.num_blocks().expect("failed to get block height");

    let new_block;
    if num_blocks > 0 {
        let parent = ledger_db
            .get_block(num_blocks - 1)
            .expect("failed to get parent block");
        new_block = Block::new(
            BLOCK_VERSION,
            &parent.id,
            num_blocks as BlockIndex,
            &Default::default(),
            &block_contents,
        );
    } else {
        new_block = Block::new_origin_block(&outputs);
    }

    ledger_db
        .append_block(&new_block, &block_contents, None)
        .expect("failed writing initial transactions");

    ledger_db.num_blocks().expect("failed to get block height")
}
/// Adds a block containing one txo for each provided recipient and returns new block height.
///
/// # Arguments
/// * `ledger_db`
/// * `recipients` - Recipients of outputs.
/// * `rng`
Adds a block containing one txo for each provided recipient and returns new block height.
Adds a block containing one txo for each provided recipient and returns new block height .
pub fn add_block_to_ledger_db(
    ledger_db: &mut LedgerDB,
    recipients: &[PublicAddress],
    key_images: &[KeyImage],
    rng: &mut (impl CryptoRng + RngCore),
) -> u64 {
    // Each initial account gets 5k MOB, which are each 10^12 picoMOB.
    let value: u64 = PER_RECIPIENT_AMOUNT;
    let outputs: Vec<_> = recipients
        .iter()
        .map(|recipient| {
            TxOut::new(
                // TODO: allow for subaddress index!
                value,
                recipient,
                &RistrettoPrivate::from_random(rng),
                Default::default(),
                rng,
            )
            .unwrap()
        })
        .collect();
    let block_contents = BlockContents::new(key_images.to_vec(), outputs.clone());
    let num_blocks = ledger_db.num_blocks().expect("failed to get block height");
    let new_block;
    if num_blocks > 0 {
        let parent = ledger_db
            .get_block(num_blocks - 1)
            .expect("failed to get parent block");
        new_block = Block::new(
            BLOCK_VERSION,
            &parent.id,
            num_blocks as BlockIndex,
            &Default::default(),
            &block_contents,
        );
    } else {
        new_block = Block::new_origin_block(&outputs);
    }
    ledger_db
        .append_block(&new_block, &block_contents, None)
        .expect("failed writing initial transactions");
    ledger_db.num_blocks().expect("failed to get block height")
}
pub fn add_block_to_ledger_db ( ledger_db : & mut LedgerDB , recipients : & [ PublicAddress ] , key_images : & [ KeyImage ] , rng : & mut ( impl CryptoRng + RngCore ) , ) -> u64 { // Each initial account gets 5k MOB, which are each 10^12 picoMOB. let value : u64 = PER_RECIPIENT_AMOUNT ; let outputs : Vec < _ > = recipients . iter ( ) . map ( | recipient | { TxOut :: new ( // TODO: allow for subaddress index! value , recipient , & RistrettoPrivate :: from_random ( rng ) , Default :: default ( ) , rng , ) . unwrap ( ) } ) . collect ( ) ; let block_contents = BlockContents :: new ( key_images . to_vec ( ) , outputs . clone ( ) ) ; let num_blocks = ledger_db . num_blocks ( ) . expect ( " " ) ; let new_block ; if num_blocks > 0 { let parent = ledger_db . get_block ( num_blocks - 1 ) . expect ( " " ) ; new_block = Block :: new ( BLOCK_VERSION , & parent . id , num_blocks as BlockIndex , & Default :: default ( ) , & block_contents , ) ; } else { new_block = Block :: new_origin_block ( & outputs ) ; } ledger_db . append_block ( & new_block , & block_contents , None ) . expect ( " " ) ; ledger_db . num_blocks ( ) . expect ( " " ) }
Adds a block containing one txo for each provided recipient and returns new block height.
Adds a block containing one txo for each provided recipient and returns new block height .
ledger_db
&mut LedgerDB
recipients
&[PublicAddress]
key_images
&[KeyImage]
rng
&mut (impl CryptoRng + RngCore)
ledger_db
&mut LedgerDB
recipients
&[PublicAddress]
key_images
&[KeyImage]
rng
&mut (impl CryptoRng + RngCore)