id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c27100 | dbm.DBBackendType(ctx.Config.DBBackend), ctx.Config.DBDir())
n.closers = append(n.closers, db)
return db, nil
} | |
c27101 |
log = kitlevel.NewFilter(log, kitlevel.AllowInfo()) // info + warn + error logs
case "debug":
log = kitlevel.NewFilter(log, kitlevel.AllowDebug()) // all logs
default:
log = kitlevel.NewFilter(log, kitlevel.AllowNone()) // no logs
}
log = kitlog.With(log, "service", "vent")
log = kitlog.With(log, "ts", kit... | |
c27102 | kitlevel.Error(l.Log).Log(args...)
} | |
c27103 | kitlevel.Warn(l.Log).Log(args...)
} | |
c27104 | kitlevel.Info(l.Log).Log(args...)
} | |
c27105 | kitlevel.Debug(l.Log).Log(args...)
} | |
c27106 | err != nil {
return
}
} else {
address = *ta.Address
}
// Get the (possibly existing) key
pubKey, err = keyClient.PublicKey(address)
if err != nil {
return
}
} else {
address = (*ta.PublicKey).GetAddress()
if ta.Address != nil && *ta.Address != address {
err = fmt.Errorf("template addr... | |
c27107 | := executor.Execute(txEnv)
if err != nil {
ex := errors.AsException(err)
return types.ResponseCheckTx{
Code: codes.TxExecutionErrorCode,
Tags: tags,
Log: logf("Could not execute transaction: %s, error: %v", txEnv, ex.Exception),
}
}
if txe.Receipt.CreatesContract {
tags = append(tags, common.KVPa... | |
c27108 |
keyvals[i] = string(kvp.Key)
keyvals[i+1] = string(kvp.Value)
}
return logger.With(keyvals...)
} | |
c27109 |
values, err := jsonParamsToArgs(rpcFunc, params, 1)
if err != nil {
return nil, err
}
return append([]reflect.Value{reflect.ValueOf(wsCtx)}, values...), nil
} | |
c27110 | CheckOrigin: func(r *http.Request) bool {
// TODO ???
return true
},
},
logger: logger,
wsConnOptions: wsConnOptions,
}
} | |
c27111 | {
if lsi.SignBytes != nil {
if lsi.Signature == nil {
panic("pv: Signature is nil but SignBytes is not!")
}
return true, nil
}
return false, errors.New("No Signature found")
}
}
}
return false, nil
} | |
c27112 | LR:%v, LS:%v}", lsi.Height, lsi.Round, lsi.Step)
} | |
c27113 | instanceName := strings.ToLower(contract.Name[:1]) + contract.Name[1:]
if instanceName == contract.Name {
return "contractInstance"
}
return instanceName
} | |
c27114 |
err := contractTemplate.Execute(buf, contract)
if err != nil {
return "", err
}
return buf.String(), nil
} | |
c27115 | " ", "\t", "")
return replacer.Replace(parameter)
} | |
c27116 | := <-cl.ch.Out()
return readLogLine(logLine, ok)
} | |
c27117 | readLogLine(logLine, ok)
default:
return nil
}
} | |
c27118 | != nil; logLine = cl.WaitReadLogLine() {
err := logger.Log(logLine...)
if err != nil && errCh != nil {
errCh.In() <- err
}
}
} | |
c27119 |
logLine := cl.WaitReadLogLine()
if logLine != nil {
err := logger.Log(logLine...)
if err != nil {
errs = append(errs, err)
}
}
}
return errors.CombineErrors(errs)
} | |
c27120 | {
logLines = append(logLines, keyvals)
return nil
}))
return logLines
} | |
c27121 | cl.ch = channels.NewRingChannel(cl.ch.Cap())
} | |
c27122 |
errCh := channels.NewRingChannel(cl.BufferCap())
go cl.DrainForever(outputLogger, errCh)
return cl, errCh
} | |
c27123 | DefaultValidatorsWindowSize)
rs := ReadState{Forest: forest, History: ring}
ws := writeState{forest: forest, ring: ring}
return &State{
db: db,
ReadState: rs,
writeState: ws,
logger: logging.NewNoopLogger(),
}
} | |
c27124 | included in the accounts tree
globalPerms := permission.DefaultAccountPermissions
globalPerms = genesisDoc.GlobalPermissions
// XXX: make sure the set bits are all true
// Without it the HasPermission() functions will fail
globalPerms.Base.SetBit = permission.AllPermFlags
permsAcc := &acm.Account{
Address: ... | |
c27125 |
if err != nil {
return nil, 0, err
}
return s.commit()
} | |
c27126 | if err != nil {
return err
}
return tree.IterateWriteTree(nil, nil, true, func(key []byte, value []byte) error {
treeCopy.Set(key, value)
return nil
})
})
if err != nil {
return nil, err
}
_, _, err = stateCopy.commit()
if err != nil {
return nil, err
}
return stateCopy, nil
} | |
c27127 | }
// IMPORTANT: DO NOT CHANGE TABLE CREATION ORDER (2)
if err = db.createTable(sysTables[types.SQLLogTableName], true); err != nil {
if !db.DBAdapter.ErrorEquals(err, types.SQLErrorTypeDuplicatedTable) {
db.Log.Info("msg", "Error creating Log table", "err", err)
return nil, err
}
}
// IMPORTANT: DO NOT... | |
c27128 | err != nil {
db.Log.Error("msg", "Error closing database", "err", err)
}
} | |
c27129 | err
}
height, err := strconv.ParseUint(id, 10, 64)
if err != nil {
return 0, fmt.Errorf("could not parse height from block ID: %v", err)
}
return height, nil
} | |
c27130 |
if found {
err = db.alterTable(table)
} else {
err = db.createTable(table, false)
}
if err != nil {
return err
}
}
return nil
} | |
c27131 | }
// for each row in table
var dataRows []types.EventDataRow
for rows.Next() {
row := make(map[string]interface{})
if err = rows.Scan(pointers...); err != nil {
db.Log.Info("msg", "Error scanning data", "err", err)
return data, err
}
db.Log.Info("msg", "Query resultset", "value", fmt.Spri... | |
c27132 | err = rows.Err(); err != nil {
db.Log.Info("msg", "error scanning table structure", "err", err)
return err
}
restoreTable := fmt.Sprintf("%s_%s", prefix, tableName)
switch action {
case types.ActionUpsert, types.ActionDelete:
// get row values
if pointers, err = db.getValuesFromJSON(sqlValues); e... | |
c27133 | (KVCallbackIterableReader, error) {
return imf.tree(prefix)
} | |
c27134 | {
return value.(*RWTree), nil
}
// Not in caches but non-negative version - we should be able to load into memory
return imf.loadOrCreateTree(prefix)
} | |
c27135 | p), imf.cacheSize)
imf.treeCache.Add(p, tree)
return tree
} | |
c27136 | case lb:
start = i + 1
case rb:
return `\$` + str[start:i]
}
}
return str[start:]
} | |
c27137 | := validation.LengthOfValue(value)
if err == nil && length == 0 {
return true
}
return false
} | |
c27138 | {
return fmt.Errorf("Error asserting directory %s: %v", dir, err)
} else if !fileOptions.IsDir() {
return fmt.Errorf("Path already exists as a file: %s", dir)
}
return nil
} | |
c27139 | return false
}
return fileInfo.IsDir()
} | |
c27140 |
if err != nil {
return errors.Wrap(err, "could not create monax key json").Error()
}
return string(bs)
} | |
c27141 |
panic(fmt.Errorf("function with ID %x already defined: %s", fid, otherF.Signature()))
}
functionsByID[fid] = f
}
return &SNativeContractDescription{
Comment: comment,
Name: name,
functionsByID: functionsByID,
functions: functions,
}
} | |
c27142 | nil {
return nil, err
}
logger.TraceMsg("Dispatching to function",
"caller", caller,
"function_name", function.Name)
remainingArgs := args[abi.FunctionIDSize:]
// check if we have permission to call this function
if !HasPermission(st, caller, function.PermFlag) {
return nil, errors.LacksSNativePermissi... | |
c27143 | sha3.Sha3([]byte(contract.Name))
copy(address[:], hash[len(hash)-crypto.AddressLength:])
return
} | |
c27144 |
f, ok := contract.functionsByID[id]
if !ok {
return nil,
errors.ErrorCodef(errors.ErrorCodeNativeFunction, "unknown SNative function with ID %x", id)
}
return f, nil
} | |
c27145 | return f, nil
}
}
return nil, fmt.Errorf("unknown SNative function with name %s", name)
} | |
c27146 | len(contract.functions))
copy(functions, contract.functions)
return functions
} | |
c27147 | argTypeNames[i] = arg.EVM.GetSignature()
}
return fmt.Sprintf("%s(%s)", function.Name,
strings.Join(argTypeNames, ","))
} | |
c27148 | // Store reference to key-holder amongst Taggeds
ct.ks[k] = append(ct.ks[k], t)
} else if concat {
// Store additional tag reference only if concat, otherwise first key-holder wins
ct.ks[k] = append(ct.ks[k], t)
}
}
}
} | |
c27149 |
from: cs.from,
apply: cs.apply,
}
} | |
c27150 |
// Skip if config file does not exist at default location
skip = os.IsNotExist(err)
}
return &configSource{
skip: skip,
from: fmt.Sprintf("XDG base dir"),
apply: func(baseConfig interface{}) error {
if err != nil {
return err
}
return FromFile(configFile, baseConfig)
},
}
} | |
c27151 |
apply: func(baseConfig interface{}) error {
return FromString(configString, baseConfig)
},
}
} | |
c27152 | // Perform a merge into that value to effect the copy
err := mergo.Merge(confCopy, conf)
if err != nil {
return nil, err
}
return confCopy, nil
} | |
c27153 | err != nil {
return nil, errors.Wrap(err, "Error unmarshalling eventSpec")
}
return NewProjectionFromEventSpec(eventSpec)
} | |
c27154 | fileEventSpec := types.EventSpec{}
err = json.Unmarshal(bs, &fileEventSpec)
if err != nil {
return fmt.Errorf("error reading spec file '%s': %v", path, err)
}
eventSpec = append(eventSpec, fileEventSpec...)
}
return nil
})
if err != nil {
return nil, fmt.Errorf("%s %v", errHeader, e... | |
c27155 | {
return nil, err
}
i++
// Update channels broadcast payload subsets with this column
for _, channel := range mapping.Notify {
channels[channel] = append(channels[channel], mapping.ColumnName)
}
columns = append(columns, &types.SQLTableColumn{
Name: mapping.ColumnName,
Type: ... | |
c27156 | '%s'",
tableName, columnName)
}
return column, nil
}
return nil, fmt.Errorf("GetColumn: table does not exist projection: %s ", tableName)
} | |
c27157 | byteValue, err := ioutil.ReadAll(theFile)
if err != nil {
return nil, err
}
return byteValue, nil
} | |
c27158 | typeSize == 0 || typeSize == 256 {
return types.SQLColumnTypeBigInt, 0, nil
}
if typeSize <= 32 {
return types.SQLColumnTypeInt, 0, nil
} else {
return types.SQLColumnTypeNumeric, 0, nil
}
// solidity uint or uint256 => sql bigint
// solidity uint <= 16 => sql int
// solidity uint > 16 => sql nu... | |
c27159 | types.EventTypeLabel,
Type: types.EventFieldTypeString,
},
{
ColumnName: types.SQLColumnLabelEventName,
Field: types.EventNameLabel,
Type: types.EventFieldTypeString,
},
}
} | |
c27160 | copy(accCopy.Permissions.Roles, acc.Permissions.Roles)
return &accCopy
} | |
c27161 | i)
if err != nil {
return nil, fmt.Errorf("could not create Account from template: %v", err)
}
genesisDoc.Accounts = append(genesisDoc.Accounts, *account)
if templateAccount.Balances().HasPower() {
// Note this does not modify the input template
templateAccount.Address = &account.Address
validator... | |
c27162 |
vs.ChangePower(id, power)
return nil
} | |
c27163 |
delete(vs.powers, address)
} else {
vs.publicKeys[address] = crypto.NewAddressable(id)
vs.powers[address] = new(big.Int).Set(power)
}
return flow
} | |
c27164 | new(big.Int).Sub(power, vs.GetPower(id.GetAddress()))
} | |
c27165 |
}
return new(big.Int).Set(vs.powers[id])
} | |
c27166 | return vs.GetPower(id), nil
} | |
c27167 | non-matching validator
return vs.IterateValidators(func(id crypto.Addressable, power *big.Int) error {
otherPower := vsOther.GetPower(id.GetAddress())
if otherPower.Cmp(power) != 0 {
return fmt.Errorf("set power %d != other set power %d", power, otherPower)
}
return nil
})
} | |
c27168 | for _, address := range addresses {
err := iter(vs.publicKeys[address], new(big.Int).Set(vs.powers[address]))
if err != nil {
return err
}
}
return nil
} | |
c27169 | br.GetStart().Bound(latestBlockHeight), br.GetEnd().Bound(latestBlockHeight) + 1,
br.GetEnd().GetType() == Bound_STREAM
} | |
c27170 | Id: id,
Method: method,
Params: params,
}
} | |
c27171 | Result: res,
Id: id,
JSONRPC: "2.0",
})
} | |
c27172 | return RPCResponse(&RPCErrorResponse{
Error: &RPCError{code, message},
Id: id,
JSONRPC: "2.0",
})
} | |
c27173 | iterators,
iteratorOrder: make(map[KVIterator]int),
lessComp: lessComp,
}
mi.init()
return mi
} | |
c27174 | go func() {
for err != nil {
err = localKeyClient.HealthCheck()
}
aliveCh <- struct{}{}
}()
select {
case <-time.After(keysTimeout):
return nil, fmt.Errorf("keys instance did not become responsive after %s: %v", keysTimeout, err)
case <-aliveCh:
return &LocalKeyClient{localKeyClient}, nil
}
} | |
c27175 | low = []byte{}
}
return low, high
} | |
c27176 | if ko1 < ko2 {
return -1
}
if ko1 > ko2 {
return 1
}
return bytes.Compare(k1, k2)
} | |
c27177 |
callState.PushError(vm.ensureStackDepth())
// Early exit
if callState.Error() != nil {
return
}
if len(code) > 0 {
vm.stackDepth += 1
output = vm.execute(callState, eventSink, caller, callee, code, input, value, gas)
vm.stackDepth -= 1
}
return
} | |
c27178 |
} else {
err.PushError(errors.ErrorCodeInsufficientGas)
}
} | |
c27179 | := "callee-none"
if callee != crypto.ZeroAddress {
calleeString = fmt.Sprintf("callee-%v", caller)
}
ioutil.WriteFile(fmt.Sprintf("tokens_%s_%s_%s.asm", txHashString, callerString, calleeString),
[]byte(tokensString), 0777)
} | |
c27180 |
for i := 0; i < n; i++ {
accounts[i] = acm.GeneratePrivateAccountFromSecret("mysecret" + strconv.Itoa(i))
}
return accounts
} | |
c27181 | &PostgresAdapter{
Log: log,
Schema: schema,
}
} | |
c27182 | '%s');`, adapter.Schema)
adapter.Log.Info("msg", "FIND SCHEMA", "query", query)
if err := db.QueryRow(query).Scan(&found); err == nil {
if !found {
adapter.Log.Warn("msg", "Schema not found")
}
adapter.Log.Info("msg", "Creating schema")
query = Cleanf("CREATE SCHEMA %s;", adapter.Schema)
adapt... | |
c27183 | query := Cleanf("CREATE TABLE %s.%s (%s", adapter.Schema, adapter.SecureName(tableName), columnsDef)
if primaryKey != "" {
query += "," + Cleanf("CONSTRAINT %s_pkey PRIMARY KEY (%s)", tableName, primaryKey)
}
query += ");"
dictionaryQuery := Cleanf("INSERT INTO %s.%s (%s,%s,%s,%s,%s,%s) VALUES %s;",
adapter.S... | |
c27184 |
adapter.Schema, types.SQLDictionaryTableName, // from
types.SQLColumnLabelTableName, // where
types.SQLColumnLabelColumnOrder) // order by
} | |
c27185 | types.SQLColumnLabelEventName, types.SQLColumnLabelEventFilter,
types.SQLColumnLabelHeight, types.SQLColumnLabelTxHash, types.SQLColumnLabelAction, types.SQLColumnLabelDataRow,
types.SQLColumnLabelSqlStmt, types.SQLColumnLabelSqlValues)
} | |
c27186 | make(chan struct{}),
txDecoder: txDecoder,
panic: panicFunc,
}
if commitInterval != 0 {
p.ticker = time.NewTicker(commitInterval)
go p.triggerCommits()
}
return p
} | |
c27187 | := tx.Enclose()
err := env.Sign(signingAccounts...)
if err != nil {
return nil, err
}
tx.Rehash()
return env, nil
} | |
c27188 | err != nil {
panic(err)
}
return bs
} | |
c27189 | = callTx.Address == nil
if receipt.CreatesContract {
receipt.ContractAddress = crypto.NewContractAddress(callTx.Input.Address, tx.Hash())
} else {
receipt.ContractAddress = *callTx.Address
}
}
return receipt
} | |
c27190 |
if structure.Signal(keyvals) != "" || !predicate(keyvals) {
return outputLogger.Log(keyvals...)
}
return nil
})
} | |
c27191 | keys server", "server", c.KeysClientAddress)
c.keyClient, err = keys.NewRemoteKeyClient(c.KeysClientAddress, logger)
}
if err != nil {
return err
}
ctx, cancel := context.WithTimeout(context.Background(), c.timeout)
defer cancel()
stat, err := c.queryClient.Status(ctx, &rpcquery.StatusParam{})
if... | |
c27192 | err != nil {
return crypto.PublicKey{}, err
}
}
address, err := c.keyClient.Generate(keyName, curveType)
if err != nil {
return crypto.PublicKey{}, err
}
return c.keyClient.PublicKey(address)
} | |
c27193 |
return nil, err
}
ctx, cancel := context.WithTimeout(context.Background(), c.timeout)
defer cancel()
return c.transactClient.BroadcastTxSync(ctx, &rpctransact.TxEnvelopeParam{Payload: tx.Any()})
} | |
c27194 | {
return nil, err
}
ctx, cancel := context.WithTimeout(context.Background(), c.timeout)
defer cancel()
return c.transactClient.BroadcastTxSync(ctx, &rpctransact.TxEnvelopeParam{Envelope: txEnv})
} | |
c27195 | commit immediately
accounts := execution.NewAccounts(kern.committer, kern.keyClient, AccountsRingMutexCount)
// Elide consensus and use a CheckTx function that immediately commits any valid transaction
kern.Transactor = execution.NewTransactor(kern.Blockchain, kern.Emitter, accounts, proc.CheckTx, kern.txCode... | |
c27196 | make([]AddressableSigner, len(concretePrivateAccounts))
for i, cpa := range concretePrivateAccounts {
signingAccounts[i] = cpa
}
return signingAccounts
} | |
c27197 | Address: publicKey.GetAddress(),
PublicKey: publicKey,
PrivateKey: privateKey,
}.PrivateAccount(), nil
} | |
c27198 | Address: publicKey.GetAddress(),
PublicKey: publicKey,
PrivateKey: privateKey,
}.PrivateAccount()
} | |
c27199 | solidity, err := templates.NewSolidityContract(contract).Solidity()
if err != nil {
fmt.Printf("Error generating solidity for contract %s: %s\n",
contract.Name, err)
}
fmt.Println(solidity)
if i < len(contracts) {
// Two new lines between contracts as per Solidity style guide
// (... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.