Skip to content

Commit

Permalink
final updates for tag and build based on grin 1.1.0 merge
Browse files Browse the repository at this point in the history
  • Loading branch information
yeastplume committed Apr 3, 2019
1 parent 0e9ccef commit 9b49bde
Show file tree
Hide file tree
Showing 7 changed files with 228 additions and 198 deletions.
366 changes: 184 additions & 182 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions controller/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ uuid = { version = "0.7", features = ["serde", "v4"] }
url = "1.7.0"
chrono = { version = "0.4.4", features = ["serde"] }
easy-jsonrpc = "0.4.1"
lazy_static = "1"

grin_wallet_util = { path = "../util", version = "1.1.0" }

Expand Down
12 changes: 10 additions & 2 deletions controller/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use crate::util::Mutex;
use failure::ResultExt;
use futures::future::{err, ok};
use futures::{Future, Stream};
use hyper::header::HeaderValue;
use hyper::{Body, Request, Response, StatusCode};
use serde::{Deserialize, Serialize};
use serde_json;
Expand All @@ -45,6 +46,11 @@ use crate::apiwallet::{Foreign, ForeignRpc, Owner, OwnerRpc};
use easy_jsonrpc;
use easy_jsonrpc::Handler;

lazy_static! {
pub static ref GRIN_OWNER_BASIC_REALM: HeaderValue =
HeaderValue::from_str("Basic realm=GrinOwnerAPI").unwrap();
}

/// Instantiate wallet Owner API for a single-use (command line) call
/// Return a function containing a loaded API context to call
pub fn owner_single_use<F, T: ?Sized, C, K>(wallet: Arc<Mutex<T>>, f: F) -> Result<(), Error>
Expand Down Expand Up @@ -93,8 +99,10 @@ where
if api_secret.is_some() {
let api_basic_auth =
"Basic ".to_string() + &to_base64(&("grin:".to_string() + &api_secret.unwrap()));
let basic_realm = "Basic realm=GrinOwnerAPI".to_string();
let basic_auth_middleware = Arc::new(BasicAuthMiddleware::new(api_basic_auth, basic_realm));
let basic_auth_middleware = Arc::new(BasicAuthMiddleware::new(
api_basic_auth,
&GRIN_OWNER_BASIC_REALM,
));
router.add_middleware(basic_auth_middleware);
}

Expand Down
2 changes: 2 additions & 0 deletions controller/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ extern crate prettytable;

#[macro_use]
extern crate log;
#[macro_use]
extern crate lazy_static;
use failure;
use grin_wallet_api as apiwallet;
use grin_wallet_config as config;
Expand Down
20 changes: 14 additions & 6 deletions impls/src/lmdb_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ where
}

fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = OutputData> + 'a> {
Box::new(self.db.iter(&[OUTPUT_PREFIX]).unwrap())
Box::new(self.db.iter(&[OUTPUT_PREFIX]).unwrap().map(|o| o.1))
}

fn get_tx_log_entry(&self, u: &Uuid) -> Result<Option<TxLogEntry>, Error> {
Expand All @@ -245,7 +245,7 @@ where
}

fn tx_log_iter<'a>(&'a self) -> Box<dyn Iterator<Item = TxLogEntry> + 'a> {
Box::new(self.db.iter(&[TX_LOG_ENTRY_PREFIX]).unwrap())
Box::new(self.db.iter(&[TX_LOG_ENTRY_PREFIX]).unwrap().map(|o| o.1))
}

fn get_private_context(&mut self, slate_id: &[u8]) -> Result<Context, Error> {
Expand All @@ -266,7 +266,12 @@ where
}

fn acct_path_iter<'a>(&'a self) -> Box<dyn Iterator<Item = AcctPathMapping> + 'a> {
Box::new(self.db.iter(&[ACCOUNT_PATH_MAPPING_PREFIX]).unwrap())
Box::new(
self.db
.iter(&[ACCOUNT_PATH_MAPPING_PREFIX])
.unwrap()
.map(|o| o.1),
)
}

fn get_acct_path(&self, label: String) -> Result<Option<AcctPathMapping>, Error> {
Expand Down Expand Up @@ -412,7 +417,8 @@ where
.as_ref()
.unwrap()
.iter(&[OUTPUT_PREFIX])
.unwrap(),
.unwrap()
.map(|o| o.1),
)
}

Expand Down Expand Up @@ -450,7 +456,8 @@ where
.as_ref()
.unwrap()
.iter(&[TX_LOG_ENTRY_PREFIX])
.unwrap(),
.unwrap()
.map(|o| o.1),
)
}

Expand Down Expand Up @@ -519,7 +526,8 @@ where
.as_ref()
.unwrap()
.iter(&[ACCOUNT_PATH_MAPPING_PREFIX])
.unwrap(),
.unwrap()
.map(|o| o.1),
)
}

Expand Down
4 changes: 2 additions & 2 deletions impls/src/test_framework/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ fn get_outputs_by_pmmr_index_local(
outputs: outputs
.2
.iter()
.map(|x| api::OutputPrintable::from_output(x, chain.clone(), None, true))
.map(|x| api::OutputPrintable::from_output(x, chain.clone(), None, true).unwrap())
.collect(),
}
}

/// Adds a block with a given reward to the chain and mines it
pub fn add_block_with_reward(chain: &Chain, txs: Vec<&Transaction>, reward: CbData) {
let prev = chain.head_header().unwrap();
let next_header_info = consensus::next_difficulty(1, chain.difficulty_iter());
let next_header_info = consensus::next_difficulty(1, chain.difficulty_iter().unwrap());
let mut b = core::core::Block::new(
&prev,
txs.into_iter().cloned().collect(),
Expand Down
21 changes: 15 additions & 6 deletions util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@ serde_derive = "1"
toml = "0.4"
dirs = "1.0.3"

grin_core = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
grin_chain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
grin_util = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
grin_api = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
grin_store = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
# For Release
grin_core = "1.1.0-beta.1"
grin_keychain = "1.1.0-beta.1"
grin_chain = "1.1.0-beta.1"
grin_util = "1.1.0-beta.1"
grin_api = "1.1.0-beta.1"
grin_store = "1.1.0-beta.1"

# For bleeding edge
#grin_core = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
#grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
#grin_chain = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
#grin_util = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
#grin_api = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }
#grin_store = { git = "https://github.com/mimblewimble/grin", branch = "milestone/1.1.0" }

# For local testing
#grin_core = { path = "../../grin/core", version= "1.1.0"}
Expand Down

0 comments on commit 9b49bde

Please sign in to comment.