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:
committed by
GitHub
parent
a5f07638ec
commit
e7de7c32db
@@ -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());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user