Boot futures 0.1
We added them thinking it'd be a good stepping stone towards an asynchronous thin client, but it's used inconsistently and where it used, the function is still synchronous, which is just confusing.
This commit is contained in:
parent
391744af97
commit
c9fd5d74b5
|
@ -63,6 +63,5 @@ byteorder = "^1.2.1"
|
||||||
libc = "^0.2.1"
|
libc = "^0.2.1"
|
||||||
getopts = "^0.2"
|
getopts = "^0.2"
|
||||||
isatty = "0.1"
|
isatty = "0.1"
|
||||||
futures = "0.1"
|
|
||||||
rand = "0.4.2"
|
rand = "0.4.2"
|
||||||
pnet = "^0.21.0"
|
pnet = "^0.21.0"
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
extern crate futures;
|
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
extern crate isatty;
|
extern crate isatty;
|
||||||
extern crate pnet;
|
extern crate pnet;
|
||||||
|
@ -6,7 +5,6 @@ extern crate rayon;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
extern crate solana;
|
extern crate solana;
|
||||||
|
|
||||||
use futures::Future;
|
|
||||||
use getopts::Options;
|
use getopts::Options;
|
||||||
use isatty::stdin_isatty;
|
use isatty::stdin_isatty;
|
||||||
use pnet::datalink;
|
use pnet::datalink;
|
||||||
|
@ -128,7 +126,7 @@ fn main() {
|
||||||
let mut client = mk_client(&client_addr, &leader);
|
let mut client = mk_client(&client_addr, &leader);
|
||||||
|
|
||||||
println!("Get last ID...");
|
println!("Get last ID...");
|
||||||
let last_id = client.get_last_id().wait().unwrap();
|
let last_id = client.get_last_id();
|
||||||
println!("Got last ID {:?}", last_id);
|
println!("Got last ID {:?}", last_id);
|
||||||
|
|
||||||
let rnd = GenKeys::new(demo.mint.keypair().public_key_bytes());
|
let rnd = GenKeys::new(demo.mint.keypair().public_key_bytes());
|
||||||
|
|
|
@ -50,8 +50,6 @@ extern crate serde_json;
|
||||||
extern crate sha2;
|
extern crate sha2;
|
||||||
extern crate untrusted;
|
extern crate untrusted;
|
||||||
|
|
||||||
extern crate futures;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate matches;
|
extern crate matches;
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
//! unstable and may change in future releases.
|
//! unstable and may change in future releases.
|
||||||
|
|
||||||
use bincode::{deserialize, serialize};
|
use bincode::{deserialize, serialize};
|
||||||
use futures::future::{ok, FutureResult};
|
|
||||||
use hash::Hash;
|
use hash::Hash;
|
||||||
use request::{Request, Response};
|
use request::{Request, Response};
|
||||||
use signature::{KeyPair, PublicKey, Signature};
|
use signature::{KeyPair, PublicKey, Signature};
|
||||||
|
@ -138,7 +137,7 @@ impl ThinClient {
|
||||||
|
|
||||||
/// Request the last Entry ID from the server. This method blocks
|
/// Request the last Entry ID from the server. This method blocks
|
||||||
/// until the server sends a response.
|
/// until the server sends a response.
|
||||||
pub fn get_last_id(&mut self) -> FutureResult<Hash, ()> {
|
pub fn get_last_id(&mut self) -> Hash {
|
||||||
info!("get_last_id");
|
info!("get_last_id");
|
||||||
let req = Request::GetLastId;
|
let req = Request::GetLastId;
|
||||||
let data = serialize(&req).expect("serialize GetLastId in pub fn get_last_id");
|
let data = serialize(&req).expect("serialize GetLastId in pub fn get_last_id");
|
||||||
|
@ -153,7 +152,7 @@ impl ThinClient {
|
||||||
}
|
}
|
||||||
self.process_response(resp);
|
self.process_response(resp);
|
||||||
}
|
}
|
||||||
ok(self.last_id.expect("some last_id"))
|
self.last_id.expect("some last_id")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn poll_get_balance(&mut self, pubkey: &PublicKey) -> io::Result<i64> {
|
pub fn poll_get_balance(&mut self, pubkey: &PublicKey) -> io::Result<i64> {
|
||||||
|
@ -178,7 +177,6 @@ mod tests {
|
||||||
use bank::Bank;
|
use bank::Bank;
|
||||||
use budget::Budget;
|
use budget::Budget;
|
||||||
use crdt::TestNode;
|
use crdt::TestNode;
|
||||||
use futures::Future;
|
|
||||||
use logger;
|
use logger;
|
||||||
use mint::Mint;
|
use mint::Mint;
|
||||||
use server::Server;
|
use server::Server;
|
||||||
|
@ -223,7 +221,7 @@ mod tests {
|
||||||
leader.data.transactions_addr,
|
leader.data.transactions_addr,
|
||||||
transactions_socket,
|
transactions_socket,
|
||||||
);
|
);
|
||||||
let last_id = client.get_last_id().wait().unwrap();
|
let last_id = client.get_last_id();
|
||||||
let _sig = client
|
let _sig = client
|
||||||
.transfer(500, &alice.keypair(), bob_pubkey, &last_id)
|
.transfer(500, &alice.keypair(), bob_pubkey, &last_id)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -269,13 +267,13 @@ mod tests {
|
||||||
leader.data.transactions_addr,
|
leader.data.transactions_addr,
|
||||||
transactions_socket,
|
transactions_socket,
|
||||||
);
|
);
|
||||||
let last_id = client.get_last_id().wait().unwrap();
|
let last_id = client.get_last_id();
|
||||||
|
|
||||||
let tx = Transaction::new(&alice.keypair(), bob_pubkey, 500, last_id);
|
let tx = Transaction::new(&alice.keypair(), bob_pubkey, 500, last_id);
|
||||||
|
|
||||||
let _sig = client.transfer_signed(tx).unwrap();
|
let _sig = client.transfer_signed(tx).unwrap();
|
||||||
|
|
||||||
let last_id = client.get_last_id().wait().unwrap();
|
let last_id = client.get_last_id();
|
||||||
|
|
||||||
let mut tr2 = Transaction::new(&alice.keypair(), bob_pubkey, 501, last_id);
|
let mut tr2 = Transaction::new(&alice.keypair(), bob_pubkey, 501, last_id);
|
||||||
if let Instruction::NewContract(contract) = &mut tr2.instruction {
|
if let Instruction::NewContract(contract) = &mut tr2.instruction {
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
extern crate bincode;
|
extern crate bincode;
|
||||||
extern crate futures;
|
|
||||||
extern crate solana;
|
extern crate solana;
|
||||||
|
|
||||||
use futures::Future;
|
|
||||||
use solana::bank::Bank;
|
use solana::bank::Bank;
|
||||||
use solana::crdt::TestNode;
|
use solana::crdt::TestNode;
|
||||||
use solana::crdt::{Crdt, ReplicatedData};
|
use solana::crdt::{Crdt, ReplicatedData};
|
||||||
|
@ -167,7 +165,7 @@ fn tx_and_retry_get_balance(
|
||||||
) -> io::Result<i64> {
|
) -> io::Result<i64> {
|
||||||
let mut client = mk_client(leader);
|
let mut client = mk_client(leader);
|
||||||
trace!("getting leader last_id");
|
trace!("getting leader last_id");
|
||||||
let last_id = client.get_last_id().wait().unwrap();
|
let last_id = client.get_last_id();
|
||||||
info!("executing leader transer");
|
info!("executing leader transer");
|
||||||
let _sig = client
|
let _sig = client
|
||||||
.transfer(500, &alice.keypair(), *bob_pubkey, &last_id)
|
.transfer(500, &alice.keypair(), *bob_pubkey, &last_id)
|
||||||
|
|
Loading…
Reference in New Issue