// Refresh retrieves and parses API data from Coinbase.
762435
func (coinbase *CoinbaseExchange) Refresh() {
	coinbase.LogRequest()
	response := new(CoinbaseResponse)
	err := coinbase.fetch(coinbase.requests.price, response)
	if err != nil {
		coinbase.fail("Fetch", err)
		return
	}

	indices := make(FiatIndices)
	for code, floatStr := range response.Data.Rates {
		price, err := strconv.ParseFloat(floatStr, 64)
		if err != nil {
			coinbase.fail(fmt.Sprintf("Failed to parse float for index %s. Given %s", code, floatStr), err)
			continue
		}
		indices[code] = price
	}
	coinbase.UpdateIndices(indices)
}
604518
func (dragonex *DragonExchange) Refresh() {
	dragonex.LogRequest()
	response := new(DragonExPriceResponse)
	err := dragonex.fetch(dragonex.requests.price, response)
	if err != nil {
		dragonex.fail("Fetch", err)
		return
	}
	if !response.Ok {
		dragonex.fail("Response not ok", err)
		return
	}
	if len(response.Data) == 0 {
		dragonex.fail("No data", fmt.Errorf("Response data array is empty"))
		return
	}
	data := response.Data[0]
	if data.SymbolID != dragonex.SymbolID {
		dragonex.fail("Wrong code", fmt.Errorf("Pair id %d in response is not the expected id %d", data.SymbolID, dragonex.SymbolID))
		return
	}
	price, err := strconv.ParseFloat(data.ClosePrice, 64)
	if err != nil {
		dragonex.fail(fmt.Sprintf("Failed to parse float from ClosePrice=%s", data.ClosePrice), err)
		return
	}
	volume, err := strconv.ParseFloat(data.TotalVolume, 64)
	if err != nil {
		dragonex.fail(fmt.Sprintf("Failed to parse float from TotalVolume=%s", data.TotalVolume), err)
		return
	}
	btcVolume := volume * price
	priceChange, err := strconv.ParseFloat(data.PriceChange, 64)
	if err != nil {
		dragonex.fail(fmt.Sprintf("Failed to parse float from PriceChange=%s", data.PriceChange), err)
		return
	}

	// Depth chart
	depthSellResponse := new(DragonExDepthResponse)
	sellErr := dragonex.getDragonExDepthData(dragonex.depthSellRequest, depthSellResponse)
	if sellErr != nil {
		log.Errorf("DragonEx sell order book response error: %v", sellErr)
	}

	depthBuyResponse := new(DragonExDepthResponse)
	buyErr := dragonex.getDragonExDepthData(dragonex.depthBuyRequest, depthBuyResponse)
	if buyErr != nil {
		log.Errorf("DragonEx buy order book response error: %v", buyErr)
	}

	var depth *DepthData
	if sellErr == nil && buyErr == nil {
		depth = &DepthData{
			Time: time.Now().Unix(),
			Bids: depthBuyResponse.Data.translate(),
			Asks: depthSellResponse.Data.translate(),
		}
	}

	// Grab the current state to check if candlesticks need updating
	state := dragonex.state()

	candlesticks := map[candlestickKey]Candlesticks{}
	for bin, req := range dragonex.requests.candlesticks {
		oldSticks, found := state.Candlesticks[bin]
		if !found || oldSticks.needsUpdate(bin) {
			log.Tracef("Signalling candlestick update for %s, bin size %s", dragonex.token, bin)
			response := new(DragonExCandlestickResponse)
			err := dragonex.fetch(req, response)
			if err != nil {
				log.Errorf("Error retrieving candlestick data from dragonex for bin size %s: %v", string(bin), err)
				continue
			}
			if !response.Ok {
				log.Errorf("DragonEx server error while fetching candlestick data. Message: %s", response.Msg)
			}

			sticks := response.Data.translate()
			if !found || sticks.time().After(oldSticks.time()) {
				candlesticks[bin] = sticks
			}
		}
	}

	dragonex.Update(&ExchangeState{
		Price:        price,
		BaseVolume:   btcVolume,
		Volume:       volume,
		Change:       priceChange,
		Stamp:        data.Timestamp,
		Depth:        depth,
		Candlesticks: candlesticks,
	})
}
771987
func (c *Charm) Refresh() error {
	ch, err := c.st.Charm(c.doc.URL)
	if err != nil {
		return errors.Trace(err)
	}
	c.doc = ch.doc
	return nil
}
1274428
func (app *Application) Refresh() {
	ev := &eventAppRefresh{}
	ev.SetEventNow()
	if scr := app.screen; scr != nil {
		go func() { scr.PostEventWait(ev) }()
	}
}
623910
func (c *Cache) refresh(opts *RegisterOptions, attempt uint, t string, key string, r Request) {
	// Sanity-check, we should not schedule anything that has refresh disabled
	if !opts.Refresh {
		return
	}
	// Check if cache was stopped
	if atomic.LoadUint32(&c.stopped) == 1 {
		return
	}

	// If we're over the attempt minimum, start an exponential backoff.
	if wait := backOffWait(attempt); wait > 0 {
		time.Sleep(wait)
	}

	// If we have a timer, wait for it
	if opts.RefreshTimer > 0 {
		time.Sleep(opts.RefreshTimer)
	}

	// Trigger. The "allowNew" field is false because in the time we were
	// waiting to refresh we may have expired and got evicted. If that
	// happened, we don't want to create a new entry.
	c.fetch(t, key, r, false, attempt)
}
462678
func (t *Transport) Refresh() error {
	if t.Token == nil {
		return OAuthError{"Refresh", "no existing Token"}
	}
	if t.RefreshToken == "" {
		return OAuthError{"Refresh", "Token expired; no Refresh Token"}
	}
	if t.Config == nil {
		return OAuthError{"Refresh", "no Config supplied"}
	}

	err := t.updateToken(t.Token, url.Values{
		"grant_type":    {"refresh_token"},
		"refresh_token": {t.RefreshToken},
	})
	if err != nil {
		return err
	}
	if t.TokenCache != nil {
		return t.TokenCache.PutToken(t.Token)
	}
	return nil
}
426339
func (p *ChangePoller) Refresh(c context.Context) error {
	var meta config.Meta
	if err := cfgclient.Get(c, cfgclient.AsService, p.ConfigSet, p.Path, nil, &meta); err != nil {
		return errors.Annotate(err, "failed to reload config %s :: %s", p.ConfigSet, p.Path).Err()
	}

	p.ContentHash = meta.ContentHash
	return nil
}
789008
func (f *faucet) refresh(head *types.Header) error {
	// Ensure a state update does not run for too long
	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
	defer cancel()

	// If no header was specified, use the current chain head
	var err error
	if head == nil {
		if head, err = f.client.HeaderByNumber(ctx, nil); err != nil {
			return err
		}
	}
	// Retrieve the balance, nonce and gas price from the current head
	var (
		balance *big.Int
		nonce   uint64
		price   *big.Int
	)
	if balance, err = f.client.BalanceAt(ctx, f.account.Address, head.Number); err != nil {
		return err
	}
	if nonce, err = f.client.NonceAt(ctx, f.account.Address, head.Number); err != nil {
		return err
	}
	if price, err = f.client.SuggestGasPrice(ctx); err != nil {
		return err
	}
	// Everything succeeded, update the cached stats and eject old requests
	f.lock.Lock()
	f.head, f.balance = head, balance
	f.price, f.nonce = price, nonce
	for len(f.reqs) > 0 && f.reqs[0].Tx.Nonce() < f.nonce {
		f.reqs = f.reqs[1:]
	}
	f.lock.Unlock()

	return nil
}
807027
func (huobi *HuobiExchange) Refresh() {
	huobi.LogRequest()
	priceResponse := new(HuobiPriceResponse)
	err := huobi.fetch(huobi.requests.price, priceResponse)
	if err != nil {
		huobi.fail("Fetch", err)
		return
	}
	if priceResponse.Status != huobi.Ok {
		huobi.fail("Status not ok", fmt.Errorf("Expected status %s. Received %s", huobi.Ok, priceResponse.Status))
		return
	}
	baseVolume := priceResponse.Tick.Vol

	// Depth data
	var depth *DepthData
	depthResponse := new(HuobiDepthResponse)
	err = huobi.fetch(huobi.requests.depth, depthResponse)
	if err != nil {
		log.Errorf("Huobi depth chart fetch error: %v", err)
	} else if depthResponse.Status != huobi.Ok {
		log.Errorf("Huobi server depth response error. status: %s", depthResponse.Status)
	} else {
		depth = &DepthData{
			Time: depthResponse.Ts / 1000,
			Bids: depthResponse.Tick.Bids.translate(),
			Asks: depthResponse.Tick.Asks.translate(),
		}
	}

	// Candlestick data
	state := huobi.state()
	candlesticks := map[candlestickKey]Candlesticks{}
	for bin, req := range huobi.requests.candlesticks {
		oldSticks, found := state.Candlesticks[bin]
		if !found || oldSticks.needsUpdate(bin) {
			log.Tracef("Signalling candlestick update for %s, bin size %s", huobi.token, bin)
			response := new(HuobiCandlestickResponse)
			err := huobi.fetch(req, response)
			if err != nil {
				log.Errorf("Error retrieving candlestick data from huobi for bin size %s: %v", string(bin), err)
				continue
			}
			if response.Status != huobi.Ok {
				log.Errorf("Huobi server error while fetching candlestick data. status: %s", response.Status)
				continue
			}

			sticks := response.Data.translate()
			if !found || sticks.time().After(oldSticks.time()) {
				candlesticks[bin] = sticks
			}
		}
	}

	huobi.Update(&ExchangeState{
		Price:        priceResponse.Tick.Close,
		BaseVolume:   baseVolume,
		Volume:       baseVolume / priceResponse.Tick.Close,
		Change:       priceResponse.Tick.Close - priceResponse.Tick.Open,
		Stamp:        priceResponse.Ts / 1000,
		Depth:        depth,
		Candlesticks: candlesticks,
	})
}
443371
func (buf *Buffer) Refresh() error {
	// If we're not echoing just write prompt.
	if !buf.Echo {
		_, err := buf.Out.Write(mvLeftEdge)
		if err != nil {
			return err
		}

		_, err = buf.Out.Write([]byte(buf.Prompt))
		if err != nil {
			return err
		}

		_, err = buf.Out.Write(delRight)
		return err
	}

	prLen := len(buf.Prompt)
	start := 0
	size := buf.size
	pos := buf.pos

	// Get slice range that should be visible.
	for prLen+pos >= buf.Cols {
		start++
		size--
		pos--
	}
	for prLen+size > buf.Cols {
		size--
	}

	_, err := buf.Out.Write(mvLeftEdge)
	if err != nil {
		return err
	}

	_, err = buf.Out.Write([]byte(buf.Prompt))
	if err != nil {
		return err
	}

	_, err = buf.Out.Write(toBytes(buf.data[start : size+start]))
	if err != nil {
		return err
	}

	_, err = buf.Out.Write(delRight)
	if err != nil {
		return err
	}

	_, err = buf.Out.Write([]byte(fmt.Sprintf(mvToCol, pos+prLen)))
	return err
}
635168
func (c *oidcConnector) Refresh(ctx context.Context, s connector.Scopes, identity connector.Identity) (connector.Identity, error) {
	return identity, nil
}
198193
func (w *WalletState) Refresh(mctx libkb.MetaContext, accountID stellar1.AccountID, reason string) error {
	a, ok := w.accountState(accountID)
	if !ok {
		return ErrAccountNotFound
	}
	return a.Refresh(mctx, w.G().NotifyRouter, reason)
}
1374917
func (c *ConsoleClient) refresh() {
	// clear lines for incomplete downloads
	if c.inProgress > 0 {
		fmt.Printf("\033[%dA\033[K", c.inProgress)
	}

	// print newly completed downloads
	for i, resp := range c.responses {
		if resp != nil && resp.IsComplete() {
			if resp.Err() != nil {
				c.failed++
				fmt.Fprintf(os.Stderr, "Error downloading %s: %v\n",
					resp.Request.URL(),
					resp.Err())
			} else {
				c.succeeded++
				fmt.Printf("Finished %s %s / %s (%d%%)\n",
					resp.Filename,
					byteString(resp.BytesComplete()),
					byteString(resp.Size),
					int(100*resp.Progress()))
			}
			c.responses[i] = nil
		}
	}

	// print progress for incomplete downloads
	c.inProgress = 0
	for _, resp := range c.responses {
		if resp != nil {
			fmt.Printf("Downloading %s %s / %s (%d%%) - %s ETA: %s \033[K\n",
				resp.Filename,
				byteString(resp.BytesComplete()),
				byteString(resp.Size),
				int(100*resp.Progress()),
				bpsString(resp.BytesPerSecond()),
				etaString(resp.ETA()))
			c.inProgress++
		}
	}
}
122793
func (c *CloudService) Refresh() error {
	_, err := c.CloudService()
	return errors.Trace(err)
}
412633
func (u *User) Refresh() error {
	var udoc userDoc
	if err := u.st.getUser(u.Name(), &udoc); err != nil {
		return err
	}
	u.doc = udoc
	return nil
}
417986
func (c *TokenController) Refresh(ctx *app.RefreshTokenContext) error {
	// retrieve the access token if it exists (otherwise, a jwtrequest.ErrNoTokenInRequest is returned, but it can be ignored here)
	accessToken := goajwt.ContextJWT(ctx)
	refreshToken := ctx.Payload.RefreshToken
	if refreshToken == nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("refresh_token", nil).Expected("not nil"))
	}
	var t *manager.TokenSet
	var err error
	if accessToken != nil {
		t, err = c.app.TokenService().ExchangeRefreshToken(ctx, *refreshToken, accessToken.Raw)
	} else {
		t, err = c.app.TokenService().ExchangeRefreshToken(ctx, *refreshToken, "")
	}
	if err != nil {
		c.TokenManager.AddLoginRequiredHeaderToUnauthorizedError(err, ctx.ResponseData)
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	ctx.ResponseData.Header().Set("Cache-Control", "no-cache")
	return ctx.OK(convertToken(*t))
}
652529
func (s *Application) Refresh() error {
	life, err := s.st.life(s.tag)
	if err != nil {
		return err
	}
	s.life = life
	return nil
}