Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Commit 8f88432

Browse files
author
GitHub
committed
Automatic update on Mon Jun 13 01:08:21 UTC 2022
1 parent a7a0c33 commit 8f88432

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

pkg/cothority/scmgr/app.go

+38
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"encoding/json"
99
"errors"
1010
"fmt"
11+
"golang.org/x/xerrors"
1112
"io/ioutil"
1213
"math/rand"
1314
"net"
@@ -495,6 +496,43 @@ func scOptimize(c *cli.Context) error {
495496
return nil
496497
}
497498

499+
func scScan(c *cli.Context) error {
500+
if c.NArg() < 1 {
501+
return errors.New("please give one remote URL")
502+
}
503+
si := network.ServerIdentity{Address: network.Address(c.Args().First()),
504+
URL: c.Args().First(), Public: cothority.Suite.Point()}
505+
cl := skipchain.NewClient()
506+
507+
if c.NArg() == 2 {
508+
chain, err := hex.DecodeString(c.Args().Get(1))
509+
if err != nil {
510+
return xerrors.Errorf("wrong chain format: %v")
511+
}
512+
roster := onet.NewRoster([]*network.ServerIdentity{&si})
513+
update, err := cl.GetUpdateChain(roster, chain)
514+
if err != nil {
515+
return xerrors.Errorf("while getting update: %v", err)
516+
}
517+
latest := update.Update[len(update.Update)-1]
518+
group := app.Group{Roster: latest.Roster}
519+
toml, err := group.Toml(cothority.Suite)
520+
if err != nil {
521+
return xerrors.Errorf("while creating toml group: %v", err)
522+
}
523+
log.Infof("Group-toml is: \n%s", toml.String())
524+
} else {
525+
chains, err := cl.GetAllSkipChainIDs(&si)
526+
if err != nil {
527+
return xerrors.Errorf("couldn't fetch chains: %v", err)
528+
}
529+
for _, chain := range chains.IDs {
530+
log.Infof("Chain is: %x", chain)
531+
}
532+
}
533+
return nil
534+
}
535+
498536
// Joins a given skipchain
499537
func dnsFetch(c *cli.Context) error {
500538
if c.NArg() != 2 {

pkg/cothority/scmgr/commands.go

+6
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ func getCommands() cli.Commands {
188188
},
189189
},
190190
},
191+
{
192+
Name: "scan",
193+
Usage: "get all skipchains from a node",
194+
Action: scScan,
195+
ArgsUsage: "URL of node",
196+
},
191197
},
192198
},
193199

0 commit comments

Comments
 (0)