Replace transaction traits with structs

Also:
* SystemTransaction::new -> new_account
* SystemTransaction::new_create -> new_program_account
This commit is contained in:
Greg Fitzgerald
2019-02-01 08:36:35 -07:00
committed by Grimes
parent 1b3e7f734a
commit dad0bfe447
34 changed files with 347 additions and 419 deletions

View File

@ -23,7 +23,6 @@ use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::timing::duration_as_s;
use solana_sdk::transaction::Transaction;
use std::collections::{HashSet, VecDeque};
use std::env;
use std::fs::remove_dir_all;
@ -1817,7 +1816,7 @@ fn send_tx_and_retry_get_balance(
let mut client = mk_client(leader);
trace!("getting leader last_id");
let last_id = client.get_last_id();
let mut tx = Transaction::system_new(&alice, *bob_pubkey, transfer_amount, last_id);
let mut tx = SystemTransaction::new_account(&alice, *bob_pubkey, transfer_amount, last_id, 0);
info!(
"executing transfer of {} from {} to {}",
transfer_amount,

View File

@ -56,7 +56,7 @@ impl Loader {
// allocate, populate, finalize, and spawn loader
let tx = Transaction::system_create(
let tx = SystemTransaction::new_program_account(
&mint_keypair,
loader.pubkey(),
genesis_block.last_id(),
@ -68,7 +68,7 @@ impl Loader {
check_tx_results(&bank, &tx, bank.process_transactions(&vec![tx.clone()]));
let name = String::from(loader_name);
let tx = Transaction::loader_write(
let tx = LoaderTransaction::new_write(
&loader,
solana_native_loader::id(),
0,
@ -78,7 +78,7 @@ impl Loader {
);
check_tx_results(&bank, &tx, bank.process_transactions(&vec![tx.clone()]));
let tx = Transaction::loader_finalize(
let tx = LoaderTransaction::new_finalize(
&loader,
solana_native_loader::id(),
genesis_block.last_id(),
@ -86,7 +86,7 @@ impl Loader {
);
check_tx_results(&bank, &tx, bank.process_transactions(&vec![tx.clone()]));
let tx = Transaction::system_spawn(&loader, genesis_block.last_id(), 0);
let tx = SystemTransaction::new_spawn(&loader, genesis_block.last_id(), 0);
check_tx_results(&bank, &tx, bank.process_transactions(&vec![tx.clone()]));
Loader {
@ -135,7 +135,7 @@ impl Program {
// allocate, populate, finalize and spawn program
let tx = Transaction::system_create(
let tx = SystemTransaction::new_program_account(
&loader.mint_keypair,
program.pubkey(),
loader.genesis_block.last_id(),
@ -153,7 +153,7 @@ impl Program {
let chunk_size = 256; // Size of chunk just needs to fit into tx
let mut offset = 0;
for chunk in userdata.chunks(chunk_size) {
let tx = Transaction::loader_write(
let tx = LoaderTransaction::new_write(
&program,
loader.loader,
offset,
@ -169,7 +169,7 @@ impl Program {
offset += chunk_size as u32;
}
let tx = Transaction::loader_finalize(
let tx = LoaderTransaction::new_finalize(
&program,
loader.loader,
loader.genesis_block.last_id(),
@ -181,7 +181,7 @@ impl Program {
loader.bank.process_transactions(&vec![tx.clone()]),
);
let tx = Transaction::system_spawn(&program, loader.genesis_block.last_id(), 0);
let tx = SystemTransaction::new_spawn(&program, loader.genesis_block.last_id(), 0);
check_tx_results(
&loader.bank,
&tx,
@ -236,7 +236,7 @@ fn test_program_lua_move_funds() {
// Call user program with two accounts
let tx = Transaction::system_create(
let tx = SystemTransaction::new_program_account(
&loader.mint_keypair,
from.pubkey(),
loader.genesis_block.last_id(),
@ -251,7 +251,7 @@ fn test_program_lua_move_funds() {
loader.bank.process_transactions(&vec![tx.clone()]),
);
let tx = Transaction::system_create(
let tx = SystemTransaction::new_program_account(
&loader.mint_keypair,
to,
loader.genesis_block.last_id(),

View File

@ -20,7 +20,6 @@ use solana::voting_keypair::VotingKeypair;
use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::transaction::Transaction;
use std::fs::remove_dir_all;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::channel;
@ -110,8 +109,13 @@ fn test_replicator_startup() {
let last_id = leader_client.get_last_id();
// Give the replicator some tokens
let amount = 1;
let mut tx =
Transaction::system_new(&mint_keypair, replicator_keypair.pubkey(), amount, last_id);
let mut tx = SystemTransaction::new_account(
&mint_keypair,
replicator_keypair.pubkey(),
amount,
last_id,
0,
);
leader_client
.retry_transfer(&mint_keypair, &mut tx, 5)
.unwrap();

View File

@ -8,7 +8,6 @@ use solana::thin_client::new_fullnode;
use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::transaction::Transaction;
use std::fs::remove_dir_all;
use std::thread::sleep;
use std::time::Duration;
@ -42,7 +41,7 @@ fn test_rpc_send_tx() {
let last_id = Hash::new(&last_id_vec);
info!("last_id: {:?}", last_id);
let tx = Transaction::system_move(&alice, bob_pubkey, 20, last_id, 0);
let tx = SystemTransaction::new_move(&alice, bob_pubkey, 20, last_id, 0);
let serial_tx = serialize(&tx).unwrap();
let client = reqwest::Client::new();