Transactions now require a hash of the last entry they've seen

This ensures the transaction cannot be processed on a chain
that forked before that ID. It will also provide a basis for
expiration constraints. A client may want their transaction
to expire, and the generators may want to reject transactions
that have been floating in the ether for years.
This commit is contained in:
Greg Fitzgerald
2018-03-05 12:48:09 -07:00
parent d76ecbc9c9
commit 48c28c2267
10 changed files with 165 additions and 54 deletions

View File

@@ -29,6 +29,7 @@ fn main() {
let socket = UdpSocket::bind(send_addr).unwrap();
let mut acc = AccountantStub::new(addr, socket);
let last_id = acc.get_last_id().unwrap();
let alice_pubkey = get_pubkey(&alice_keypair);
let one = 1;
println!("Signing transactions...");
@@ -37,7 +38,7 @@ fn main() {
.map(|_| {
let rando_keypair = generate_keypair();
let rando_pubkey = get_pubkey(&rando_keypair);
let sig = sign_transaction_data(&one, &alice_keypair, &rando_pubkey);
let sig = sign_transaction_data(&one, &alice_keypair, &rando_pubkey, &last_id);
(rando_pubkey, sig)
})
.collect();
@@ -58,6 +59,7 @@ fn main() {
from: alice_pubkey,
to: k,
data: one,
last_id,
sig: s,
};
assert!(verify_event(&e));
@@ -76,7 +78,8 @@ fn main() {
let now = Instant::now();
let mut sig = Default::default();
for (k, s) in sigs {
acc.transfer_signed(alice_pubkey, k, one, s).unwrap();
acc.transfer_signed(alice_pubkey, k, one, last_id, s)
.unwrap();
sig = s;
}
println!("Waiting for last transaction to be confirmed...",);