Skip to content

Commit

Permalink
Add a cli option to get a witness' checkpoints
Browse files Browse the repository at this point in the history
Add a new -w option that takes a witness name and returns the latest
checkpoints signed by this witness
This is useful for witness admin (or ArmoredWitness custodians) to check
that their witness is working.

Usage:

    go run ./cmd/client -w ArmoredWitness-dry-sunset
  • Loading branch information
gregoire-mullvad authored and AlCutter committed Aug 14, 2024
1 parent b51e407 commit e4c2bef
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions cmd/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
var (
baseURL = flag.String("base_url", "https://api.transparency.dev", "The base URL of the distributor")
n = flag.Uint("n", 2, "The desired number of witness signatures for each log")
witness = flag.String("w", "", "Show the latest checkpoints for this witness short name")
)

func main() {
Expand All @@ -58,10 +59,20 @@ func main() {
continue
}
fmt.Printf("Log %q (%s)\n", log.Verifier.Name(), l)
cp, err := d.GetCheckpointN(l, *n)
if err != nil {
fmt.Printf("❌️ Could not get checkpoint.%d: %v\n", *n, err)
continue
var cp []byte
var err error
if *witness == "" {
cp, err = d.GetCheckpointN(l, *n)
if err != nil {
fmt.Printf("❌️ Could not get checkpoint.%d: %v\n", *n, err)
continue
}
} else {
cp, err = d.GetCheckpointWitness(l, *witness)
if err != nil {
fmt.Printf("❌️ Could not get checkpoint: %v\n", err)
continue
}
}
_, _, cpN, err := f_log.ParseCheckpoint(cp, log.Origin, log.Verifier, maps.Values(ws)...)
if err != nil {
Expand Down

0 comments on commit e4c2bef

Please sign in to comment.