Skip to content

Commit

Permalink
Initialize but do not run exchange rates when disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
cpacia committed Jan 3, 2019
1 parent 4da6964 commit f4fcbce
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 1 addition & 2 deletions exchangerates/bitcoinprices.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func NewBitcoinPriceFetcher(dialer proxy.Dialer) *BitcoinPriceFetcher {
{"https://blockchain.info/ticker", b.cache, client, BlockchainInfoDecoder{}},
{"https://api.bitcoincharts.com/v1/weighted_prices.json", b.cache, client, BitcoinChartsDecoder{}},
}
go b.run()
return &b
}

Expand Down Expand Up @@ -141,7 +140,7 @@ func (provider *ExchangeRateProvider) fetch() (err error) {
return provider.decoder.decode(dataMap, provider.cache)
}

func (b *BitcoinPriceFetcher) run() {
func (b *BitcoinPriceFetcher) Run() {
b.fetchCurrentRates()
ticker := time.NewTicker(time.Minute * 15)
for range ticker.C {
Expand Down
10 changes: 5 additions & 5 deletions peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ func NewPeerManager(config *PeerManagerConfig) (*PeerManager, error) {
}

pm := &PeerManager{
addrManager: addrmgr.New(config.AddressCacheDir, nil),
peerMutex: new(sync.RWMutex),
sourceAddr: wire.NewNetAddressIPPort(net.ParseIP("0.0.0.0"), defaultPort, 0),
trustedPeer: config.TrustedPeer,
proxy: config.Proxy,
addrManager: addrmgr.New(config.AddressCacheDir, nil),
peerMutex: new(sync.RWMutex),
sourceAddr: wire.NewNetAddressIPPort(net.ParseIP("0.0.0.0"), defaultPort, 0),
trustedPeer: config.TrustedPeer,
proxy: config.Proxy,
recentlyTriedAddresses: make(map[string]bool),
connectedPeers: make(map[uint64]*peer.Peer),
msgChan: config.MsgChan,
Expand Down
4 changes: 3 additions & 1 deletion wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ func NewSPVWallet(config *Config) (*SPVWallet, error) {
mutex: new(sync.RWMutex),
}

bpf := exchangerates.NewBitcoinPriceFetcher(config.Proxy)
w.exchangeRates = bpf
if !config.DisableExchangeRates {
w.exchangeRates = exchangerates.NewBitcoinPriceFetcher(config.Proxy)
go bpf.Run()
}

w.keyManager, err = NewKeyManager(config.DB.Keys(), w.params, w.masterPrivateKey)
Expand Down

0 comments on commit f4fcbce

Please sign in to comment.