fix timestamp generation and check

This commit is contained in:
NikVolf 2016-11-25 14:40:07 +03:00
parent e167b3350a
commit 9f4469e480
5 changed files with 5 additions and 2 deletions

1
Cargo.lock generated
View File

@ -688,6 +688,7 @@ dependencies = [
"chain 0.1.0",
"primitives 0.1.0",
"serialization 0.1.0",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]

View File

@ -7,3 +7,4 @@ authors = ["Nikolay Volf <nikvolf@gmail.com>"]
chain = { path = "../chain" }
primitives = { path = "../primitives" }
serialization = { path = "../serialization" }
time = "0.1"

View File

@ -182,7 +182,7 @@ impl<F> BlockHeaderBuilder<F> where F: Invoke<chain::BlockHeader> {
pub fn with_callback(callback: F) -> Self {
BlockHeaderBuilder {
callback: callback,
time: 0,
time: ::time::get_time().sec as u32,
nonce: 0,
merkle_root: H256::from(0),
parent: H256::from(0),

View File

@ -3,6 +3,7 @@
extern crate chain;
extern crate primitives;
extern crate serialization as ser;
extern crate time;
use chain::Block;

View File

@ -65,7 +65,7 @@ impl ChainVerifier {
}
if let Some(median_timestamp) = self.ordered_median_timestamp(block, at_height) {
if median_timestamp >= block.block_header.time {
if median_timestamp > block.block_header.time {
trace!(target: "verification", "median timestamp verification failed, median: {}, current: {}", median_timestamp, block.block_header.time);
return Err(Error::Timestamp);
}