mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
add hash() to tip for safety (#2145)
This commit is contained in:
parent
df62fd6d95
commit
7ae22eff2b
1 changed files with 7 additions and 2 deletions
|
@ -64,8 +64,7 @@ pub struct Tip {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tip {
|
impl Tip {
|
||||||
/// TODO - why do we have Tip when we could just use a block header?
|
/// Creates a new tip based on provided header.
|
||||||
/// Creates a new tip based on header.
|
|
||||||
pub fn from_header(header: &BlockHeader) -> Tip {
|
pub fn from_header(header: &BlockHeader) -> Tip {
|
||||||
Tip {
|
Tip {
|
||||||
height: header.height,
|
height: header.height,
|
||||||
|
@ -74,6 +73,12 @@ impl Tip {
|
||||||
total_difficulty: header.total_difficulty(),
|
total_difficulty: header.total_difficulty(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// *Really* easy to accidentally call hash() on a tip (thinking its a header).
|
||||||
|
/// So lets make hash() do the right thing here.
|
||||||
|
pub fn hash(&self) -> Hash {
|
||||||
|
self.last_block_h
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Tip {
|
impl Default for Tip {
|
||||||
|
|
Loading…
Reference in a new issue