Rename storage_last_id to storage_block_hash

This commit is contained in:
Michael Vines 2019-03-02 09:50:41 -08:00 committed by Greg Fitzgerald
parent ea110efabd
commit 81cd461591
5 changed files with 22 additions and 22 deletions

View File

@ -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));

View File

@ -72,9 +72,9 @@ impl JsonRpcRequestProcessor {
Ok(self.bank()?.transaction_count() as u64)
}
fn get_storage_mining_last_id(&self) -> Result<String> {
let id = self.storage_state.get_last_id();
Ok(bs58::encode(id).into_string())
fn get_storage_block_hash(&self) -> Result<String> {
let hash = self.storage_state.get_storage_block_hash();
Ok(bs58::encode(hash).into_string())
}
fn get_storage_mining_entry_height(&self) -> Result<u64> {
@ -170,8 +170,8 @@ pub trait RpcSol {
#[rpc(meta, name = "sendTransaction")]
fn send_transaction(&self, _: Self::Metadata, _: Vec<u8>) -> Result<String>;
#[rpc(meta, name = "getStorageMiningLastId")]
fn get_storage_mining_last_id(&self, _: Self::Metadata) -> Result<String>;
#[rpc(meta, name = "getStorageBlockHash")]
fn get_storage_block_hash(&self, _: Self::Metadata) -> Result<String>;
#[rpc(meta, name = "getStorageMiningEntryHeight")]
fn get_storage_mining_entry_height(&self, _: Self::Metadata) -> Result<u64>;
@ -328,11 +328,11 @@ impl RpcSol for RpcSolImpl {
Ok(signature)
}
fn get_storage_mining_last_id(&self, meta: Self::Metadata) -> Result<String> {
fn get_storage_block_hash(&self, meta: Self::Metadata) -> Result<String> {
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<u64> {

View File

@ -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",
};

View File

@ -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 {

View File

@ -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);
}