Skip to content

Commit

Permalink
adding previous blockhash and renaming txs to transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
godmodegalactus committed Sep 21, 2023
1 parent 147120c commit 886c80f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion cluster-endpoints/src/grpc_subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,14 @@ fn process_block(
};

ProducedBlock {
txs,
transactions: txs,
block_height: block
.block_height
.map(|block_height| block_height.block_height)
.unwrap(),
block_time: block.block_time.map(|time| time.timestamp).unwrap() as u64,
blockhash: block.blockhash,
previous_blockhash: block.parent_blockhash,
commitment_config,
leader_id,
parent_slot: block.parent_slot,
Expand Down
7 changes: 5 additions & 2 deletions core/src/structures/produced_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ pub struct TransactionInfo {

#[derive(Default, Debug, Clone)]
pub struct ProducedBlock {
pub txs: Vec<TransactionInfo>,
pub transactions: Vec<TransactionInfo>,
pub leader_id: Option<String>,
pub blockhash: String,
pub block_height: u64,
pub slot: Slot,
pub parent_slot: Slot,
pub block_time: u64,
pub commitment_config: CommitmentConfig,
pub previous_blockhash: String,
}

impl ProducedBlock {
Expand All @@ -40,6 +41,7 @@ impl ProducedBlock {
let txs = block.transactions.unwrap_or_default();

let blockhash = block.blockhash;
let previous_blockhash = block.previous_blockhash;
let parent_slot = block.parent_slot;

let txs = txs
Expand Down Expand Up @@ -139,10 +141,11 @@ impl ProducedBlock {
let block_time = block.block_time.unwrap_or(0) as u64;

ProducedBlock {
txs,
transactions: txs,
block_height,
leader_id,
blockhash,
previous_blockhash,
parent_slot,
block_time,
slot,
Expand Down
3 changes: 2 additions & 1 deletion history/tests/inmemory_block_store_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ pub fn create_test_block(slot: u64, commitment_config: CommitmentConfig) -> Prod
ProducedBlock {
block_height: slot,
blockhash: Hash::new_unique().to_string(),
previous_blockhash: Hash::new_unique().to_string(),
parent_slot: slot - 1,
txs: vec![],
transactions: vec![],
block_time: 0,
commitment_config,
leader_id: None,
Expand Down
3 changes: 2 additions & 1 deletion history/tests/multiple_strategy_block_store_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ pub fn create_test_block(slot: u64, commitment_config: CommitmentConfig) -> Prod
ProducedBlock {
block_height: slot,
blockhash: Hash::new_unique().to_string(),
previous_blockhash: Hash::new_unique().to_string(),
parent_slot: slot - 1,
txs: vec![],
transactions: vec![],
block_time: 0,
commitment_config,
leader_id: None,
Expand Down
2 changes: 1 addition & 1 deletion services/src/data_caching_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl DataCachingService {
_ => TransactionConfirmationStatus::Processed,
};

for tx in block.txs {
for tx in block.transactions {
if data_cache.txs.update_status(
&tx.signature,
TransactionStatus {
Expand Down

0 comments on commit 886c80f

Please sign in to comment.