OSDN Git Service

little edit (#107)
authorPaladz <yzhu101@uottawa.ca>
Sat, 1 Jun 2019 06:36:24 +0000 (14:36 +0800)
committerGitHub <noreply@github.com>
Sat, 1 Jun 2019 06:36:24 +0000 (14:36 +0800)
cmd/bytomd/commands/init.go
consensus/general.go

index 951aecb..4003047 100644 (file)
@@ -38,15 +38,15 @@ func initFiles(cmd *cobra.Command, args []string) {
                cfg.EnsureRoot(config.RootDir, "solonet")
        }
 
-       fedFile := config.FederationFile()
-       if _, err := os.Stat(fedFile); !os.IsNotExist(err) {
-               log.WithFields(log.Fields{"module": logModule, "config": fedFile}).Panic("Already exists federation file.")
-       }
-
-       if err := cfg.ExportFederationFile(fedFile, config); err != nil {
-               log.WithFields(log.Fields{"module": logModule, "config": fedFile, "error": err}).Panic("exportFederationFile failed.")
+       //generate the federation config file
+       fedFilePath := config.FederationFile()
+       if _, err := os.Stat(fedFilePath); os.IsNotExist(err) {
+               if err := cfg.ExportFederationFile(fedFilePath, config); err != nil {
+                       log.WithFields(log.Fields{"module": logModule, "config": fedFilePath, "error": err}).Panic("fail on export federation file")
+               }
        }
 
+       //generate the node private key
        keyFilePath := path.Join(config.RootDir, config.PrivateKeyFile)
        if _, err := os.Stat(keyFilePath); os.IsNotExist(err) {
                xprv, err := chainkd.NewXPrv(nil)
@@ -54,10 +54,11 @@ func initFiles(cmd *cobra.Command, args []string) {
                        log.WithFields(log.Fields{"module": logModule, "err": err}).Panic("fail on generate private key")
                }
 
-               xprvStr := hex.EncodeToString(xprv[:])
-               if err := ioutil.WriteFile(keyFilePath, []byte(xprvStr), 0600); err != nil {
+               if err := ioutil.WriteFile(keyFilePath, []byte(hex.EncodeToString(xprv[:])), 0600); err != nil {
                        log.WithFields(log.Fields{"module": logModule, "err": err}).Panic("fail on save private key")
                }
+
+               log.WithFields(log.Fields{"pubkey": xprv.XPub()}).Info("success generate private")
        }
 
        log.WithFields(log.Fields{"module": logModule, "config": configFilePath}).Info("Initialized bytom")
index cf3ddbf..2b513aa 100644 (file)
@@ -22,11 +22,6 @@ const (
        //config parameter for vote
        VotePendingBlockNumber = uint64(10000)
 
-       // config for pow mining
-       BlocksPerRetarget     = uint64(2016)
-       TargetSecondsPerBlock = uint64(150)
-       SeedPerRetarget       = uint64(256)
-
        // MaxTimeOffsetMs is the maximum number of seconds a block time is allowed to be ahead of the current time
        MaxTimeOffsetMs  = uint64(60 * 60 * 1000)
        MedianTimeBlocks = 11