From be2e4c5860bdbd2db42c473bb6c31c1954d14022 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Fri, 31 Jan 2014 19:51:24 -0600 Subject: [PATCH] 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. --- checkpoints.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/checkpoints.go b/checkpoints.go index 384b9160..c52218cf 100644 --- a/checkpoints.go +++ b/checkpoints.go @@ -100,6 +100,17 @@ func (b *BlockChain) checkpointData() *checkpointData { 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 // is already known). When checkpoints are disabled or there are no checkpoints // for the active network, it will return nil.