github.com/aergoio/aergo@v1.3.1/consensus/impl/raftv2/debug.go (about) 1 package raftv2 2 3 import ( 4 "os" 5 "strconv" 6 "time" 7 ) 8 9 var ( 10 DEBUG_PROPOSE_SLEEP = "DEBUG_PROPOSE_SLEEP" 11 ) 12 13 func checkEnv(envName string) int { 14 envStr := os.Getenv(envName) 15 if len(envStr) > 0 { 16 val, err := strconv.Atoi(envStr) 17 if err != nil { 18 logger.Error().Err(err).Msgf("%s environment varialble must be integer", envName) 19 return 0 20 } 21 logger.Debug().Int("value", val).Msgf("env variable[%s] is set", envName) 22 23 return val 24 } 25 return 0 26 } 27 28 func debugRaftProposeSleep() { 29 val := checkEnv(DEBUG_PROPOSE_SLEEP) 30 31 if val > 0 { 32 logger.Debug().Int("sleep", val).Msg("sleep raft propose") 33 time.Sleep(time.Second * time.Duration(val)) 34 } 35 }