Wallet output selection performance (#238)
* allow selecting a commit while providing a key index * added static reference to libsecp that can be called throughout * don't serialise rangeproof to json if it's not desired
This commit is contained in:
committed by
Ignotus Peverell
parent
8f0373b81e
commit
48a60858ba
+17
-7
@@ -58,7 +58,7 @@ impl UtxoHandler {
|
||||
.get_block_header_by_output_commit(&commit)
|
||||
.map_err(|_| Error::NotFound)?;
|
||||
|
||||
Ok(Output::from_output(&out, &header))
|
||||
Ok(Output::from_output(&out, &header, false))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,10 +138,10 @@ impl Handler for SumTreeHandler {
|
||||
}
|
||||
}
|
||||
match *path_elems.last().unwrap() {
|
||||
"roots" => json_response(&self.get_roots()),
|
||||
"lastutxos" => json_response(&self.get_last_n_utxo(last_n)),
|
||||
"lastrangeproofs" => json_response(&self.get_last_n_rangeproof(last_n)),
|
||||
"lastkernels" => json_response(&self.get_last_n_kernel(last_n)),
|
||||
"roots" => json_response_pretty(&self.get_roots()),
|
||||
"lastutxos" => json_response_pretty(&self.get_last_n_utxo(last_n)),
|
||||
"lastrangeproofs" => json_response_pretty(&self.get_last_n_rangeproof(last_n)),
|
||||
"lastkernels" => json_response_pretty(&self.get_last_n_kernel(last_n)),
|
||||
_ => Ok(Response::with((status::BadRequest, ""))),
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,7 @@ pub struct PeersAllHandler {
|
||||
impl Handler for PeersAllHandler {
|
||||
fn handle(&self, _req: &mut Request) -> IronResult<Response> {
|
||||
let peers = &self.peer_store.all_peers();
|
||||
json_response(&peers)
|
||||
json_response_pretty(&peers)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,12 +266,22 @@ fn json_response<T>(s: &T) -> IronResult<Response>
|
||||
where
|
||||
T: Serialize,
|
||||
{
|
||||
match serde_json::to_string_pretty(s) {
|
||||
match serde_json::to_string(s) {
|
||||
Ok(json) => Ok(Response::with((status::Ok, json))),
|
||||
Err(_) => Ok(Response::with((status::InternalServerError, ""))),
|
||||
}
|
||||
}
|
||||
|
||||
// pretty-printed version of above
|
||||
fn json_response_pretty<T>(s: &T) -> IronResult<Response>
|
||||
where
|
||||
T: Serialize,
|
||||
{
|
||||
match serde_json::to_string_pretty(s) {
|
||||
Ok(json) => Ok(Response::with((status::Ok, json))),
|
||||
Err(_) => Ok(Response::with((status::InternalServerError, ""))),
|
||||
}
|
||||
}
|
||||
/// Start all server HTTP handlers. Register all of them with Iron
|
||||
/// and runs the corresponding HTTP server.
|
||||
pub fn start_rest_apis<T>(
|
||||
|
||||
+6
-3
@@ -138,7 +138,7 @@ pub struct Output {
|
||||
/// The homomorphic commitment representing the output's amount
|
||||
pub commit: pedersen::Commitment,
|
||||
/// A proof that the commitment is in the right range
|
||||
pub proof: pedersen::RangeProof,
|
||||
pub proof: Option<pedersen::RangeProof>,
|
||||
/// The height of the block creating this output
|
||||
pub height: u64,
|
||||
/// The lock height (earliest block this output can be spent)
|
||||
@@ -146,7 +146,7 @@ pub struct Output {
|
||||
}
|
||||
|
||||
impl Output {
|
||||
pub fn from_output(output: &core::Output, block_header: &core::BlockHeader) -> Output {
|
||||
pub fn from_output(output: &core::Output, block_header: &core::BlockHeader, include_proof:bool) -> Output {
|
||||
let (output_type, lock_height) = match output.features {
|
||||
x if x.contains(core::transaction::COINBASE_OUTPUT) => (
|
||||
OutputType::Coinbase,
|
||||
@@ -158,7 +158,10 @@ impl Output {
|
||||
Output {
|
||||
output_type: output_type,
|
||||
commit: output.commit,
|
||||
proof: output.proof,
|
||||
proof: match include_proof {
|
||||
true => Some(output.proof),
|
||||
false => None,
|
||||
},
|
||||
height: block_header.height,
|
||||
lock_height: lock_height,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user