mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
rustfmt
This commit is contained in:
parent
3c1d8c3f8b
commit
e7eb26eed4
2 changed files with 23 additions and 6 deletions
|
@ -145,13 +145,18 @@ impl ProofOfWork {
|
||||||
};
|
};
|
||||||
let nonce = reader.read_u64()?;
|
let nonce = reader.read_u64()?;
|
||||||
let proof = Proof::read(reader)?;
|
let proof = Proof::read(reader)?;
|
||||||
Ok(ProofOfWork { total_difficulty, scaling_difficulty, nonce, proof})
|
Ok(ProofOfWork {
|
||||||
|
total_difficulty,
|
||||||
|
scaling_difficulty,
|
||||||
|
nonce,
|
||||||
|
proof,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write implementation, can't define as trait impl as we need a version
|
/// Write implementation, can't define as trait impl as we need a version
|
||||||
fn write<W: Writer>(&self, ver: u16, writer: &mut W) -> Result<(), ser::Error> {
|
fn write<W: Writer>(&self, ver: u16, writer: &mut W) -> Result<(), ser::Error> {
|
||||||
if writer.serialization_mode() != ser::SerializationMode::Hash {
|
if writer.serialization_mode() != ser::SerializationMode::Hash {
|
||||||
self.write_pre_pow(ver, writer)?;
|
self.write_pre_pow(ver, true, writer)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.proof.write(writer)?;
|
self.proof.write(writer)?;
|
||||||
|
@ -159,7 +164,12 @@ impl ProofOfWork {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write the pre-hash portion of the header
|
/// Write the pre-hash portion of the header
|
||||||
pub fn write_pre_pow<W: Writer>(&self, ver: u16, writer: &mut W) -> Result<(), ser::Error> {
|
pub fn write_pre_pow<W: Writer>(
|
||||||
|
&self,
|
||||||
|
ver: u16,
|
||||||
|
include_nonce: bool,
|
||||||
|
writer: &mut W,
|
||||||
|
) -> Result<(), ser::Error> {
|
||||||
if ver > 1 {
|
if ver > 1 {
|
||||||
ser_multiwrite!(
|
ser_multiwrite!(
|
||||||
writer,
|
writer,
|
||||||
|
@ -167,7 +177,9 @@ impl ProofOfWork {
|
||||||
[write_u64, self.scaling_difficulty]
|
[write_u64, self.scaling_difficulty]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
writer.write_u64(self.nonce)?;
|
if include_nonce {
|
||||||
|
writer.write_u64(self.nonce)?;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +368,9 @@ impl BlockHeader {
|
||||||
pub fn pre_pow_hash(&self) -> Hash {
|
pub fn pre_pow_hash(&self) -> Hash {
|
||||||
let mut hasher = HashWriter::default();
|
let mut hasher = HashWriter::default();
|
||||||
self.write_pre_pow(&mut hasher).unwrap();
|
self.write_pre_pow(&mut hasher).unwrap();
|
||||||
self.pow.write_pre_pow(self.version, &mut hasher).unwrap();
|
self.pow
|
||||||
|
.write_pre_pow(self.version, true, &mut hasher)
|
||||||
|
.unwrap();
|
||||||
let mut ret = [0; 32];
|
let mut ret = [0; 32];
|
||||||
hasher.finalize(&mut ret);
|
hasher.finalize(&mut ret);
|
||||||
Hash(ret)
|
Hash(ret)
|
||||||
|
|
|
@ -34,7 +34,7 @@ use core::{global, pow, ser};
|
||||||
use keychain;
|
use keychain;
|
||||||
use mining::mine_block;
|
use mining::mine_block;
|
||||||
use pool;
|
use pool;
|
||||||
use util::{LOGGER, self};
|
use util::{self, LOGGER};
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
// http://www.jsonrpc.org/specification
|
// http://www.jsonrpc.org/specification
|
||||||
|
@ -270,6 +270,9 @@ impl StratumServer {
|
||||||
{
|
{
|
||||||
let mut writer = ser::BinWriter::new(&mut header_buf);
|
let mut writer = ser::BinWriter::new(&mut header_buf);
|
||||||
bh.write_pre_pow(&mut writer).unwrap();
|
bh.write_pre_pow(&mut writer).unwrap();
|
||||||
|
bh.pow
|
||||||
|
.write_pre_pow(bh.version, false, &mut writer)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
let pre_pow = util::to_hex(header_buf);
|
let pre_pow = util::to_hex(header_buf);
|
||||||
let job_template = JobTemplate {
|
let job_template = JobTemplate {
|
||||||
|
|
Loading…
Reference in a new issue