diff --git a/block/block.go b/block/block.go index 79f99ef6..9b2d35f5 100644 --- a/block/block.go +++ b/block/block.go @@ -120,10 +120,8 @@ func (h *Header) Hash() []byte { if *err != nil { panic(err) } - log.Debug("Hashing", "bytes", buf.Bytes()) hasher.Write(buf.Bytes()) hash := hasher.Sum(nil) - log.Debug("Hashing got", "hash", hash) return hash } diff --git a/config/config.go b/config/config.go index d7d7b194..ecf1c1a2 100644 --- a/config/config.go +++ b/config/config.go @@ -21,13 +21,19 @@ var defaultConfig = `# This is a TOML config file. Network = "tendermint_testnet0" ListenAddr = "0.0.0.0:8080" # First node to connect to. Command-line overridable. -# SeedNode = "a.b.c.d:pppp" +SeedNode = "23.239.22.253:8080" [DB] # The only other available backend is "memdb" Backend = "leveldb" -# The leveldb data directory. -# Dir = "/.tendermint/data" +# Dir = "~/.tendermint/data" + +[Log.Stdout] +Level = "info" + +[Log.File] +Level = "debug" +# Dir = "~/.tendermint/log" [RPC.HTTP] # For the RPC API HTTP server. Port required. @@ -46,8 +52,9 @@ func initDefaults() { App.SetDefault("ListenAddr", "0.0.0.0:8080") App.SetDefault("DB.Backend", "leveldb") App.SetDefault("DB.Dir", rootDir+"/data") - App.SetDefault("Log.Level", "debug") - App.SetDefault("Log.Dir", rootDir+"/log") + App.SetDefault("Log.Stdout.Level", "info") + App.SetDefault("Log.File.Dir", rootDir+"/log") + App.SetDefault("Log.File.Level", "debug") App.SetDefault("RPC.HTTP.ListenAddr", "0.0.0.0:8081") App.SetDefault("GenesisFile", rootDir+"/genesis.json") diff --git a/consensus/state.go b/consensus/state.go index 2d992918..010e8b6e 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -315,7 +315,7 @@ func (cs *ConsensusState) stepTransitionRoutine() { // we're running in a separate goroutine, which avoids deadlocks. rs := cs.getRoundState() round, roundStartTime, roundDuration, _, elapsedRatio := calcRoundInfo(rs.StartTime) - log.Info("Scheduling next action", "height", rs.Height, "round", round, "step", rs.Step, "roundStartTime", roundStartTime, "elapsedRatio", elapsedRatio) + log.Debug("Scheduling next action", "height", rs.Height, "round", round, "step", rs.Step, "roundStartTime", roundStartTime, "elapsedRatio", elapsedRatio) switch rs.Step { case RoundStepNewHeight: // We should run RoundActionPropose when rs.StartTime passes. diff --git a/logger/log.go b/logger/log.go index cb63bd3c..6ea35954 100644 --- a/logger/log.go +++ b/logger/log.go @@ -5,32 +5,41 @@ import ( "os" "github.com/tendermint/log15" + . "github.com/tendermint/tendermint/common" "github.com/tendermint/tendermint/config" ) var rootHandler log15.Handler +func getLevel(lvlString string) log15.Lvl { + lvl, err := log15.LvlFromString(lvlString) + if err != nil { + Exit(Fmt("Invalid log level %v: %v", lvlString, err)) + } + return lvl +} + func init() { handlers := []log15.Handler{} // By default, there's a stdout terminal format handler. handlers = append(handlers, log15.LvlFilterHandler( - log15.LvlDebug, + getLevel(config.App.GetString("Log.Stdout.Level")), log15.StreamHandler(os.Stdout, log15.TerminalFormat()), )) // Maybe also write to a file. - if config.App.GetString("Log.Dir") != "" { + if _logFileDir := config.App.GetString("Log.File.Dir"); _logFileDir != "" { // Create log dir if it doesn't exist - err := os.MkdirAll(config.App.GetString("Log.Dir"), 0700) + err := os.MkdirAll(_logFileDir, 0700) if err != nil { fmt.Printf("Could not create directory: %v", err) os.Exit(1) } // File handler handlers = append(handlers, log15.LvlFilterHandler( - log15.LvlDebug, - log15.Must.FileHandler(config.App.GetString("Log.Dir")+"/tendermint.log", log15.LogfmtFormat()), + getLevel(config.App.GetString("Log.File.Level")), + log15.Must.FileHandler(_logFileDir+"/tendermint.log", log15.LogfmtFormat()), )) } diff --git a/p2p/pex_reactor.go b/p2p/pex_reactor.go index bca70370..3ede6dc0 100644 --- a/p2p/pex_reactor.go +++ b/p2p/pex_reactor.go @@ -152,7 +152,7 @@ FOR_LOOP: func (pexR *PEXReactor) ensurePeers() { numOutPeers, _, numDialing := pexR.sw.NumPeers() numToDial := minNumOutboundPeers - (numOutPeers + numDialing) - log.Info("Ensure peers", "numOutPeers", numOutPeers, "numDialing", numDialing, "numToDial", numToDial) + log.Debug("Ensure peers", "numOutPeers", numOutPeers, "numDialing", numDialing, "numToDial", numToDial) if numToDial <= 0 { return } @@ -166,15 +166,16 @@ func (pexR *PEXReactor) ensurePeers() { // Try to fetch a new peer 3 times. // This caps the maximum number of tries to 3 * numToDial. for j := 0; j < 3; j++ { - picked = pexR.book.PickAddress(newBias) - if picked == nil { - return + try := pexR.book.PickAddress(newBias) + if try == nil { + break } - if toDial.Has(picked.String()) || - pexR.sw.IsDialing(picked) || - pexR.sw.Peers().Has(picked.String()) { + if toDial.Has(try.String()) || + pexR.sw.IsDialing(try) || + pexR.sw.Peers().Has(try.String()) { continue } else { + picked = try break } } diff --git a/p2p/switch.go b/p2p/switch.go index cf555667..2a804ae8 100644 --- a/p2p/switch.go +++ b/p2p/switch.go @@ -45,7 +45,7 @@ var ( ) const ( - peerDialTimeoutSeconds = 30 + peerDialTimeoutSeconds = 3 ) func NewSwitch(reactors []Reactor) *Switch {