From e4c2beffc8812dfb146ef32cde92017f5e2a8d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20D=C3=A9trez?= Date: Tue, 13 Aug 2024 14:22:42 +0200 Subject: [PATCH] Add a cli option to get a witness' checkpoints 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 --- cmd/client/client.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/cmd/client/client.go b/cmd/client/client.go index 47c3e83..d3145ac 100644 --- a/cmd/client/client.go +++ b/cmd/client/client.go @@ -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() { @@ -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 {