Change replicators to slot-based (#4118)

This commit is contained in:
Sagar Dhawan
2019-05-03 16:27:53 -07:00
committed by GitHub
parent 5bb75a5894
commit a7b695c27a
17 changed files with 255 additions and 484 deletions

View File

@@ -11,18 +11,18 @@ use solana_sdk::signature::Signature;
pub enum StorageInstruction {
SubmitMiningProof {
sha_state: Hash,
entry_height: u64,
slot: u64,
signature: Signature,
},
AdvertiseStorageRecentBlockhash {
hash: Hash,
entry_height: u64,
slot: u64,
},
ClaimStorageReward {
entry_height: u64,
slot: u64,
},
ProofValidation {
entry_height: u64,
slot: u64,
proofs: Vec<CheckedProof>,
},
}
@@ -30,12 +30,12 @@ pub enum StorageInstruction {
pub fn mining_proof(
from_pubkey: &Pubkey,
sha_state: Hash,
entry_height: u64,
slot: u64,
signature: Signature,
) -> Instruction {
let storage_instruction = StorageInstruction::SubmitMiningProof {
sha_state,
entry_height,
slot,
signature,
};
let account_metas = vec![AccountMeta::new(*from_pubkey, true)];
@@ -45,34 +45,27 @@ pub fn mining_proof(
pub fn advertise_recent_blockhash(
from_pubkey: &Pubkey,
storage_hash: Hash,
entry_height: u64,
slot: u64,
) -> Instruction {
let storage_instruction = StorageInstruction::AdvertiseStorageRecentBlockhash {
hash: storage_hash,
entry_height,
slot,
};
let account_metas = vec![AccountMeta::new(*from_pubkey, true)];
Instruction::new(id(), &storage_instruction, account_metas)
}
pub fn proof_validation(
from_pubkey: &Pubkey,
entry_height: u64,
proofs: Vec<CheckedProof>,
) -> Instruction {
pub fn proof_validation(from_pubkey: &Pubkey, slot: u64, proofs: Vec<CheckedProof>) -> Instruction {
let mut account_metas = vec![AccountMeta::new(*from_pubkey, true)];
proofs.iter().for_each(|checked_proof| {
account_metas.push(AccountMeta::new(checked_proof.proof.id, false))
});
let storage_instruction = StorageInstruction::ProofValidation {
entry_height,
proofs,
};
let storage_instruction = StorageInstruction::ProofValidation { slot, proofs };
Instruction::new(id(), &storage_instruction, account_metas)
}
pub fn reward_claim(from_pubkey: &Pubkey, entry_height: u64) -> Instruction {
let storage_instruction = StorageInstruction::ClaimStorageReward { entry_height };
pub fn reward_claim(from_pubkey: &Pubkey, slot: u64) -> Instruction {
let storage_instruction = StorageInstruction::ClaimStorageReward { slot };
let account_metas = vec![AccountMeta::new(*from_pubkey, true)];
Instruction::new(id(), &storage_instruction, account_metas)
}