id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c17200
//This is kind of a rough hack to replace the old []byte //detection with reflect.Uint8Type, it doesn't catch //zero-length byte slices case reflect.Slice: typ := v.Type() if typ.Elem().Kind() == reflect.Uint || typ.Elem().Kind() == reflect.Uint8 || typ.Elem().Kind() == reflect.Uint16 || ty...
c17201
client.sendCommand("PUBLISH", channel, string(val)) if err != nil { return err } return nil }
c17202
sha256.New() h.Write(data) return h.Sum(nil) }
c17203
return o.EncryptBytesWithSaltAndDigestFunc(passphrase, salt, plainData, kdf) }
c17204
} return o.EncryptBinaryBytesWithSaltAndDigestFunc(passphrase, salt, plainData, kdf) }
c17205
if err != nil { panic(err) } return s }
c17206
%d", len(data)) } padlen := int(data[len(data)-1]) if padlen > blocklen || padlen == 0 { return nil, fmt.Errorf("invalid padding") } pad := data[len(data)-padlen:] for i := 0; i < padlen; i++ { if pad[i] != byte(padlen) { return nil, fmt.Errorf("invalid padding") } } return data[:len(data)-padlen], ni...
c17207
uintptr(ns), uintptr(nstype), 0) if e1 != 0 { err = e1 } return }
c17208
nil { return -1, err } return Get() }
c17209
syscall.O_RDONLY, 0) if err != nil { return -1, err } return NsHandle(fd), nil }
c17210
{ return GetFromPath(fmt.Sprintf("/proc/%d/task/%d/ns/net", pid, tid)) }
c17211
return -1, err } return GetFromPid(pid) }
c17212
err != nil { return false } if err := syscall.Fstat(int(other), &s2); err != nil { return false } return (s1.Dev == s2.Dev) && (s1.Ino == s2.Ino) }
c17213
return fmt.Sprintf("NS(%d: unknown)", ns) } return fmt.Sprintf("NS(%d: %d, %d)", ns, s.Dev, s.Ino) }
c17214
if err != nil { return 0, err } return int(i), nil }
c17215
fmt.Sscan(value, &i) return i, err }
c17216
"0x" + strings.TrimPrefix(fmt.Sprintf("%x", bigInt.Bytes()), "0") }
c17217
!= nil { params["value"] = BigToHex(*t.Value) } if t.Data != "" { params["data"] = t.Data } if t.Nonce > 0 { params["nonce"] = IntToHex(t.Nonce) } return json.Marshal(params) }
c17218
log.LstdFlags), } for _, option := range options { option(rpc) } return rpc }
c17219
return New(url, options...) }
c17220
nil { return nil, err } if rpc.Debug { rpc.log.Println(fmt.Sprintf("%s\nRequest: %s\nResponse: %s\n", method, body, data)) } resp := new(ethResponse) if err := json.Unmarshal(data, resp); err != nil { return nil, err } if resp.Error != nil { return nil, *resp.Error } return resp.Result, nil }
c17221
:= rpc.call("web3_clientVersion", &clientVersion) return clientVersion, err }
c17222
err := rpc.call("net_version", &version) return version, err }
c17223
:= rpc.call("net_listening", &listening) return listening, err }
c17224
:= rpc.call("eth_protocolVersion", &protocolVersion) return protocolVersion, err }
c17225
if bytes.Equal(result, []byte("false")) { return syncing, nil } err = json.Unmarshal(result, syncing) return syncing, err }
c17226
err := rpc.call("eth_coinbase", &address) return address, err }
c17227
err := rpc.call("eth_mining", &mining) return mining, err }
c17228
return big.Int{}, err } return ParseBigInt(response) }
c17229
err := rpc.call("eth_accounts", &accounts) return accounts, err }
c17230
err != nil { return 0, err } return ParseInt(response) }
c17231
if err := rpc.call("eth_getBalance", &response, address, block); err != nil { return big.Int{}, err } return ParseBigInt(response) }
c17232
rpc.call("eth_getStorageAt", &result, data, IntToHex(position), tag) return result, err }
c17233
if err := rpc.call("eth_getTransactionCount", &response, address, block); err != nil { return 0, err } return ParseInt(response) }
c17234
:= rpc.call("eth_getBlockTransactionCountByHash", &response, hash); err != nil { return 0, err } return ParseInt(response) }
c17235
if err := rpc.call("eth_getBlockTransactionCountByNumber", &response, IntToHex(number)); err != nil { return 0, err } return ParseInt(response) }
c17236
rpc.call("eth_getCode", &code, address, block) return code, err }
c17237
rpc.call("eth_sendTransaction", &hash, transaction) return hash, err }
c17238
rpc.call("eth_sendRawTransaction", &hash, data) return hash, err }
c17239
rpc.call("eth_call", &data, transaction, tag) return data, err }
c17240
err := rpc.call("eth_estimateGas", &response, transaction) if err != nil { return 0, err } return ParseInt(response) }
c17241
return rpc.getBlock("eth_getBlockByHash", withTransactions, hash, withTransactions) }
c17242
rpc.getBlock("eth_getBlockByNumber", withTransactions, IntToHex(number), withTransactions) }
c17243
rpc.getTransaction("eth_getTransactionByHash", hash) }
c17244
return rpc.getTransaction("eth_getTransactionByBlockHashAndIndex", blockHash, IntToHex(transactionIndex)) }
c17245
rpc.getTransaction("eth_getTransactionByBlockNumberAndIndex", IntToHex(blockNumber), IntToHex(transactionIndex)) }
c17246
rpc.call("eth_getTransactionReceipt", transactionReceipt, hash) if err != nil { return nil, err } return transactionReceipt, nil }
c17247
err := rpc.call("eth_getCompilers", &compilers) return compilers, err }
c17248
{ var filterID string err := rpc.call("eth_newFilter", &filterID, params) return filterID, err }
c17249
:= rpc.call("eth_newBlockFilter", &filterID) return filterID, err }
c17250
err := rpc.call("eth_newPendingTransactionFilter", &filterID) return filterID, err }
c17251
{ var res bool err := rpc.call("eth_uninstallFilter", &res, filterID) return res, err }
c17252
rpc.call("eth_getFilterChanges", &logs, filterID) return logs, err }
c17253
rpc.call("eth_getLogs", &logs, params) return logs, err }
c17254
func(rpc *EthRPC) { rpc.client = client } }
c17255
*EthRPC) { rpc.log = l } }
c17256
*EthRPC) { rpc.Debug = enabled } }
c17257
CommandLine.long(v, "", short, helpvalue...) }
c17258
return CommandLine.long(v, long, short, helpvalue...) }
c17259
return s.long(v, "", short, helpvalue...) }
c17260
if g, ok := v.(*generic); ok { return g.p } return nil }
c17261
CommandLine.Uint64(name, value, helpvalue...) }
c17262
CommandLine.List(name, helpvalue...) }
c17263
CommandLine.ListVar(p, name, helpvalue...) }
c17264
CommandLine.VarLong(p, "", name, helpvalue...) }
c17265
CommandLine.Uint16(name, value, helpvalue...) }
c17266
[]string{} CommandLine.Flag(&p, name, helpvalue...) return &p }
c17267
CommandLine.Int32(name, value, helpvalue...) }
c17268
CommandLine.Int(name, value, helpvalue...) }
c17269
CommandLine.Int16(name, value, helpvalue...) }
c17270
CommandLine.Int64(name, value, helpvalue...) }
c17271
CommandLine.Uint(name, value, helpvalue...) }
c17272
CommandLine.Uint32(name, value, helpvalue...) }
c17273
parts = append(parts, s.parameters) } fmt.Fprintln(w, strings.Join(parts, " ")) s.PrintOptions(w) }
c17274
if flags != "" { opts = append(opts, "-"+flags) } // Now append all the long options and options that require // values. for _, opt := range s.options { if opt.flag { if opt.short != 0 { continue } flags = "--" + opt.long } else if opt.short != 0 { flags = "-" + string(opt.short) + " " + opt...
c17275
0 { a = append(a, s) } return a } x := max for s[x] != ' ' { // the first word is too long?! if x == 0 { x = max for x < len(s) && s[x] != ' ' { x++ } if x == len(s) { x-- } break } x-- } for s[x] == ' ' { x-- } a = append(a, s[:x+1]) s = s[x+1...
c17276
nil); err != nil { fmt.Fprintln(stderr, err) s.usage() exit(1) } }
c17277
append(opts, "-"+flags) } // Now append all the long options and options that require // values. for _, opt := range s.options { if opt.flag { if opt.short != 0 { continue } flags = "--" + opt.long } else if opt.short != 0 { flags = "-" + string(opt.short) + " " + opt.name } else { flags ...
c17278
make(map[string]*option), parameters: "[parameters ...]", } s.usage = func() { s.PrintUsage(stderr) } return s }
c17279
for _, opt := range s.options { if opt.count > 0 { fn(opt) } } }
c17280
:= range s.options { fn(opt) } }
c17281
CommandLine.String(name, value, helpvalue...) }
c17282
".") if y < 0 { return } // thisPackage includes the trailing . after the package name. thisPackage = thisPackage[:x+y+1] }
c17283
{ f := runtime.FuncForPC(pc) if f != nil && strings.HasPrefix(f.Name(), thisPackage) { continue } } return fmt.Sprintf("%s:%d", file, line) } }
c17284
if n == '-' { i.Name = "-" } else { i.Name = "-" + string(n) } case string: i.Name = "--" + n } i.Err = fmt.Errorf("unknown option: %s", i.Name) return i }
c17285
fmt.Errorf("missing parameter for %s", o.Name()), } }
c17286
fmt.Errorf("unexpected parameter passed to %s: %q", o.Name(), value), } }
c17287
o.Name(), Parameter: value, Err: err, } }
c17288
CommandLine.Enum(name, values, helpvalue...) }
c17289
*time.Duration { CommandLine.FlagLong(&value, "", name, helpvalue...) return &value }
c17290
!= 0 { return string(o.short) + o.long } return o.long[:1] + o.long }
c17291
= false o.count = 0 o.value.Set(o.defval, o) }
c17292
fmt.Fprintf(stderr, "%s: --%s already declared at %s\n", opt.where, opt.long, oo.where) exit(1) } s.longOptions[opt.long] = opt } s.options = append(s.options, opt) }
c17293
*Options) { o.TTL = t } }
c17294
} // time since ttl is longer than timeout if time.Since(ttl) > c.opts.TTL { return false } // ok return true }
c17295
copy endpoints var eps []*registry.Endpoint for _, ep := range service.Endpoints { e := new(registry.Endpoint) *e = *ep eps = append(eps, e) } s.Endpoints = eps // append service services = append(services, s) } return services }
c17296
a = 0 } time.Sleep(d) a++ continue } // reset a a = 0 // watch for events if err := c.watch(w); err != nil { if c.quit() { return } d := backoff(b) if b > 3 { log.Log("rcache: ", err, " backing off ", d) b = 0 } time.Sleep(d) b++ continue } // re...
c17297
{ res, err := w.Next() if err != nil { return err } c.update(res) } }
c17298
options, watched: make(map[string]bool), cache: make(map[string][]*registry.Service), ttls: make(map[string]time.Time), exit: make(chan bool), } }
c17299
c.ListAppEventsByQuery(eventType, nil) }