Skip to content

Commit

Permalink
chore(papyrus_storage): rename events table to emitter_to_events
Browse files Browse the repository at this point in the history
  • Loading branch information
AlonLStarkWare committed Dec 17, 2024
1 parent 21cd7a8 commit c480966
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions crates/papyrus_storage/src/body/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ where
key: (ContractAddress, EventIndex),
) -> StorageResult<EventIterByContractAddress<'env, 'txn>> {
let transaction_metadata_table = self.open_table(&self.tables.transaction_metadata)?;
let events_table = self.open_table(&self.tables.events)?;
let mut cursor = events_table.cursor(&self.txn)?;
let emitter_to_events_table = self.open_table(&self.tables.emitter_to_events)?;
let mut cursor = emitter_to_events_table.cursor(&self.txn)?;
let events_queue = if let Some((contract_address, tx_index)) =
cursor.lower_bound(&(key.0, key.1.0))?.map(|(key, _)| key)
{
Expand Down
8 changes: 4 additions & 4 deletions crates/papyrus_storage/src/body/events_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ fn revert_events() {

// Test events raw table.
let txn = storage_reader.begin_ro_txn().unwrap();
let events_table = txn.txn.open_table(&txn.tables.events).unwrap();
let emitter_to_events_table = txn.txn.open_table(&txn.tables.emitter_to_events).unwrap();
for (tx_idx, tx_output) in block.body.transaction_outputs.iter().enumerate() {
let transaction_index = TransactionIndex(block_number, TransactionOffsetInBlock(tx_idx));
for event in tx_output.events().iter() {
assert_matches!(
events_table.get(&txn.txn, &(event.from_address, transaction_index)),
emitter_to_events_table.get(&txn.txn, &(event.from_address, transaction_index)),
Ok(Some(_))
);
}
Expand Down Expand Up @@ -195,12 +195,12 @@ fn revert_events() {
);

let txn = storage_reader.begin_ro_txn().unwrap();
let events_table = txn.txn.open_table(&txn.tables.events).unwrap();
let emitter_to_events_table = txn.txn.open_table(&txn.tables.emitter_to_events).unwrap();
for (tx_idx, tx_output) in block.body.transaction_outputs.iter().enumerate() {
let transaction_index = TransactionIndex(block_number, TransactionOffsetInBlock(tx_idx));
for event in tx_output.events().iter() {
assert_matches!(
events_table.get(&txn.txn, &(event.from_address, transaction_index)),
emitter_to_events_table.get(&txn.txn, &(event.from_address, transaction_index)),
Ok(None)
);
}
Expand Down
8 changes: 4 additions & 4 deletions crates/papyrus_storage/src/body/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ impl BodyStorageWriter for StorageTxn<'_, RW> {
update_marker(&self.txn, &markers_table, block_number)?;

if self.scope != StorageScope::StateOnly {
let events_table = self.open_table(&self.tables.events)?;
let emitter_to_events_table = self.open_table(&self.tables.emitter_to_events)?;
let transaction_hash_to_idx_table =
self.open_table(&self.tables.transaction_hash_to_idx)?;
let transaction_metadata_table = self.open_table(&self.tables.transaction_metadata)?;
Expand All @@ -361,7 +361,7 @@ impl BodyStorageWriter for StorageTxn<'_, RW> {
&file_offset_table,
&transaction_hash_to_idx_table,
&transaction_metadata_table,
&events_table,
&emitter_to_events_table,
block_number,
)?;
}
Expand Down Expand Up @@ -397,7 +397,7 @@ impl BodyStorageWriter for StorageTxn<'_, RW> {
let transaction_metadata_table = self.open_table(&self.tables.transaction_metadata)?;
let transaction_hash_to_idx_table =
self.open_table(&self.tables.transaction_hash_to_idx)?;
let events_table = self.open_table(&self.tables.events)?;
let emitter_to_events_table = self.open_table(&self.tables.emitter_to_events)?;

let transactions = self
.get_block_transactions(block_number)?
Expand All @@ -416,7 +416,7 @@ impl BodyStorageWriter for StorageTxn<'_, RW> {
let tx_index = TransactionIndex(block_number, TransactionOffsetInBlock(offset));

for event in tx_output.events().iter() {
events_table.delete(&self.txn, &(event.from_address, tx_index))?;
emitter_to_events_table.delete(&self.txn, &(event.from_address, tx_index))?;
}
transaction_hash_to_idx_table.delete(&self.txn, tx_hash)?;
transaction_metadata_table.delete(&self.txn, &tx_index)?;
Expand Down
6 changes: 3 additions & 3 deletions crates/papyrus_storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ pub fn open_storage(
deprecated_declared_classes: db_writer
.create_simple_table("deprecated_declared_classes")?,
deployed_contracts: db_writer.create_simple_table("deployed_contracts")?,
events: db_writer.create_common_prefix_table("events")?,
emitter_to_events: db_writer.create_common_prefix_table("emitter_to_events")?,
headers: db_writer.create_simple_table("headers")?,
markers: db_writer.create_simple_table("markers")?,
nonces: db_writer.create_common_prefix_table("nonces")?,
Expand Down Expand Up @@ -495,7 +495,7 @@ impl<Mode: TransactionKind> StorageTxn<'_, Mode> {
) -> StorageResult<TableHandle<'_, K, V, T>> {
if self.scope == StorageScope::StateOnly {
let unused_tables = [
self.tables.events.name,
self.tables.emitter_to_events.name,
self.tables.transaction_hash_to_idx.name,
self.tables.transaction_metadata.name,
];
Expand Down Expand Up @@ -528,7 +528,7 @@ struct_field_names! {
deprecated_declared_classes: TableIdentifier<ClassHash, VersionZeroWrapper<IndexedDeprecatedContractClass>, SimpleTable>,
// TODO(dvir): consider use here also the CommonPrefix table type.
deployed_contracts: TableIdentifier<(ContractAddress, BlockNumber), VersionZeroWrapper<ClassHash>, SimpleTable>,
events: TableIdentifier<(ContractAddress, TransactionIndex), NoVersionValueWrapper<NoValue>, CommonPrefix>,
emitter_to_events: TableIdentifier<(ContractAddress, TransactionIndex), NoVersionValueWrapper<NoValue>, CommonPrefix>,
headers: TableIdentifier<BlockNumber, VersionZeroWrapper<StorageBlockHeader>, SimpleTable>,
markers: TableIdentifier<MarkerKind, VersionZeroWrapper<BlockNumber>, SimpleTable>,
nonces: TableIdentifier<(ContractAddress, BlockNumber), VersionZeroWrapper<Nonce>, CommonPrefix>,
Expand Down

0 comments on commit c480966

Please sign in to comment.