|
8 | 8 | "encoding/json"
|
9 | 9 | "errors"
|
10 | 10 | "fmt"
|
| 11 | + "golang.org/x/xerrors" |
11 | 12 | "io/ioutil"
|
12 | 13 | "math/rand"
|
13 | 14 | "net"
|
@@ -495,6 +496,43 @@ func scOptimize(c *cli.Context) error {
|
495 | 496 | return nil
|
496 | 497 | }
|
497 | 498 |
|
| 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 | + |
498 | 536 | // Joins a given skipchain
|
499 | 537 | func dnsFetch(c *cli.Context) error {
|
500 | 538 | if c.NArg() != 2 {
|
|
0 commit comments