Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Upload entries to bigtable
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyera Eulberg committed Nov 15, 2023
1 parent 684d2fd commit da83052
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions storage-bigtable/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use {
timing::AtomicInterval,
transaction::{TransactionError, VersionedTransaction},
},
solana_storage_proto::convert::{generated, tx_by_addr},
solana_storage_proto::convert::{entries, generated, tx_by_addr},
solana_transaction_status::{
extract_and_fmt_memos, ConfirmedBlock, ConfirmedTransactionStatusWithSignature,
ConfirmedTransactionWithStatusMeta, Reward, TransactionByAddrInfo,
Expand Down Expand Up @@ -92,6 +92,10 @@ fn slot_to_blocks_key(slot: Slot) -> String {
slot_to_key(slot)
}

fn slot_to_entries_key(slot: Slot) -> String {
slot_to_key(slot)
}

fn slot_to_tx_by_addr_key(slot: Slot) -> String {
slot_to_key(!slot)
}
Expand Down Expand Up @@ -904,7 +908,10 @@ impl LedgerStorage {
slot
);
let mut by_addr: HashMap<&Pubkey, Vec<TransactionByAddrInfo>> = HashMap::new();
let confirmed_block = confirmed_block.block;
let VersionedConfirmedBlockWithEntries {
block: confirmed_block,
entries,
} = confirmed_block;

let mut tx_cells = vec![];
for (index, transaction_with_meta) in confirmed_block.transactions.iter().enumerate() {
Expand Down Expand Up @@ -955,6 +962,14 @@ impl LedgerStorage {
})
.collect();

let num_entries = entries.len();
let entry_cell = (
slot_to_entries_key(slot),
entries::Entries {
entries: entries.into_iter().enumerate().map(Into::into).collect(),
},
);

let mut tasks = vec![];

if !tx_cells.is_empty() {
Expand All @@ -976,6 +991,14 @@ impl LedgerStorage {
}));
}

if num_entries > 0 {
let conn = self.connection.clone();
tasks.push(tokio::spawn(async move {
conn.put_protobuf_cells_with_retry::<entries::Entries>("entries", &[entry_cell])
.await
}));
}

let mut bytes_written = 0;
let mut maybe_first_err: Option<Error> = None;

Expand Down Expand Up @@ -1016,6 +1039,7 @@ impl LedgerStorage {
"storage-bigtable-upload-block",
("slot", slot, i64),
("transactions", num_transactions, i64),
("entries", num_entries, i64),
("bytes", bytes_written, i64),
);
Ok(())
Expand Down

0 comments on commit da83052

Please sign in to comment.