// ToWire translates ModuleID into a Thrift-level intermediate
// representation. This intermediate representation may be serialized
// into bytes using a ThriftRW protocol implementation.
778058
func (v ModuleID) ToWire() (wire.Value, error) {
	x := (int32)(v)
	return wire.NewValueI32(x), error(nil)
}
1374263
func (t *Module) AddDepend(modules ...*Module) *Module {
	t.Depend = append(t.Depend, modules...)
	return t
}
1177671
func (v *Module) String() string {
	if v == nil {
		return "<nil>"
	}

	var fields [3]string
	i := 0
	fields[i] = fmt.Sprintf("ImportPath: %v", v.ImportPath)
	i++
	fields[i] = fmt.Sprintf("Directory: %v", v.Directory)
	i++
	fields[i] = fmt.Sprintf("ThriftFilePath: %v", v.ThriftFilePath)
	i++

	return fmt.Sprintf("Module{%v}", strings.Join(fields[:i], ", "))
}
867944
func (m *Motto) Require(id, pwd string) (otto.Value, error) {
	if cache, ok := m.cachedModule(id); ok {
		return cache, nil
	}

	loader := m.module(id)
	if loader == nil {
		loader = Module(id)
	}

	if loader != nil {
		v, err := loader(m)
		if err != nil {
			return otto.UndefinedValue(), err
		}

		m.addCachedModule(id, v)
		return v, nil
	}

	filename, err := FindFileModule(id, pwd, append(m.paths, globalPaths...))
	if err != nil {
		return otto.UndefinedValue(), err
	}

	// resove id
	id = filename

	if cache, ok := m.cachedModule(id); ok {
		return cache, nil
	}

	v, err := CreateLoaderFromFile(id)(m)

	if err != nil {
		return otto.UndefinedValue(), err
	}

	m.addCachedModule(id, v)
	return v, nil
}
199914
func NewTrie(data []byte, payload interface{}) *TrieNode {
	return &TrieNode{
		suffix:      data,
		children:    []*TrieNode{},
		longestPath: len(data),
		PathLen:     len(data),
		Payload:     payload,
	}
}
241618
func (pm *ProtocolManager) getHelperTrieAuxData(req HelperTrieReq) []byte {
	if req.Type == htCanonical && req.AuxReq == auxHeader && len(req.Key) == 8 {
		blockNum := binary.BigEndian.Uint64(req.Key)
		hash := rawdb.ReadCanonicalHash(pm.chainDb, blockNum)
		return rawdb.ReadHeaderRLP(pm.chainDb, hash, blockNum)
	}
	return nil
}
390001
func ToEntry(w http.ResponseWriter, r *http.Request, api string, statusCode int, reqClaims map[string]interface{}) Entry {
	vars := mux.Vars(r)
	bucket := vars["bucket"]
	object := vars["object"]

	reqQuery := make(map[string]string)
	for k, v := range r.URL.Query() {
		reqQuery[k] = strings.Join(v, ",")
	}
	reqHeader := make(map[string]string)
	for k, v := range r.Header {
		reqHeader[k] = strings.Join(v, ",")
	}
	respHeader := make(map[string]string)
	for k, v := range w.Header() {
		respHeader[k] = strings.Join(v, ",")
	}
	respHeader["Etag"] = strings.Trim(respHeader["Etag"], `"`)

	entry := Entry{
		Version:      Version,
		DeploymentID: w.Header().Get("x-minio-deployment-id"),
		RemoteHost:   handlers.GetSourceIP(r),
		RequestID:    w.Header().Get("x-amz-request-id"),
		UserAgent:    r.UserAgent(),
		Time:         time.Now().UTC().Format(time.RFC3339Nano),
		ReqQuery:     reqQuery,
		ReqHeader:    reqHeader,
		ReqClaims:    reqClaims,
		RespHeader:   respHeader,
	}

	entry.API.Name = api
	entry.API.Bucket = bucket
	entry.API.Object = object
	entry.API.Status = http.StatusText(statusCode)
	entry.API.StatusCode = statusCode

	return entry
}
1026737
func (priv *PrivateKey) ToWIF() (wif string) {
	/* See https://en.bitcoin.it/wiki/Wallet_import_format */

	/* Convert the private key to bytes */
	priv_bytes := priv.ToBytes()

	/* Convert bytes to base-58 check encoded string with version 0x80 */
	wif = b58checkencode(0x80, priv_bytes)

	return wif
}
243463
func (m *ExpirationManager) persistEntry(ctx context.Context, le *leaseEntry) error {
	// Encode the entry
	buf, err := le.encode()
	if err != nil {
		return errwrap.Wrapf("failed to encode lease entry: {{err}}", err)
	}

	// Write out to the view
	ent := logical.StorageEntry{
		Key:   le.LeaseID,
		Value: buf,
	}
	if le.Auth != nil && len(le.Auth.Policies) == 1 && le.Auth.Policies[0] == "root" {
		ent.SealWrap = true
	}

	view := m.leaseView(le.namespace)
	if err := view.Put(ctx, &ent); err != nil {
		return errwrap.Wrapf("failed to persist lease entry: {{err}}", err)
	}
	return nil
}
42488
func (a *api) DockerOverride(newImage string, oldImage string) error {
	client, err := a.connectMaster()
	if err != nil {
		return err
	}
	return client.DockerOverride(newImage, oldImage)
}
245994
func ToWriteCloser(w io.Writer) io.WriteCloser {
	if rw, ok := w.(io.WriteCloser); ok {
		return rw
	}

	return struct {
		io.Writer
		io.Closer
	}{
		w,
		ioutil.NopCloser(nil),
	}
}
985663
func (api *PublicEthereumAPI) ChainId() hexutil.Uint64 {
	chainID := new(big.Int)
	if config := api.e.blockchain.Config(); config.IsEIP155(api.e.blockchain.CurrentBlock().Number()) {
		chainID = config.ChainID
	}
	return (hexutil.Uint64)(chainID.Uint64())
}
1249282
func (inode *Inode) DeRef(n uint64) (stale bool) {
	inode.logFuse("DeRef", n, inode.refcnt)

	if inode.refcnt < n {
		panic(fmt.Sprintf("deref %v from %v", n, inode.refcnt))
	}

	inode.refcnt -= n

	stale = (inode.refcnt == 0)
	return
}
1273327
func (s *Restore) ConfigEntry(c structs.ConfigEntry) error {
	// Insert
	if err := s.tx.Insert(configTableName, c); err != nil {
		return fmt.Errorf("failed restoring config entry object: %s", err)
	}
	if err := indexUpdateMaxTxn(s.tx, c.GetRaftIndex().ModifyIndex, configTableName); err != nil {
		return fmt.Errorf("failed updating index: %s", err)
	}

	return nil
}
616660
func (d *Dictionary) Iterator() segment.DictionaryIterator {
	rv := &DictionaryIterator{
		d: d,
	}

	if d.fst != nil {
		itr, err := d.fst.Iterator(nil, nil)
		if err == nil {
			rv.itr = itr
		} else if err != vellum.ErrIteratorDone {
			rv.err = err
		}
	}

	return rv
}
298828
func ToWire(mb *state.MetricBatch, modelName string) *wireformat.MetricBatch {
	metrics := make([]wireformat.Metric, len(mb.Metrics()))
	for i, m := range mb.Metrics() {
		metrics[i] = wireformat.Metric{
			Key:    m.Key,
			Value:  m.Value,
			Time:   m.Time.UTC(),
			Labels: m.Labels,
		}
	}
	return &wireformat.MetricBatch{
		UUID:           mb.UUID(),
		ModelUUID:      mb.ModelUUID(),
		ModelName:      modelName,
		UnitName:       mb.Unit(),
		CharmUrl:       mb.CharmURL(),
		Created:        mb.Created().UTC(),
		Metrics:        metrics,
		Credentials:    mb.Credentials(),
		SLACredentials: mb.SLACredentials(),
	}
}
753880
func (u *User) IDForProvider(provider string) string {
	id := u.ProviderCredentials()[provider].Get(common.CredentialsKeyID).Data()
	switch id.(type) {
	case string:
		return id.(string)
	case float64:
		return strconv.FormatFloat(id.(float64), 'f', 0, 64)
	}
	return ""
}