mirror of
https://github.com/romanz/electrs.git
synced 2025-02-24 23:08:39 +01:00
Fix vec![] usage
This commit is contained in:
parent
1786fa69ed
commit
421e1877bb
6 changed files with 14 additions and 14 deletions
|
@ -127,7 +127,7 @@ impl Daemon {
|
|||
.iter()
|
||||
.map(|params| json!({"method": method, "params": params}))
|
||||
.collect();
|
||||
let mut result = Vec::new();
|
||||
let mut result = vec![];
|
||||
for reply in self.call_jsonrpc(&reqs)
|
||||
.chain_err(|| format!("RPC failed: {}", reqs))?
|
||||
.as_array_mut()
|
||||
|
@ -164,7 +164,7 @@ impl Daemon {
|
|||
Ok(deserialize(&header_bytes)
|
||||
.chain_err(|| format!("failed to parse blockheader {}", header_hex))?)
|
||||
}
|
||||
let mut result = Vec::new();
|
||||
let mut result = vec![];
|
||||
for h in headers {
|
||||
result.push(header_from_value(h)?);
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ impl Daemon {
|
|||
|
||||
pub fn getmempooltxids(&self) -> Result<Vec<Sha256dHash>> {
|
||||
let txids: Value = self.request("getrawmempool", json!([/*verbose=*/ false]))?;
|
||||
let mut result = Vec::new();
|
||||
let mut result = vec![];
|
||||
for value in txids.as_array().chain_err(|| "non-array result")? {
|
||||
result.push(parse_hash(&value).chain_err(|| "invalid txid")?);
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ pub fn index_transaction(txn: &Transaction, height: usize, rows: &mut Vec<Row>)
|
|||
}
|
||||
|
||||
fn index_block(block: &Block, height: usize) -> Vec<Row> {
|
||||
let mut rows = Vec::new();
|
||||
let mut rows = vec![];
|
||||
for txn in &block.txdata {
|
||||
index_transaction(&txn, height, &mut rows);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ impl ReadStore for MempoolStore {
|
|||
fn scan(&self, prefix: &[u8]) -> Vec<Row> {
|
||||
let map = self.map.read().unwrap();
|
||||
let range = map.range((Bound::Included(prefix.to_vec()), Bound::Unbounded));
|
||||
let mut rows = Vec::new();
|
||||
let mut rows = vec![];
|
||||
for (key, value) in range {
|
||||
if !key.starts_with(prefix) {
|
||||
break;
|
||||
|
@ -133,7 +133,7 @@ impl Tracker {
|
|||
}
|
||||
|
||||
fn update_tx_index(&mut self) {
|
||||
let mut rows = Vec::new();
|
||||
let mut rows = vec![];
|
||||
for stats in self.stats.values() {
|
||||
index_transaction(&stats.tx, 0, &mut rows)
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ impl Tracker {
|
|||
entries.sort_unstable_by(|e1, e2| {
|
||||
e2.fee_per_vbyte().partial_cmp(&e1.fee_per_vbyte()).unwrap()
|
||||
});
|
||||
let mut histogram = Vec::new();
|
||||
let mut histogram = vec![];
|
||||
let mut bin_size = 0;
|
||||
let mut last_fee_rate = None;
|
||||
for e in entries {
|
||||
|
|
10
src/query.rs
10
src/query.rs
|
@ -139,7 +139,7 @@ impl Query {
|
|||
}
|
||||
|
||||
fn load_txns(&self, store: &ReadStore, prefixes: Vec<HashPrefix>) -> Result<Vec<TxnHeight>> {
|
||||
let mut txns = Vec::new();
|
||||
let mut txns = vec![];
|
||||
for txid_prefix in prefixes {
|
||||
for tx_row in txrows_by_prefix(store, &txid_prefix) {
|
||||
let txid: Sha256dHash = deserialize(&tx_row.key.txid).unwrap();
|
||||
|
@ -162,7 +162,7 @@ impl Query {
|
|||
store,
|
||||
txids_by_funding_output(store, &funding.txn_id, funding.output_index),
|
||||
)?;
|
||||
let mut spending_inputs = Vec::new();
|
||||
let mut spending_inputs = vec![];
|
||||
for t in &spending_txns {
|
||||
for input in t.txn.input.iter() {
|
||||
if input.prev_hash == funding.txn_id
|
||||
|
@ -185,7 +185,7 @@ impl Query {
|
|||
}
|
||||
|
||||
fn find_funding_outputs(&self, t: &TxnHeight, script_hash: &[u8]) -> Vec<FundingOutput> {
|
||||
let mut result = Vec::new();
|
||||
let mut result = vec![];
|
||||
let txn_id = t.txn.txid();
|
||||
for (index, output) in t.txn.output.iter().enumerate() {
|
||||
if compute_script_hash(&output.script_pubkey[..]) == script_hash {
|
||||
|
@ -256,7 +256,7 @@ impl Query {
|
|||
pub fn get_headers(&self, heights: &[usize]) -> Vec<BlockHeader> {
|
||||
let headers_list = self.app.index().headers_list();
|
||||
let headers = headers_list.headers();
|
||||
let mut result = Vec::new();
|
||||
let mut result = vec![];
|
||||
for height in heights {
|
||||
let header: &BlockHeader = match headers.get(*height) {
|
||||
Some(header) => header.header(),
|
||||
|
@ -290,7 +290,7 @@ impl Query {
|
|||
.iter()
|
||||
.position(|txid| txid == tx_hash)
|
||||
.chain_err(|| format!("missing txid {}", tx_hash))?;
|
||||
let mut merkle = Vec::new();
|
||||
let mut merkle = vec![];
|
||||
let mut index = pos;
|
||||
while txids.len() > 1 {
|
||||
if txids.len() % 2 != 0 {
|
||||
|
|
|
@ -99,7 +99,7 @@ impl Connection {
|
|||
fn blockchain_block_get_header(&self, params: &[Value]) -> Result<Value> {
|
||||
let height = params.get(0).chain_err(|| "missing height")?;
|
||||
let height = height.as_u64().chain_err(|| "non-number height")? as usize;
|
||||
let headers = self.query.get_headers(&vec![height]);
|
||||
let headers = self.query.get_headers(&[height]);
|
||||
Ok(json!(jsonify_header(&headers[0], height)))
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ impl ReadStore for DBStore {
|
|||
|
||||
// TODO: use generators
|
||||
fn scan(&self, prefix: &[u8]) -> Vec<Row> {
|
||||
let mut rows = Vec::new();
|
||||
let mut rows = vec![];
|
||||
let mut iter = self.db.raw_iterator();
|
||||
iter.seek(prefix);
|
||||
while iter.valid() {
|
||||
|
|
Loading…
Add table
Reference in a new issue