Move loader_transaction out of src/

This commit is contained in:
Michael Vines
2018-12-04 15:18:35 -08:00
parent 7af95eadcc
commit 122627dda2
5 changed files with 9 additions and 19 deletions

View File

@ -6,6 +6,7 @@ pub mod budget_program;
pub mod budget_transaction;
pub mod hash;
pub mod loader_instruction;
pub mod loader_transaction;
pub mod native_loader;
pub mod native_program;
pub mod packet;

View File

@ -0,0 +1,39 @@
//! The `loader_transaction` module provides functionality for loading and calling a program
use hash::Hash;
use loader_instruction::LoaderInstruction;
use pubkey::Pubkey;
use signature::Keypair;
use transaction::Transaction;
pub trait LoaderTransaction {
fn loader_write(
from_keypair: &Keypair,
loader: Pubkey,
offset: u32,
bytes: Vec<u8>,
last_id: Hash,
fee: u64,
) -> Self;
fn loader_finalize(from_keypair: &Keypair, loader: Pubkey, last_id: Hash, fee: u64) -> Self;
}
impl LoaderTransaction for Transaction {
fn loader_write(
from_keypair: &Keypair,
loader: Pubkey,
offset: u32,
bytes: Vec<u8>,
last_id: Hash,
fee: u64,
) -> Self {
let instruction = LoaderInstruction::Write { offset, bytes };
Transaction::new(from_keypair, &[], loader, &instruction, last_id, fee)
}
fn loader_finalize(from_keypair: &Keypair, loader: Pubkey, last_id: Hash, fee: u64) -> Self {
let instruction = LoaderInstruction::Finalize;
Transaction::new(from_keypair, &[], loader, &instruction, last_id, fee)
}
}