diff --git a/apis/eth_price.go b/apis/eth_price.go index ffd8c1eb..f7e82947 100644 --- a/apis/eth_price.go +++ b/apis/eth_price.go @@ -4,11 +4,12 @@ import ( "bytes" "encoding/json" "fmt" - "github.com/golang/glog" - "github.com/montanaflynn/stats" "io/ioutil" "net/http" "strconv" + + "github.com/golang/glog" + "github.com/montanaflynn/stats" ) type CoinbaseResponse struct { @@ -194,7 +195,7 @@ func GetUSDToETHPrice() (float64, error) { amount, err := getCoinbasePrice() if err != nil { // The amount will be zero in this case, which is fine - glog.Errorf("Error fetching Coinbase price: %v", err) + glog.V(2).Infof("Error fetching Coinbase price: %v", err) } if amount != 0 { @@ -205,7 +206,7 @@ func GetUSDToETHPrice() (float64, error) { amount, err := getCoingeckoPrice() if err != nil { // The amount will be zero in this case, which is fine - glog.Errorf("Error fetching Coingecko price: %v", err) + glog.V(2).Infof("Error fetching Coingecko price: %v", err) } if amount != 0 { @@ -216,7 +217,7 @@ func GetUSDToETHPrice() (float64, error) { amount, err := getBlockchainDotcomPrice() if err != nil { // The amount will be zero in this case, which is fine - glog.Errorf("Error fetching blockchain.com price: %v", err) + glog.V(2).Infof("Error fetching blockchain.com price: %v", err) } if amount != 0 { @@ -227,7 +228,7 @@ func GetUSDToETHPrice() (float64, error) { amount, err := getGeminiPrice() if err != nil { // The amount will be zero in this case, which is fine - glog.Errorf("Error fetching Gemini price: %v", err) + glog.V(2).Infof("Error fetching Gemini price: %v", err) } if amount != 0 { @@ -238,7 +239,7 @@ func GetUSDToETHPrice() (float64, error) { amount, err := getKrakenPrice() if err != nil { // The amount will be zero in this case, which is fine - glog.Errorf("Error fetching Kraken price: %v", err) + glog.V(2).Infof("Error fetching Kraken price: %v", err) } if amount != 0 { diff --git a/routes/admin_node.go b/routes/admin_node.go index 473c26dd..136e63d7 100644 --- a/routes/admin_node.go +++ b/routes/admin_node.go @@ -167,7 +167,7 @@ func (fes *APIServer) _handleNodeControlGetInfo( existingDeSoPeers[currentPeerRes.IP+fmt.Sprintf(":%d", currentPeerRes.ProtocolPort)] = true } // Return some deso addrs from the addr manager. - desoAddrs := fes.backendServer.GetConnectionManager().GetAddrManager().AddressCache() + desoAddrs := fes.backendServer.AddrMgr.AddressCache() sort.Slice(desoAddrs, func(ii, jj int) bool { // Use a hash to get a random but deterministic ordering. hashI := string(lib.Sha256DoubleHash([]byte(desoAddrs[ii].IP.String() + fmt.Sprintf(":%d", desoAddrs[ii].Port)))[:]) @@ -239,12 +239,12 @@ func (fes *APIServer) _handleConnectDeSoNode( // increasing retry delay, but we should still clean it up at some point. connectPeerDone := make(chan bool) go func() { - netAddr, err := fes.backendServer.GetConnectionManager().GetAddrManager().HostToNetAddress(ip, protocolPort, 0) + netAddr, err := fes.backendServer.AddrMgr.HostToNetAddress(ip, protocolPort, 0) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("_handleConnectDeSoNode: Cannot connect to node %s:%d: %v", ip, protocolPort, err)) return } - fes.backendServer.GetConnectionManager().ConnectPeer(nil, netAddr) + fes.backendServer.GetNetworkManager().CreateNonValidatorOutboundConnection(ip) // Spin until the peer shows up in the connection manager or until 100 iterations. // Note the pause between each iteration. @@ -274,7 +274,7 @@ func (fes *APIServer) _handleConnectDeSoNode( // At this point the peer shoud be connected. Add their address to the addrmgr // in case the user wants to connect again in the future. Set the source to be // the address itself since we don't have anything else. - fes.backendServer.GetConnectionManager().GetAddrManager().AddAddress(netAddr, netAddr) + fes.backendServer.AddrMgr.AddAddress(netAddr, netAddr) connectPeerDone <- true return @@ -320,13 +320,13 @@ func (fes *APIServer) _handleDisconnectDeSoNode( // Manually remove the peer from the connection manager and mark it as such // so that the connection manager won't reconnect to it or replace it. - fes.backendServer.GetConnectionManager().RemovePeer(peerFound) - peerFound.PeerManuallyRemovedFromConnectionManager = true - - peerFound.Disconnect() + remoteNode := fes.backendServer.GetNetworkManager().GetRemoteNodeManager().GetRemoteNodeFromPeer(peerFound) + if remoteNode != nil { + fes.backendServer.GetNetworkManager().GetRemoteNodeManager().Disconnect(remoteNode) + } res := NodeControlResponse{ - // Return an empty response, which indicates we set the peer up to be connected. + // Return an empty response, which indicates we set the peer up to be disconnected. } if err := json.NewEncoder(ww).Encode(res); err != nil { _AddBadRequestError(ww, fmt.Sprintf("NodeControl: Problem encoding response as JSON: %v", err)) diff --git a/routes/base.go b/routes/base.go index fa72279c..ce0359a0 100644 --- a/routes/base.go +++ b/routes/base.go @@ -150,14 +150,14 @@ func (fes *APIServer) GetBlockchainDotComExchangeRate() (_exchangeRate float64, url := "https://api.blockchain.com/v3/exchange/tickers/CLOUT-USD" req, err := http.NewRequest("GET", url, nil) if err != nil { - glog.Errorf("GetBlockchainDotComExchangeRate: Problem creating request: %v", err) + glog.V(2).Infof("GetBlockchainDotComExchangeRate: Problem creating request: %v", err) continue } req.Header.Set("Content-Type", "application/json") resp, err := httpClient.Do(req) if err != nil { - glog.Errorf("GetBlockchainDotComExchangeRate: Problem with HTTP request %s: %v", url, err) + glog.V(2).Infof("GetBlockchainDotComExchangeRate: Problem with HTTP request %s: %v", url, err) continue } defer resp.Body.Close() @@ -167,7 +167,7 @@ func (fes *APIServer) GetBlockchainDotComExchangeRate() (_exchangeRate float64, responseData := &BlockchainDeSoTickerResponse{} decoder := json.NewDecoder(bytes.NewReader(body)) if err = decoder.Decode(responseData); err != nil { - glog.Errorf("GetBlockchainDotComExchangeRate: Problem decoding response JSON into "+ + glog.V(2).Infof("GetBlockchainDotComExchangeRate: Problem decoding response JSON into "+ "interface %v, response: %v, error: %v", responseData, resp, err) continue } @@ -179,13 +179,13 @@ func (fes *APIServer) GetBlockchainDotComExchangeRate() (_exchangeRate float64, } blockchainDotComExchangeRate, err := stats.Max(exchangeRatesFetched) if err != nil { - glog.Errorf("GetBlockchainDotComExchangeRate: Problem getting max from list of float64s: %v", err) + glog.V(2).Infof("GetBlockchainDotComExchangeRate: Problem getting max from list of float64s: %v", err) return 0, err } glog.V(2).Infof("Blockchain exchange rate: %v %v", blockchainDotComExchangeRate, exchangeRatesFetched) if fes.backendServer != nil && fes.backendServer.GetStatsdClient() != nil { if err = fes.backendServer.GetStatsdClient().Gauge("BLOCKCHAIN_LAST_TRADE_PRICE", blockchainDotComExchangeRate, []string{}, 1); err != nil { - glog.Errorf("GetBlockchainDotComExchangeRate: Error logging Last Trade Price of %f to datadog: %v", blockchainDotComExchangeRate, err) + glog.V(2).Infof("GetBlockchainDotComExchangeRate: Error logging Last Trade Price of %f to datadog: %v", blockchainDotComExchangeRate, err) } } return blockchainDotComExchangeRate, nil diff --git a/routes/bitcoin_price.go b/routes/bitcoin_price.go index 5f7842ee..31f8e2d6 100644 --- a/routes/bitcoin_price.go +++ b/routes/bitcoin_price.go @@ -4,11 +4,12 @@ import ( "bytes" "encoding/json" "fmt" - "github.com/golang/glog" - "github.com/montanaflynn/stats" "io/ioutil" "net/http" "strconv" + + "github.com/golang/glog" + "github.com/montanaflynn/stats" ) type CoinbaseResponse struct { @@ -206,7 +207,7 @@ func GetUSDToBTCPrice() (float64, error) { amount, err := getCoinbasePrice() if err != nil { // The amount will be zero in this case, which is fine - glog.Errorf("Error fetching Coinbase price: %v", err) + glog.V(2).Infof("Error fetching Coinbase price: %v", err) } if amount != 0 { @@ -217,7 +218,7 @@ func GetUSDToBTCPrice() (float64, error) { amount, err := getCoingeckoPrice() if err != nil { // The amount will be zero in this case, which is fine - glog.Errorf("Error fetching Coingecko price: %v", err) + glog.V(2).Infof("Error fetching Coingecko price: %v", err) } if amount != 0 { @@ -228,7 +229,7 @@ func GetUSDToBTCPrice() (float64, error) { amount, err := getBlockchainDotcomPrice() if err != nil { // The amount will be zero in this case, which is fine - glog.Errorf("Error fetching blockchain.com price: %v", err) + glog.V(2).Infof("Error fetching blockchain.com price: %v", err) } if amount != 0 { @@ -239,7 +240,7 @@ func GetUSDToBTCPrice() (float64, error) { amount, err := getGeminiPrice() if err != nil { // The amount will be zero in this case, which is fine - glog.Errorf("Error fetching Gemini price: %v", err) + glog.V(2).Infof("Error fetching Gemini price: %v", err) } if amount != 0 { @@ -250,7 +251,7 @@ func GetUSDToBTCPrice() (float64, error) { amount, err := getKrakenPrice() if err != nil { // The amount will be zero in this case, which is fine - glog.Errorf("Error fetching Kraken price: %v", err) + glog.V(2).Infof("Error fetching Kraken price: %v", err) } if amount != 0 {