Skip to content

Commit

Permalink
refactor: function renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbinth committed Jun 28, 2024
1 parent 13f499e commit 1bc11e2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
5 changes: 4 additions & 1 deletion crates/block-producer/src/batch_builder/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ impl TransactionBatch {
produced_nullifiers.push(note.nullifier());
if let Some(header) = note.header() {
if !unauthenticated_input_notes.insert(header.id()) {
return Err(BuildBatchError::DuplicatedNoteId(header.id(), txs));
return Err(BuildBatchError::DuplicateUnauthenticatedNote(
header.id(),
txs,
));
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions crates/block-producer/src/batch_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,11 @@ where

let dangling_notes = self.find_dangling_notes(&txs).await;
if !dangling_notes.is_empty() {
let stored_notes = match self.store.get_note_paths(dangling_notes.iter()).await {
Ok(stored_notes) => stored_notes,
Err(err) => return Err(BuildBatchError::NotePathsError(err, txs)),
};
let stored_notes =
match self.store.get_note_authentication_info(dangling_notes.iter()).await {
Ok(stored_notes) => stored_notes,
Err(err) => return Err(BuildBatchError::NotePathsError(err, txs)),
};
let missing_notes: Vec<_> = dangling_notes
.into_iter()
.filter(|note_id| !stored_notes.contains_key(note_id))
Expand Down
4 changes: 2 additions & 2 deletions crates/block-producer/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub enum BuildBatchError {
NotePathsError(NotePathsError, Vec<ProvenTransaction>),

#[error("Duplicated note ID in the batch: {0}")]
DuplicatedNoteId(NoteId, Vec<ProvenTransaction>),
DuplicateUnauthenticatedNote(NoteId, Vec<ProvenTransaction>),

#[error("Unauthenticated transaction notes not found in the store: {0:?}")]
UnauthenticatedNotesNotFound(Vec<NoteId>, Vec<ProvenTransaction>),
Expand All @@ -93,7 +93,7 @@ impl BuildBatchError {
BuildBatchError::TooManyNotesCreated(_, txs) => txs,
BuildBatchError::NotesSmtError(_, txs) => txs,
BuildBatchError::NotePathsError(_, txs) => txs,
BuildBatchError::DuplicatedNoteId(_, txs) => txs,
BuildBatchError::DuplicateUnauthenticatedNote(_, txs) => txs,
BuildBatchError::UnauthenticatedNotesNotFound(_, txs) => txs,
}
}
Expand Down
11 changes: 9 additions & 2 deletions crates/block-producer/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ pub trait Store: ApplyBlock {
notes: impl Iterator<Item = &NoteId> + Send,
) -> Result<BlockInputs, BlockInputsError>;

async fn get_note_paths(
/// Returns note authentication information for the set of specified notes.
///
/// If authentication info could for a note does not exist in the store, the note is omitted
/// from the returned set of notes.
///
/// TODO: right now this return only Merkle paths per note, but this will need to be updated to
/// return full authentication info.
async fn get_note_authentication_info(
&self,
notes: impl Iterator<Item = &NoteId> + Send,
) -> Result<BTreeMap<NoteId, MerklePath>, NotePathsError>;
Expand Down Expand Up @@ -230,7 +237,7 @@ impl Store for DefaultStore {
Ok(store_response.try_into()?)
}

async fn get_note_paths(
async fn get_note_authentication_info(
&self,
notes: impl Iterator<Item = &NoteId> + Send,
) -> Result<BTreeMap<NoteId, MerklePath>, NotePathsError> {
Expand Down
4 changes: 2 additions & 2 deletions crates/block-producer/src/test_utils/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl Store for MockStoreSuccess {
})
}

async fn get_note_paths(
async fn get_note_authentication_info(
&self,
_notes: impl Iterator<Item = &NoteId> + Send,
) -> Result<BTreeMap<NoteId, MerklePath>, NotePathsError> {
Expand Down Expand Up @@ -312,7 +312,7 @@ impl Store for MockStoreFailure {
Err(BlockInputsError::GrpcClientError(String::new()))
}

async fn get_note_paths(
async fn get_note_authentication_info(
&self,
_notes: impl Iterator<Item = &NoteId> + Send,
) -> Result<BTreeMap<NoteId, MerklePath>, NotePathsError> {
Expand Down

0 comments on commit 1bc11e2

Please sign in to comment.