Skip to content

Commit 73b65ae

Browse files
committed
Address issues with pull-root-block & generate-root-block-vote
1 parent 2abba86 commit 73b65ae

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

cmd/bootstrap/transit/cmd/generate_root_block_vote.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ var generateVoteCmd = &cobra.Command{
2626

2727
func init() {
2828
rootCmd.AddCommand(generateVoteCmd)
29-
addGenerateRootBlockCmdFlags()
29+
addGenerateVoteCmdFlags()
3030
}
3131

32-
func addGenerateRootBlockCmdFlags() {
32+
func addGenerateVoteCmdFlags() {
3333
generateVoteCmd.Flags().StringVarP(&flagOutputDir, "outputDir", "o", "", "ouput directory for vote files; if not set defaults to bootstrap directory")
3434
}
3535

@@ -83,6 +83,12 @@ func generateVote(c *cobra.Command, args []string) {
8383
signer := verification.NewCombinedSigner(me, beaconKeyStore)
8484

8585
path = filepath.Join(flagBootDir, bootstrap.PathRootBlockData)
86+
87+
// If output directory is specified, use it for the root-block.json
88+
if flagOutputDir != "" {
89+
path = filepath.Join(flagOutputDir, "root-block.json")
90+
}
91+
8692
data, err = io.ReadFile(path)
8793
if err != nil {
8894
log.Fatal().Err(err).Msg("could not read root block file")

cmd/bootstrap/transit/cmd/pull_root_block.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ func pullRootBlock(c *cobra.Command, args []string) {
6363
log.Fatal().Err(err).Msgf("could not download google bucket file")
6464
}
6565

66+
log.Info().Msg("successfully downloaded root block ")
67+
6668
objectName := filepath.Join(flagToken, fmt.Sprintf(FilenameRandomBeaconCipher, nodeID))
6769

6870
// By default, use the bootstrap directory for the random beacon download & unwrapping
@@ -83,12 +85,12 @@ func pullRootBlock(c *cobra.Command, args []string) {
8385

8486
err = bucket.DownloadFile(ctx, client, fullRandomBeaconPath, objectName)
8587
if err != nil {
86-
log.Fatal().Err(err).Msg("could not download file from google bucket")
87-
}
88-
err = unWrapFile(flagBootDir, nodeID, flagOutputDir, unWrappedRandomBeaconPath)
89-
if err != nil {
90-
log.Fatal().Err(err).Msg("could not unwrap random beacon file")
88+
log.Info().Msg("could not download file from google bucket")
89+
} else {
90+
err = unWrapFile(flagBootDir, nodeID, flagOutputDir, unWrappedRandomBeaconPath)
91+
if err != nil {
92+
log.Fatal().Err(err).Msg("could not unwrap random beacon file")
93+
}
94+
log.Info().Msg("successfully downloaded and unwrapped random beacon private key")
9195
}
92-
93-
log.Info().Msg("successfully downloaded root block and random beacon key")
9496
}

0 commit comments

Comments
 (0)