fix timestamp generation and check
This commit is contained in:
parent
e167b3350a
commit
9f4469e480
|
@ -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]]
|
||||
|
|
|
@ -7,3 +7,4 @@ authors = ["Nikolay Volf <nikvolf@gmail.com>"]
|
|||
chain = { path = "../chain" }
|
||||
primitives = { path = "../primitives" }
|
||||
serialization = { path = "../serialization" }
|
||||
time = "0.1"
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
extern crate chain;
|
||||
extern crate primitives;
|
||||
extern crate serialization as ser;
|
||||
extern crate time;
|
||||
|
||||
use chain::Block;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue