Unverified Commit 582af3d6 authored by Roman Zeyde's avatar Roman Zeyde
Browse files

Update rust-bitcoin to 0.15.1 and re-generate Cargo.lock

parent edc2532f
This diff is collapsed.
......@@ -14,7 +14,7 @@ readme = "README.md"
arrayref = "0.3"
base64 = "0.9"
bincode = "1.0"
bitcoin = "0.14"
bitcoin = "0.15"
chan = "0.1"
chan-signal = "0.3"
clap = "2.31"
......
extern crate electrs;
#[macro_use]
extern crate log;
use electrs::config::Config;
use electrs::notify;
fn main() {
let _ = Config::from_args();
let rx = notify::run().into_receiver();
for blockhash in rx.iter() {
info!("block {}", blockhash.be_hex_string())
}
}
use bitcoin::blockdata::block::Block;
use bitcoin::network::serialize::BitcoinHash;
use bitcoin::network::serialize::SimpleDecoder;
use bitcoin::network::serialize::{deserialize, RawDecoder};
use bitcoin::util::hash::Sha256dHash;
use bitcoin::consensus::encode::{deserialize, Decodable};
use bitcoin::util::hash::{BitcoinHash, Sha256dHash};
use libc;
use std::collections::HashSet;
use std::fs;
......@@ -118,11 +116,9 @@ fn parse_blocks(blob: Vec<u8>, magic: u32) -> Result<Vec<Block>> {
let mut blocks = vec![];
let max_pos = blob.len() as u64;
while cursor.position() < max_pos {
let mut decoder = RawDecoder::new(cursor);
match decoder.read_u32() {
match u32::consensus_decode(&mut cursor) {
Ok(value) => {
if magic != value {
cursor = decoder.into_inner();
cursor
.seek(SeekFrom::Current(-3))
.expect("failed to seek back");
......@@ -131,9 +127,7 @@ fn parse_blocks(blob: Vec<u8>, magic: u32) -> Result<Vec<Block>> {
}
Err(_) => break, // EOF
};
let block_size = decoder.read_u32().chain_err(|| "no block size")?;
cursor = decoder.into_inner();
let block_size = u32::consensus_decode(&mut cursor).chain_err(|| "no block size")?;
let start = cursor.position() as usize;
cursor
.seek(SeekFrom::Current(block_size as i64))
......
use base64;
use bitcoin::blockdata::block::{Block, BlockHeader};
use bitcoin::blockdata::transaction::Transaction;
use bitcoin::consensus::encode::{deserialize, serialize};
use bitcoin::network::constants::Network;
use bitcoin::network::serialize::BitcoinHash;
use bitcoin::network::serialize::{deserialize, serialize};
use bitcoin::util::hash::BitcoinHash;
use bitcoin::util::hash::Sha256dHash;
use glob;
use hex;
......@@ -557,7 +557,7 @@ impl Daemon {
}
pub fn broadcast(&self, tx: &Transaction) -> Result<Sha256dHash> {
let tx = hex::encode(serialize(tx).unwrap());
let tx = hex::encode(serialize(tx));
let txid = self.request("sendrawtransaction", json!([tx]))?;
Ok(
Sha256dHash::from_hex(txid.as_str().chain_err(|| "non-string txid")?)
......
use bincode;
use bitcoin::blockdata::block::{Block, BlockHeader};
use bitcoin::blockdata::transaction::{Transaction, TxIn, TxOut};
use bitcoin::network::serialize::BitcoinHash;
use bitcoin::network::serialize::{deserialize, serialize};
use bitcoin::consensus::encode::{deserialize, serialize};
use bitcoin::util::hash::BitcoinHash;
use bitcoin::util::hash::Sha256dHash;
use crypto::digest::Digest;
use crypto::sha2::Sha256;
......@@ -195,7 +195,7 @@ pub fn index_block(block: &Block, height: usize) -> Vec<Row> {
code: b'B',
hash: full_hash(&blockhash[..]),
}).unwrap(),
value: serialize(&block.header).unwrap(),
value: serialize(&block.header),
});
rows
}
......@@ -204,7 +204,7 @@ pub fn last_indexed_block(blockhash: &Sha256dHash) -> Row {
// Store last indexed block (i.e. all previous blocks were indexed)
Row {
key: b"L".to_vec(),
value: serialize(blockhash).unwrap(),
value: serialize(blockhash),
}
}
......
......@@ -44,7 +44,6 @@ pub mod fake;
pub mod index;
pub mod mempool;
pub mod metrics;
pub mod notify;
pub mod query;
pub mod rpc;
pub mod signal;
......
// TODO: network::socket::Socket needs to be reimplemented.
use bitcoin::network::constants::Network;
use bitcoin::network::message::NetworkMessage;
use bitcoin::network::message_blockdata::InvType;
......
use bitcoin::blockdata::block::Block;
use bitcoin::blockdata::transaction::Transaction;
use bitcoin::network::serialize::deserialize;
use bitcoin::consensus::encode::deserialize;
use bitcoin::util::hash::Sha256dHash;
use crypto::digest::Digest;
use crypto::sha2::Sha256;
......
use bitcoin::blockdata::transaction::Transaction;
use bitcoin::network::serialize::{deserialize, serialize};
use bitcoin::consensus::encode::{deserialize, serialize};
use bitcoin::util::address::Address;
use bitcoin::util::hash::Sha256dHash;
use error_chain::ChainedError;
......@@ -99,7 +99,7 @@ impl Connection {
fn blockchain_headers_subscribe(&mut self) -> Result<Value> {
let entry = self.query.get_best_header()?;
let hex_header = hex::encode(serialize(entry.header()).unwrap());
let hex_header = hex::encode(serialize(entry.header()));
let result = json!({"hex": hex_header, "height": entry.height()});
self.last_header_entry = Some(entry);
Ok(result)
......@@ -133,7 +133,7 @@ impl Connection {
.query
.get_headers(&heights)
.into_iter()
.map(|entry| hex::encode(&serialize(entry.header()).unwrap()))
.map(|entry| hex::encode(&serialize(entry.header())))
.collect();
Ok(json!({
"count": headers.len(),
......@@ -330,7 +330,7 @@ impl Connection {
let entry = self.query.get_best_header()?;
if *last_entry != entry {
*last_entry = entry;
let hex_header = hex::encode(serialize(last_entry.header()).unwrap());
let hex_header = hex::encode(serialize(last_entry.header()));
let header = json!({"hex": hex_header, "height": last_entry.height()});
result.push(json!({
"jsonrpc": "2.0",
......
use bitcoin::blockdata::block::BlockHeader;
use bitcoin::network::serialize::BitcoinHash;
use bitcoin::util::hash::Sha256dHash;
use bitcoin::util::hash::{BitcoinHash, Sha256dHash};
use std::collections::HashMap;
use std::fmt;
use std::iter::FromIterator;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment