Export CalcPastMedianTime function.
This commit makes a slight variant of the existing calcPastMedianTime function available to external callers. The new exported version calculates the past median time from the end of the current main chain versus an arbitrary block node.
This commit is contained in:
parent
6dd7785276
commit
96f9b88935
1 changed files with 9 additions and 0 deletions
9
chain.go
9
chain.go
|
@ -680,6 +680,15 @@ func (b *BlockChain) calcPastMedianTime(startNode *blockNode) (time.Time, error)
|
|||
return medianTimestamp, nil
|
||||
}
|
||||
|
||||
// CalcPastMedianTime calculates the median time of the previous few blocks
|
||||
// prior to, and including, the end of the current best chain. It is primarily
|
||||
// used to ensure new blocks have sane timestamps.
|
||||
//
|
||||
// This function is NOT safe for concurrent access.
|
||||
func (b *BlockChain) CalcPastMedianTime() (time.Time, error) {
|
||||
return b.calcPastMedianTime(b.bestChain)
|
||||
}
|
||||
|
||||
// getReorganizeNodes finds the fork point between the main chain and the passed
|
||||
// node and returns a list of block nodes that would need to be detached from
|
||||
// the main chain and a list of block nodes that would need to be attached to
|
||||
|
|
Loading…
Add table
Reference in a new issue