code: 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
  }
docs: // refresh attempts to retrieve the latest header from the chain and extract the
  // associated faucet balance and nonce for connectivity caching.