Skip to content

Commit

Permalink
chore: run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Evalir committed Mar 25, 2023
1 parent c350a2f commit 29e2dff
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 21 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ target/

.env

logs/
logs/

.DS_Store
10 changes: 3 additions & 7 deletions src/db/mongodb/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ impl TryFrom<&BlockData<'_>> for BlockDocument {
number,
slot: block_data.slot,
timestamp: block.timestamp.as_u64(),
transactions: block_data
.tx_to_versioned_hashes
.keys()
.map(|hash| hash.clone())
.collect(),
transactions: block_data.tx_to_versioned_hashes.keys().copied().collect(),
})
}
}
Expand Down Expand Up @@ -90,8 +86,8 @@ impl TryFrom<&TransactionData<'_>> for TransactionDocument {
from: tx.from,
to,
value: tx.value,
block_hash: block_hash,
block_number: block_number,
block_hash,
block_number,
blob_versioned_hashes: tx_data.blob_versioned_hashes.clone(),
})
}
Expand Down
16 changes: 7 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,16 @@ async fn main() -> Result<(), StdError> {

loop {
if let Some(latest_beacon_block) = context.beacon_api.get_block(None).await? {
let latest_slot: u32 = latest_beacon_block.slot.parse()?;
let latest_slot: u32 = latest_beacon_block.slot.parse()?;

if current_slot < latest_slot {
slot_processor
.process_slots(current_slot, latest_slot)
.await;
if current_slot < latest_slot {
slot_processor
.process_slots(current_slot, latest_slot)
.await;

current_slot = latest_slot;
}
current_slot = latest_slot;
}
};

}
thread::sleep(Duration::from_secs(1));
}
}
6 changes: 3 additions & 3 deletions src/slot_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl<'a> SlotProcessor<'a> {
panic!();
};

current_slot = current_slot + 1;
current_slot += 1;
}

self.save_slot(current_slot).await
Expand Down Expand Up @@ -108,7 +108,7 @@ impl<'a> SlotProcessor<'a> {

let blobs = match beacon_api.get_blobs_sidecar(slot).await? {
Some(blobs_sidecar) => {
if blobs_sidecar.blobs.len() == 0 {
if blobs_sidecar.blobs.is_empty() {
info!("[Slot {}] Skipping as blobs sidecar is empty", slot);

return Ok(());
Expand Down Expand Up @@ -168,7 +168,7 @@ impl<'a> SlotProcessor<'a> {
commitment,
data: blob,
versioned_hash,
tx_hash: tx_hash.clone(),
tx_hash: *tx_hash,
},
Some(&mut self.db_options),
)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/web3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn sha256(value: &str) -> Result<H256, StdError> {
}

pub fn calculate_versioned_hash(commitment: &String) -> Result<H256, StdError> {
let hashed_commitment = sha256(&commitment)?;
let hashed_commitment = sha256(commitment)?;

// Replace first byte with the blob commitment version byte
let hashed_commitment = &mut hashed_commitment.as_bytes()[1..].to_vec();
Expand Down

0 comments on commit 29e2dff

Please sign in to comment.