Move storage_program out of src/
This commit is contained in:
@ -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;
|
||||
|
40
sdk/src/storage_program.rs
Normal file
40
sdk/src/storage_program.rs
Normal 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,
|
||||
)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user