diff --git a/rpcserver.go b/rpcserver.go index eba7e0474..9bc3da261 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -156,10 +156,6 @@ var rpcHandlersBeforeInit = map[string]commandHandler{ "verifychain": handleVerifyChain, } -func init() { - rpcHandlers = rpcHandlersBeforeInit -} - // list of commands that we recognise, but for which btcd has no support because // it lacks support for wallet functionality. For these commands the user // should ask a connected instance of btcwallet. @@ -1447,7 +1443,6 @@ func (state *gbtWorkState) updateBlockTemplate(s *rpcServer, useCoinbaseValue bo // to create their own coinbase. var payAddr btcutil.Address if !useCoinbaseValue { - rand.Seed(time.Now().UnixNano()) payAddr = cfg.miningAddrs[rand.Intn(len(cfg.miningAddrs))] } @@ -1514,7 +1509,6 @@ func (state *gbtWorkState) updateBlockTemplate(s *rpcServer, useCoinbaseValue bo // returned if none have been specified. if !useCoinbaseValue && !template.validPayAddress { // Choose a payment address at random. - rand.Seed(time.Now().UnixNano()) payToAddr := cfg.miningAddrs[rand.Intn(len(cfg.miningAddrs))] // Update the block coinbase output of the template to @@ -2470,7 +2464,6 @@ func handleGetWorkRequest(s *rpcServer) (interface{}, error) { state.prevHash = nil // Choose a payment address at random. - rand.Seed(time.Now().UnixNano()) payToAddr := cfg.miningAddrs[rand.Intn(len(cfg.miningAddrs))] template, err := NewBlockTemplate(s.server.txMemPool, payToAddr) @@ -3121,3 +3114,8 @@ func getDifficultyRatio(bits uint32) float64 { } return diff } + +func init() { + rpcHandlers = rpcHandlersBeforeInit + rand.Seed(time.Now().UnixNano()) +}