Files
solana/sdk/src/storage_program.rs

61 lines
1.4 KiB
Rust
Raw Normal View History

2018-12-14 20:39:10 -08:00
use crate::hash::Hash;
use crate::pubkey::Pubkey;
use crate::signature::{Keypair, KeypairUtil, Signature};
2018-12-14 20:39:10 -08:00
use crate::transaction::Transaction;
2018-12-04 08:20:41 -08:00
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum StorageProgram {
SubmitMiningProof {
sha_state: Hash,
entry_height: u64,
signature: Signature,
},
2018-12-04 08:20:41 -08:00
}
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,
entry_height: u64,
signature: Signature,
) -> Self;
2018-12-04 08:20:41 -08:00
}
impl StorageTransaction for Transaction {
fn storage_new_mining_proof(
from_keypair: &Keypair,
sha_state: Hash,
last_id: Hash,
entry_height: u64,
signature: Signature,
) -> Self {
let program = StorageProgram::SubmitMiningProof {
sha_state,
entry_height,
signature,
};
2018-12-04 08:20:41 -08:00
Transaction::new(
from_keypair,
&[from_keypair.pubkey()],
2018-12-04 08:20:41 -08:00
id(),
&program,
last_id,
0,
)
}
}