From 886c80faa6d9341e8456cfe4819ccbade4da717c Mon Sep 17 00:00:00 2001 From: godmodegalactus Date: Thu, 21 Sep 2023 15:44:58 +0200 Subject: [PATCH] adding previous blockhash and renaming txs to transactions --- cluster-endpoints/src/grpc_subscription.rs | 3 ++- core/src/structures/produced_block.rs | 7 +++++-- history/tests/inmemory_block_store_tests.rs | 3 ++- history/tests/multiple_strategy_block_store_tests.rs | 3 ++- services/src/data_caching_service.rs | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cluster-endpoints/src/grpc_subscription.rs b/cluster-endpoints/src/grpc_subscription.rs index 62c42fbe..235b3af5 100644 --- a/cluster-endpoints/src/grpc_subscription.rs +++ b/cluster-endpoints/src/grpc_subscription.rs @@ -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, diff --git a/core/src/structures/produced_block.rs b/core/src/structures/produced_block.rs index 586f7eb3..aa206900 100644 --- a/core/src/structures/produced_block.rs +++ b/core/src/structures/produced_block.rs @@ -20,7 +20,7 @@ pub struct TransactionInfo { #[derive(Default, Debug, Clone)] pub struct ProducedBlock { - pub txs: Vec, + pub transactions: Vec, pub leader_id: Option, pub blockhash: String, pub block_height: u64, @@ -28,6 +28,7 @@ pub struct ProducedBlock { pub parent_slot: Slot, pub block_time: u64, pub commitment_config: CommitmentConfig, + pub previous_blockhash: String, } impl ProducedBlock { @@ -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 @@ -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, diff --git a/history/tests/inmemory_block_store_tests.rs b/history/tests/inmemory_block_store_tests.rs index 5d7a69eb..7e4c55e7 100644 --- a/history/tests/inmemory_block_store_tests.rs +++ b/history/tests/inmemory_block_store_tests.rs @@ -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, diff --git a/history/tests/multiple_strategy_block_store_tests.rs b/history/tests/multiple_strategy_block_store_tests.rs index f1bf6981..4a089d03 100644 --- a/history/tests/multiple_strategy_block_store_tests.rs +++ b/history/tests/multiple_strategy_block_store_tests.rs @@ -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, diff --git a/services/src/data_caching_service.rs b/services/src/data_caching_service.rs index 9f881d69..a3f177c4 100644 --- a/services/src/data_caching_service.rs +++ b/services/src/data_caching_service.rs @@ -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 {