diff --git a/core/src/replicator.rs b/core/src/replicator.rs index 82926569a2..4a0c399bd9 100644 --- a/core/src/replicator.rs +++ b/core/src/replicator.rs @@ -158,10 +158,10 @@ impl Replicator { info!("Got leader: {:?}", leader); - let (storage_last_id, storage_entry_height) = + let (storage_block_hash, storage_entry_height) = Self::poll_for_last_id_and_entry_height(&cluster_info)?; - let signature = keypair.sign(storage_last_id.as_ref()); + let signature = keypair.sign(storage_block_hash.as_ref()); let entry_height = get_entry_heights_from_last_id(&signature, storage_entry_height); info!("replicating entry_height: {}", entry_height); @@ -338,8 +338,8 @@ impl Replicator { RpcClient::new_from_socket(rpc_peers[node_idx].rpc) }; - let storage_last_id = rpc_client - .make_rpc_request(2, RpcRequest::GetStorageMiningLastId, None) + let storage_block_hash = rpc_client + .make_rpc_request(2, RpcRequest::GetStorageBlockHash, None) .expect("rpc request") .to_string(); let storage_entry_height = rpc_client @@ -348,7 +348,7 @@ impl Replicator { .as_u64() .unwrap(); if get_segment_from_entry(storage_entry_height) != 0 { - return Ok((storage_last_id, storage_entry_height)); + return Ok((storage_block_hash, storage_entry_height)); } info!("max entry_height: {}", storage_entry_height); sleep(Duration::from_secs(3)); diff --git a/core/src/rpc.rs b/core/src/rpc.rs index 7661a3e539..66135118cd 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -72,9 +72,9 @@ impl JsonRpcRequestProcessor { Ok(self.bank()?.transaction_count() as u64) } - fn get_storage_mining_last_id(&self) -> Result { - let id = self.storage_state.get_last_id(); - Ok(bs58::encode(id).into_string()) + fn get_storage_block_hash(&self) -> Result { + let hash = self.storage_state.get_storage_block_hash(); + Ok(bs58::encode(hash).into_string()) } fn get_storage_mining_entry_height(&self) -> Result { @@ -170,8 +170,8 @@ pub trait RpcSol { #[rpc(meta, name = "sendTransaction")] fn send_transaction(&self, _: Self::Metadata, _: Vec) -> Result; - #[rpc(meta, name = "getStorageMiningLastId")] - fn get_storage_mining_last_id(&self, _: Self::Metadata) -> Result; + #[rpc(meta, name = "getStorageBlockHash")] + fn get_storage_block_hash(&self, _: Self::Metadata) -> Result; #[rpc(meta, name = "getStorageMiningEntryHeight")] fn get_storage_mining_entry_height(&self, _: Self::Metadata) -> Result; @@ -328,11 +328,11 @@ impl RpcSol for RpcSolImpl { Ok(signature) } - fn get_storage_mining_last_id(&self, meta: Self::Metadata) -> Result { + fn get_storage_block_hash(&self, meta: Self::Metadata) -> Result { meta.request_processor .read() .unwrap() - .get_storage_mining_last_id() + .get_storage_block_hash() } fn get_storage_mining_entry_height(&self, meta: Self::Metadata) -> Result { diff --git a/core/src/rpc_request.rs b/core/src/rpc_request.rs index 366a856b00..613c803394 100644 --- a/core/src/rpc_request.rs +++ b/core/src/rpc_request.rs @@ -137,7 +137,7 @@ pub enum RpcRequest { RegisterNode, SignVote, DeregisterNode, - GetStorageMiningLastId, + GetStorageBlockHash, GetStorageMiningEntryHeight, GetStoragePubkeysForEntryHeight, } @@ -157,7 +157,7 @@ impl RpcRequest { RpcRequest::RegisterNode => "registerNode", RpcRequest::SignVote => "signVote", RpcRequest::DeregisterNode => "deregisterNode", - RpcRequest::GetStorageMiningLastId => "getStorageMiningLastId", + RpcRequest::GetStorageBlockHash => "getStorageBlockHash", RpcRequest::GetStorageMiningEntryHeight => "getStorageMiningEntryHeight", RpcRequest::GetStoragePubkeysForEntryHeight => "getStoragePubkeysForEntryHeight", }; diff --git a/core/src/storage_stage.rs b/core/src/storage_stage.rs index 70acb2aea1..8359c56ea4 100644 --- a/core/src/storage_stage.rs +++ b/core/src/storage_stage.rs @@ -39,7 +39,7 @@ pub struct StorageStateInner { storage_results: StorageResults, storage_keys: StorageKeys, replicator_map: ReplicatorMap, - storage_last_id: Hash, + storage_block_hash: Hash, entry_height: u64, } @@ -93,7 +93,7 @@ impl StorageState { storage_results, replicator_map, entry_height: 0, - storage_last_id: Hash::default(), + storage_block_hash: Hash::default(), }; StorageState { @@ -111,8 +111,8 @@ impl StorageState { self.state.read().unwrap().storage_results[idx] } - pub fn get_last_id(&self) -> Hash { - self.state.read().unwrap().storage_last_id + pub fn get_storage_block_hash(&self) -> Hash { + self.state.read().unwrap().storage_block_hash } pub fn get_entry_height(&self) -> u64 { diff --git a/programs/native/storage/tests/storage.rs b/programs/native/storage/tests/storage.rs index a203ea505d..7458dd95ec 100644 --- a/programs/native/storage/tests/storage.rs +++ b/programs/native/storage/tests/storage.rs @@ -25,7 +25,7 @@ fn get_storage_entry_height(bank: &Bank, account: Pubkey) -> u64 { 0 } -fn get_storage_last_id(bank: &Bank, account: Pubkey) -> Hash { +fn get_storage_block_hash(bank: &Bank, account: Pubkey) -> Hash { if let Some(storage_system_account) = bank.get_account(&account) { let state = deserialize(&storage_system_account.userdata); if let Ok(state) = state { @@ -48,7 +48,7 @@ fn test_bank_storage() { let x = 42; let last_id = genesis_block.hash(); let x2 = x * 2; - let storage_last_id = hash(&[x2]); + let storage_block_hash = hash(&[x2]); bank.register_tick(&last_id); @@ -71,7 +71,7 @@ fn test_bank_storage() { let tx = StorageTransaction::new_advertise_recent_block_hash( &bob, - storage_last_id, + storage_block_hash, last_id, ENTRIES_PER_SEGMENT, ); @@ -94,5 +94,5 @@ fn test_bank_storage() { get_storage_entry_height(&bank, bob.pubkey()), ENTRIES_PER_SEGMENT ); - assert_eq!(get_storage_last_id(&bank, bob.pubkey()), storage_last_id); + assert_eq!(get_storage_block_hash(&bank, bob.pubkey()), storage_block_hash); }