Transactions with multiple programs. (#1381)

Transactions contain a vector of instructions that are executed atomically.
Bench shows a 2.3x speed up when using 5 instructions per tx.
This commit is contained in:
anatoly yakovenko
2018-09-28 16:16:35 -07:00
committed by GitHub
parent a5f07638ec
commit e7de7c32db
14 changed files with 668 additions and 249 deletions

View File

@@ -33,9 +33,10 @@ impl StorageProgram {
pub fn process_transaction(
tx: &Transaction,
_accounts: &mut [Account],
pix: usize,
_accounts: &mut [&mut Account],
) -> Result<(), StorageError> {
if let Ok(syscall) = deserialize(&tx.userdata) {
if let Ok(syscall) = deserialize(tx.userdata(pix)) {
match syscall {
StorageProgram::SubmitMiningProof { sha_state } => {
info!("Mining proof submitted with state {}", sha_state[0]);
@@ -49,4 +50,22 @@ impl StorageProgram {
}
#[cfg(test)]
mod test {}
mod test {
use super::*;
use signature::Keypair;
use signature::KeypairUtil;
#[test]
fn test_storage_tx() {
let keypair = Keypair::new();
let tx = Transaction::new(
&keypair,
&[],
StorageProgram::id(),
vec![],
Default::default(),
0,
);
assert!(StorageProgram::process_transaction(&tx, 0, &mut []).is_err());
}
}