Skip to content

Commit

Permalink
kvstore: add suport for writting tx to checkpoint to dynamodb
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed Sep 6, 2023
1 parent b8a1de2 commit b67dc3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/sui-kvstore/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub enum KVTable {
Events,
CheckpointContent,
CheckpointSummary,
TransactionToCheckpoint,
State,
}

Expand Down Expand Up @@ -86,6 +87,7 @@ impl DynamoDbClient {
KVTable::State => "state",
KVTable::CheckpointContent => "cc",
KVTable::CheckpointSummary => "cs",
KVTable::TransactionToCheckpoint => "tx2c",
}
.to_string()
}
Expand Down
8 changes: 8 additions & 0 deletions crates/sui-kvstore/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,15 @@ where
let mut transactions = vec![];
let mut effects = vec![];
let mut events = vec![];
let mut transactions_to_checkpoint = vec![];

for content in contents.iter() {
let transaction_digest = content.transaction.digest().into_inner().to_vec();
effects.push((transaction_digest.clone(), content.effects.clone()));
transactions_to_checkpoint.push((
transaction_digest.clone(),
checkpoint_summary.sequence_number,
));
transactions.push((transaction_digest, content.transaction.clone()));

if let Some(event_digest) = content.effects.events_digest() {
Expand All @@ -162,6 +167,9 @@ where
.await?;
client.multi_set(KVTable::Effects, effects).await?;
client.multi_set(KVTable::Events, events).await?;
client
.multi_set(KVTable::TransactionToCheckpoint, transactions_to_checkpoint)
.await?;

let serialized_checkpoint_number = bcs::to_bytes(
&TaggedKey::CheckpointSequenceNumber(checkpoint_summary.sequence_number),
Expand Down

0 comments on commit b67dc3a

Please sign in to comment.