Move storage_program out of src/

This commit is contained in:
Michael Vines
2018-12-04 08:20:41 -08:00
parent ea6e042a6f
commit 27d456bf93
12 changed files with 155 additions and 104 deletions

View File

@ -7,6 +7,7 @@ pub mod native_program;
pub mod packet;
pub mod pubkey;
pub mod signature;
pub mod storage_program;
pub mod system_instruction;
pub mod system_program;
pub mod timing;

View File

@ -0,0 +1,40 @@
use hash::Hash;
use pubkey::Pubkey;
use signature::{Keypair, KeypairUtil};
use transaction::Transaction;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum StorageProgram {
SubmitMiningProof { sha_state: Hash },
}
pub const STORAGE_PROGRAM_ID: [u8; 32] = [
130, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
];
pub fn check_id(program_id: &Pubkey) -> bool {
program_id.as_ref() == STORAGE_PROGRAM_ID
}
pub fn id() -> Pubkey {
Pubkey::new(&STORAGE_PROGRAM_ID)
}
pub trait StorageTransaction {
fn storage_new_mining_proof(from_keypair: &Keypair, sha_state: Hash, last_id: Hash) -> Self;
}
impl StorageTransaction for Transaction {
fn storage_new_mining_proof(from_keypair: &Keypair, sha_state: Hash, last_id: Hash) -> Self {
let program = StorageProgram::SubmitMiningProof { sha_state };
Transaction::new(
from_keypair,
&[from_keypair.pubkey()],
id(),
&program,
last_id,
0,
)
}
}