Add new function to get the checkpoints.

Previously there was only a function to get the latest checkpoint.  This
commit exposes a new function named Checkpoints which returns a slice of
checkpoints ordered by height for the active network or nil when
checkpoints are disabled.
This commit is contained in:
Dave Collins 2014-01-31 19:51:24 -06:00
parent 6a9997583a
commit be2e4c5860

View file

@ -100,6 +100,17 @@ func (b *BlockChain) checkpointData() *checkpointData {
return nil return nil
} }
// Checkpoints returns a slice of checkpoints (regardless of whether they are
// already known). When checkpoints are disabled or there are no checkpoints
// for the active network, it will return nil.
func (b *BlockChain) Checkpoints() []Checkpoint {
if b.noCheckpoints || b.checkpointData() == nil {
return nil
}
return b.checkpointData().checkpoints
}
// LatestCheckpoint returns the most recent checkpoint (regardless of whether it // LatestCheckpoint returns the most recent checkpoint (regardless of whether it
// is already known). When checkpoints are disabled or there are no checkpoints // is already known). When checkpoints are disabled or there are no checkpoints
// for the active network, it will return nil. // for the active network, it will return nil.