Skip to content

Commit 480c46e

Browse files
CopilotSteake
andcommitted
Fix state management duplication and doc comment syntax
- Fix doc comment syntax in miner.rs (use //! instead of ///!) - Remove duplicate StateManager from ValidatorNode and MinerNode - Both nodes now use Blockchain's StateManager with storage support - Update test to access state through blockchain.state() method - Resolves inconsistent state management between nodes and blockchain Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
1 parent e76b46d commit 480c46e

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

crates/bitcell-node/src/miner.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
///! Miner node implementation
1+
//! Miner node implementation
22
use crate::{NodeConfig, Result, MetricsRegistry, Blockchain, TransactionPool, NetworkManager};
33
use bitcell_crypto::SecretKey;
44
use bitcell_ca::{Glider, GliderPattern};
5-
use bitcell_state::StateManager;
65
use std::sync::Arc;
76
use bitcell_consensus::Transaction;
87

98
/// Miner node
109
pub struct MinerNode {
1110
pub config: NodeConfig,
1211
pub secret_key: Arc<SecretKey>,
13-
pub state: StateManager,
1412
pub glider_strategy: GliderPattern,
1513
pub metrics: MetricsRegistry,
1614
pub blockchain: Blockchain,
@@ -45,7 +43,6 @@ impl MinerNode {
4543
Ok(Self {
4644
config,
4745
secret_key,
48-
state: StateManager::new(),
4946
glider_strategy: GliderPattern::Standard,
5047
metrics,
5148
blockchain,

crates/bitcell-node/src/validator.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
use crate::{NodeConfig, Result, MetricsRegistry, Blockchain, TransactionPool};
44
use bitcell_consensus::Block;
5-
use bitcell_state::StateManager;
65
use bitcell_network::PeerManager;
76
use bitcell_crypto::SecretKey;
87
use std::sync::Arc;
@@ -15,7 +14,6 @@ const MAX_TXS_PER_BLOCK: usize = 1000;
1514
/// Validator node
1615
pub struct ValidatorNode {
1716
pub config: NodeConfig,
18-
pub state: StateManager,
1917
pub peers: PeerManager,
2018
pub metrics: MetricsRegistry,
2119
pub blockchain: Blockchain,
@@ -59,7 +57,6 @@ impl ValidatorNode {
5957

6058
Ok(Self {
6159
config,
62-
state: StateManager::new(),
6360
peers: PeerManager::new(),
6461
metrics,
6562
blockchain,
@@ -291,6 +288,8 @@ mod tests {
291288
fn test_validator_creation() {
292289
let config = NodeConfig::default();
293290
let node = ValidatorNode::new(config).unwrap();
294-
assert_eq!(node.state.accounts.len(), 0);
291+
let state = node.blockchain.state();
292+
let state_guard = state.read().unwrap();
293+
assert_eq!(state_guard.accounts.len(), 0);
295294
}
296295
}

0 commit comments

Comments
 (0)