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:
Greg Fitzgerald 2018-05-31 13:41:42 -06:00
parent 391744af97
commit c9fd5d74b5
5 changed files with 7 additions and 16 deletions

View File

@ -63,6 +63,5 @@ byteorder = "^1.2.1"
libc = "^0.2.1"
getopts = "^0.2"
isatty = "0.1"
futures = "0.1"
rand = "0.4.2"
pnet = "^0.21.0"

View File

@ -1,4 +1,3 @@
extern crate futures;
extern crate getopts;
extern crate isatty;
extern crate pnet;
@ -6,7 +5,6 @@ extern crate rayon;
extern crate serde_json;
extern crate solana;
use futures::Future;
use getopts::Options;
use isatty::stdin_isatty;
use pnet::datalink;
@ -128,7 +126,7 @@ fn main() {
let mut client = mk_client(&client_addr, &leader);
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);
let rnd = GenKeys::new(demo.mint.keypair().public_key_bytes());

View File

@ -50,8 +50,6 @@ extern crate serde_json;
extern crate sha2;
extern crate untrusted;
extern crate futures;
#[cfg(test)]
#[macro_use]
extern crate matches;

View File

@ -4,7 +4,6 @@
//! unstable and may change in future releases.
use bincode::{deserialize, serialize};
use futures::future::{ok, FutureResult};
use hash::Hash;
use request::{Request, Response};
use signature::{KeyPair, PublicKey, Signature};
@ -138,7 +137,7 @@ impl ThinClient {
/// Request the last Entry ID from the server. This method blocks
/// 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");
let req = Request::GetLastId;
let data = serialize(&req).expect("serialize GetLastId in pub fn get_last_id");
@ -153,7 +152,7 @@ impl ThinClient {
}
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> {
@ -178,7 +177,6 @@ mod tests {
use bank::Bank;
use budget::Budget;
use crdt::TestNode;
use futures::Future;
use logger;
use mint::Mint;
use server::Server;
@ -223,7 +221,7 @@ mod tests {
leader.data.transactions_addr,
transactions_socket,
);
let last_id = client.get_last_id().wait().unwrap();
let last_id = client.get_last_id();
let _sig = client
.transfer(500, &alice.keypair(), bob_pubkey, &last_id)
.unwrap();
@ -269,13 +267,13 @@ mod tests {
leader.data.transactions_addr,
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 _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);
if let Instruction::NewContract(contract) = &mut tr2.instruction {

View File

@ -1,10 +1,8 @@
#[macro_use]
extern crate log;
extern crate bincode;
extern crate futures;
extern crate solana;
use futures::Future;
use solana::bank::Bank;
use solana::crdt::TestNode;
use solana::crdt::{Crdt, ReplicatedData};
@ -167,7 +165,7 @@ fn tx_and_retry_get_balance(
) -> io::Result<i64> {
let mut client = mk_client(leader);
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");
let _sig = client
.transfer(500, &alice.keypair(), *bob_pubkey, &last_id)