mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
*: enforce camel case variable names
This commit is contained in:
parent
41597c2856
commit
b6233e2e35
27 changed files with 206 additions and 206 deletions
|
|
@ -59,31 +59,31 @@ var (
|
|||
|
||||
//constants for environment variables
|
||||
const (
|
||||
SWARM_ENV_CHEQUEBOOK_ADDR = "SWARM_CHEQUEBOOK_ADDR"
|
||||
SWARM_ENV_ACCOUNT = "SWARM_ACCOUNT"
|
||||
SWARM_ENV_LISTEN_ADDR = "SWARM_LISTEN_ADDR"
|
||||
SWARM_ENV_PORT = "SWARM_PORT"
|
||||
SWARM_ENV_NETWORK_ID = "SWARM_NETWORK_ID"
|
||||
SWARM_ENV_SWAP_ENABLE = "SWARM_SWAP_ENABLE"
|
||||
SWARM_ENV_SWAP_API = "SWARM_SWAP_API"
|
||||
SWARM_ENV_SYNC_DISABLE = "SWARM_SYNC_DISABLE"
|
||||
SWARM_ENV_SYNC_UPDATE_DELAY = "SWARM_ENV_SYNC_UPDATE_DELAY"
|
||||
SWARM_ENV_MAX_STREAM_PEER_SERVERS = "SWARM_ENV_MAX_STREAM_PEER_SERVERS"
|
||||
SWARM_ENV_LIGHT_NODE_ENABLE = "SWARM_LIGHT_NODE_ENABLE"
|
||||
SWARM_ENV_DELIVERY_SKIP_CHECK = "SWARM_DELIVERY_SKIP_CHECK"
|
||||
SWARM_ENV_ENS_API = "SWARM_ENS_API"
|
||||
SWARM_ENV_ENS_ADDR = "SWARM_ENS_ADDR"
|
||||
SWARM_ENV_CORS = "SWARM_CORS"
|
||||
SWARM_ENV_BOOTNODES = "SWARM_BOOTNODES"
|
||||
SWARM_ENV_PSS_ENABLE = "SWARM_PSS_ENABLE"
|
||||
SWARM_ENV_STORE_PATH = "SWARM_STORE_PATH"
|
||||
SWARM_ENV_STORE_CAPACITY = "SWARM_STORE_CAPACITY"
|
||||
SWARM_ENV_STORE_CACHE_CAPACITY = "SWARM_STORE_CACHE_CAPACITY"
|
||||
SWARM_ENV_BOOTNODE_MODE = "SWARM_BOOTNODE_MODE"
|
||||
SWARM_ACCESS_PASSWORD = "SWARM_ACCESS_PASSWORD"
|
||||
SWARM_AUTO_DEFAULTPATH = "SWARM_AUTO_DEFAULTPATH"
|
||||
SWARM_GLOBALSTORE_API = "SWARM_GLOBALSTORE_API"
|
||||
GETH_ENV_DATADIR = "GETH_DATADIR"
|
||||
SwarmEnvChequebookAddr = "SWARM_CHEQUEBOOK_ADDR"
|
||||
SwarmEnvAccount = "SWARM_ACCOUNT"
|
||||
SwarmEnvListenAddr = "SWARM_LISTEN_ADDR"
|
||||
SwarmEnvPort = "SWARM_PORT"
|
||||
SwarmEnvNetworkId = "SWARM_NETWORK_ID"
|
||||
SwarmEnvSwapEnable = "SWARM_SWAP_ENABLE"
|
||||
SwarmEnvSwapApi = "SWARM_SWAP_API"
|
||||
SwarmEnvSyncDisable = "SWARM_SYNC_DISABLE"
|
||||
SwarmEnvSyncUpdateDelay = "SWARM_ENV_SYNC_UPDATE_DELAY"
|
||||
SwarmEnvMaxStreamPeerServers = "SWARM_ENV_MAX_STREAM_PEER_SERVERS"
|
||||
SwarmEnvLightNodeEnable = "SWARM_LIGHT_NODE_ENABLE"
|
||||
SwarmEnvDeliverySkipCheck = "SWARM_DELIVERY_SKIP_CHECK"
|
||||
SwarmEnvEnsApi = "SWARM_ENS_API"
|
||||
SwarmEnvEnsAddr = "SWARM_ENS_ADDR"
|
||||
SwarmEnvCors = "SWARM_CORS"
|
||||
SwarmEnvBootnodes = "SWARM_BOOTNODES"
|
||||
SwarmEnvPssEnable = "SWARM_PSS_ENABLE"
|
||||
SwarmEnvStorePath = "SWARM_STORE_PATH"
|
||||
SwarmEnvStoreCapacity = "SWARM_STORE_CAPACITY"
|
||||
SwarmEnvStoreCacheCapacity = "SWARM_STORE_CACHE_CAPACITY"
|
||||
SwarmEnvBootnodeMode = "SWARM_BOOTNODE_MODE"
|
||||
SwarmAccessPassword = "SWARM_ACCESS_PASSWORD"
|
||||
SwarmAutoDefaultpath = "SWARM_AUTO_DEFAULTPATH"
|
||||
SwarmGlobalstoreApi = "SWARM_GLOBALSTORE_API"
|
||||
GethEnvDatadir = "GETH_DATADIR"
|
||||
)
|
||||
|
||||
// These settings ensure that TOML keys use the same names as Go struct fields.
|
||||
|
|
@ -227,7 +227,7 @@ func cmdLineOverride(currentConfig *bzzapi.Config, ctx *cli.Context) *bzzapi.Con
|
|||
|
||||
currentConfig.SwapAPI = ctx.GlobalString(SwarmSwapAPIFlag.Name)
|
||||
if currentConfig.SwapEnabled && currentConfig.SwapAPI == "" {
|
||||
utils.Fatalf(SWARM_ERR_SWAP_SET_NO_API)
|
||||
utils.Fatalf(SwarmErrSwapSetNoApi)
|
||||
}
|
||||
|
||||
if ctx.GlobalIsSet(EnsAPIFlag.Name) {
|
||||
|
|
@ -274,113 +274,113 @@ func cmdLineOverride(currentConfig *bzzapi.Config, ctx *cli.Context) *bzzapi.Con
|
|||
// envVarsOverride overrides the current config with whatver is provided in environment variables
|
||||
// most values are not allowed a zero value (empty string), if not otherwise noted
|
||||
func envVarsOverride(currentConfig *bzzapi.Config) (config *bzzapi.Config) {
|
||||
if keyid := os.Getenv(SWARM_ENV_ACCOUNT); keyid != "" {
|
||||
if keyid := os.Getenv(SwarmEnvAccount); keyid != "" {
|
||||
currentConfig.BzzAccount = keyid
|
||||
}
|
||||
|
||||
if chbookaddr := os.Getenv(SWARM_ENV_CHEQUEBOOK_ADDR); chbookaddr != "" {
|
||||
if chbookaddr := os.Getenv(SwarmEnvChequebookAddr); chbookaddr != "" {
|
||||
currentConfig.Contract = common.HexToAddress(chbookaddr)
|
||||
}
|
||||
|
||||
if networkid := os.Getenv(SWARM_ENV_NETWORK_ID); networkid != "" {
|
||||
if networkid := os.Getenv(SwarmEnvNetworkId); networkid != "" {
|
||||
id, err := strconv.ParseUint(networkid, 10, 64)
|
||||
if err != nil {
|
||||
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_NETWORK_ID, err)
|
||||
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvNetworkId, err)
|
||||
}
|
||||
if id != 0 {
|
||||
currentConfig.NetworkID = id
|
||||
}
|
||||
}
|
||||
|
||||
if datadir := os.Getenv(GETH_ENV_DATADIR); datadir != "" {
|
||||
if datadir := os.Getenv(GethEnvDatadir); datadir != "" {
|
||||
currentConfig.Path = expandPath(datadir)
|
||||
}
|
||||
|
||||
bzzport := os.Getenv(SWARM_ENV_PORT)
|
||||
bzzport := os.Getenv(SwarmEnvPort)
|
||||
if len(bzzport) > 0 {
|
||||
currentConfig.Port = bzzport
|
||||
}
|
||||
|
||||
if bzzaddr := os.Getenv(SWARM_ENV_LISTEN_ADDR); bzzaddr != "" {
|
||||
if bzzaddr := os.Getenv(SwarmEnvListenAddr); bzzaddr != "" {
|
||||
currentConfig.ListenAddr = bzzaddr
|
||||
}
|
||||
|
||||
if swapenable := os.Getenv(SWARM_ENV_SWAP_ENABLE); swapenable != "" {
|
||||
if swapenable := os.Getenv(SwarmEnvSwapEnable); swapenable != "" {
|
||||
swap, err := strconv.ParseBool(swapenable)
|
||||
if err != nil {
|
||||
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_SWAP_ENABLE, err)
|
||||
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvSwapEnable, err)
|
||||
}
|
||||
currentConfig.SwapEnabled = swap
|
||||
}
|
||||
|
||||
if syncdisable := os.Getenv(SWARM_ENV_SYNC_DISABLE); syncdisable != "" {
|
||||
if syncdisable := os.Getenv(SwarmEnvSyncDisable); syncdisable != "" {
|
||||
sync, err := strconv.ParseBool(syncdisable)
|
||||
if err != nil {
|
||||
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_SYNC_DISABLE, err)
|
||||
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvSyncDisable, err)
|
||||
}
|
||||
currentConfig.SyncEnabled = !sync
|
||||
}
|
||||
|
||||
if v := os.Getenv(SWARM_ENV_DELIVERY_SKIP_CHECK); v != "" {
|
||||
if v := os.Getenv(SwarmEnvDeliverySkipCheck); v != "" {
|
||||
skipCheck, err := strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
currentConfig.DeliverySkipCheck = skipCheck
|
||||
}
|
||||
}
|
||||
|
||||
if v := os.Getenv(SWARM_ENV_SYNC_UPDATE_DELAY); v != "" {
|
||||
if v := os.Getenv(SwarmEnvSyncUpdateDelay); v != "" {
|
||||
d, err := time.ParseDuration(v)
|
||||
if err != nil {
|
||||
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_SYNC_UPDATE_DELAY, err)
|
||||
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvSyncUpdateDelay, err)
|
||||
}
|
||||
currentConfig.SyncUpdateDelay = d
|
||||
}
|
||||
|
||||
if max := os.Getenv(SWARM_ENV_MAX_STREAM_PEER_SERVERS); max != "" {
|
||||
if max := os.Getenv(SwarmEnvMaxStreamPeerServers); max != "" {
|
||||
m, err := strconv.Atoi(max)
|
||||
if err != nil {
|
||||
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_MAX_STREAM_PEER_SERVERS, err)
|
||||
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvMaxStreamPeerServers, err)
|
||||
}
|
||||
currentConfig.MaxStreamPeerServers = m
|
||||
}
|
||||
|
||||
if lne := os.Getenv(SWARM_ENV_LIGHT_NODE_ENABLE); lne != "" {
|
||||
if lne := os.Getenv(SwarmEnvLightNodeEnable); lne != "" {
|
||||
lightnode, err := strconv.ParseBool(lne)
|
||||
if err != nil {
|
||||
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_LIGHT_NODE_ENABLE, err)
|
||||
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvLightNodeEnable, err)
|
||||
}
|
||||
currentConfig.LightNodeEnabled = lightnode
|
||||
}
|
||||
|
||||
if swapapi := os.Getenv(SWARM_ENV_SWAP_API); swapapi != "" {
|
||||
if swapapi := os.Getenv(SwarmEnvSwapApi); swapapi != "" {
|
||||
currentConfig.SwapAPI = swapapi
|
||||
}
|
||||
|
||||
if currentConfig.SwapEnabled && currentConfig.SwapAPI == "" {
|
||||
utils.Fatalf(SWARM_ERR_SWAP_SET_NO_API)
|
||||
utils.Fatalf(SwarmErrSwapSetNoApi)
|
||||
}
|
||||
|
||||
if ensapi := os.Getenv(SWARM_ENV_ENS_API); ensapi != "" {
|
||||
if ensapi := os.Getenv(SwarmEnvEnsApi); ensapi != "" {
|
||||
currentConfig.EnsAPIs = strings.Split(ensapi, ",")
|
||||
}
|
||||
|
||||
if ensaddr := os.Getenv(SWARM_ENV_ENS_ADDR); ensaddr != "" {
|
||||
if ensaddr := os.Getenv(SwarmEnvEnsAddr); ensaddr != "" {
|
||||
currentConfig.EnsRoot = common.HexToAddress(ensaddr)
|
||||
}
|
||||
|
||||
if cors := os.Getenv(SWARM_ENV_CORS); cors != "" {
|
||||
if cors := os.Getenv(SwarmEnvCors); cors != "" {
|
||||
currentConfig.Cors = cors
|
||||
}
|
||||
|
||||
if bm := os.Getenv(SWARM_ENV_BOOTNODE_MODE); bm != "" {
|
||||
if bm := os.Getenv(SwarmEnvBootnodeMode); bm != "" {
|
||||
bootnodeMode, err := strconv.ParseBool(bm)
|
||||
if err != nil {
|
||||
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_BOOTNODE_MODE, err)
|
||||
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvBootnodeMode, err)
|
||||
}
|
||||
currentConfig.BootnodeMode = bootnodeMode
|
||||
}
|
||||
|
||||
if api := os.Getenv(SWARM_GLOBALSTORE_API); api != "" {
|
||||
if api := os.Getenv(SwarmGlobalstoreApi); api != "" {
|
||||
currentConfig.GlobalStoreAPI = api
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ func TestConfigFailsSwapEnabledNoSwapApi(t *testing.T) {
|
|||
}
|
||||
|
||||
swarm := runSwarm(t, flags...)
|
||||
swarm.Expect("Fatal: " + SWARM_ERR_SWAP_SET_NO_API + "\n")
|
||||
swarm.Expect("Fatal: " + SwarmErrSwapSetNoApi + "\n")
|
||||
swarm.ExpectExit()
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ func TestConfigFailsNoBzzAccount(t *testing.T) {
|
|||
}
|
||||
|
||||
swarm := runSwarm(t, flags...)
|
||||
swarm.Expect("Fatal: " + SWARM_ERR_NO_BZZACCOUNT + "\n")
|
||||
swarm.Expect("Fatal: " + SwarmErrNoBzzaccount + "\n")
|
||||
swarm.ExpectExit()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,68 +23,68 @@ var (
|
|||
ChequebookAddrFlag = cli.StringFlag{
|
||||
Name: "chequebook",
|
||||
Usage: "chequebook contract address",
|
||||
EnvVar: SWARM_ENV_CHEQUEBOOK_ADDR,
|
||||
EnvVar: SwarmEnvChequebookAddr,
|
||||
}
|
||||
SwarmAccountFlag = cli.StringFlag{
|
||||
Name: "bzzaccount",
|
||||
Usage: "Swarm account key file",
|
||||
EnvVar: SWARM_ENV_ACCOUNT,
|
||||
EnvVar: SwarmEnvAccount,
|
||||
}
|
||||
SwarmListenAddrFlag = cli.StringFlag{
|
||||
Name: "httpaddr",
|
||||
Usage: "Swarm HTTP API listening interface",
|
||||
EnvVar: SWARM_ENV_LISTEN_ADDR,
|
||||
EnvVar: SwarmEnvListenAddr,
|
||||
}
|
||||
SwarmPortFlag = cli.StringFlag{
|
||||
Name: "bzzport",
|
||||
Usage: "Swarm local http api port",
|
||||
EnvVar: SWARM_ENV_PORT,
|
||||
EnvVar: SwarmEnvPort,
|
||||
}
|
||||
SwarmNetworkIdFlag = cli.IntFlag{
|
||||
Name: "bzznetworkid",
|
||||
Usage: "Network identifier (integer, default 3=swarm testnet)",
|
||||
EnvVar: SWARM_ENV_NETWORK_ID,
|
||||
EnvVar: SwarmEnvNetworkId,
|
||||
}
|
||||
SwarmSwapEnabledFlag = cli.BoolFlag{
|
||||
Name: "swap",
|
||||
Usage: "Swarm SWAP enabled (default false)",
|
||||
EnvVar: SWARM_ENV_SWAP_ENABLE,
|
||||
EnvVar: SwarmEnvSwapEnable,
|
||||
}
|
||||
SwarmSwapAPIFlag = cli.StringFlag{
|
||||
Name: "swap-api",
|
||||
Usage: "URL of the Ethereum API provider to use to settle SWAP payments",
|
||||
EnvVar: SWARM_ENV_SWAP_API,
|
||||
EnvVar: SwarmEnvSwapApi,
|
||||
}
|
||||
SwarmSyncDisabledFlag = cli.BoolTFlag{
|
||||
Name: "nosync",
|
||||
Usage: "Disable swarm syncing",
|
||||
EnvVar: SWARM_ENV_SYNC_DISABLE,
|
||||
EnvVar: SwarmEnvSyncDisable,
|
||||
}
|
||||
SwarmSyncUpdateDelay = cli.DurationFlag{
|
||||
Name: "sync-update-delay",
|
||||
Usage: "Duration for sync subscriptions update after no new peers are added (default 15s)",
|
||||
EnvVar: SWARM_ENV_SYNC_UPDATE_DELAY,
|
||||
EnvVar: SwarmEnvSyncUpdateDelay,
|
||||
}
|
||||
SwarmMaxStreamPeerServersFlag = cli.IntFlag{
|
||||
Name: "max-stream-peer-servers",
|
||||
Usage: "Limit of Stream peer servers, 0 denotes unlimited",
|
||||
EnvVar: SWARM_ENV_MAX_STREAM_PEER_SERVERS,
|
||||
EnvVar: SwarmEnvMaxStreamPeerServers,
|
||||
Value: 10000, // A very large default value is possible as stream servers have very small memory footprint
|
||||
}
|
||||
SwarmLightNodeEnabled = cli.BoolFlag{
|
||||
Name: "lightnode",
|
||||
Usage: "Enable Swarm LightNode (default false)",
|
||||
EnvVar: SWARM_ENV_LIGHT_NODE_ENABLE,
|
||||
EnvVar: SwarmEnvLightNodeEnable,
|
||||
}
|
||||
SwarmDeliverySkipCheckFlag = cli.BoolFlag{
|
||||
Name: "delivery-skip-check",
|
||||
Usage: "Skip chunk delivery check (default false)",
|
||||
EnvVar: SWARM_ENV_DELIVERY_SKIP_CHECK,
|
||||
EnvVar: SwarmEnvDeliverySkipCheck,
|
||||
}
|
||||
EnsAPIFlag = cli.StringSliceFlag{
|
||||
Name: "ens-api",
|
||||
Usage: "ENS API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url",
|
||||
EnvVar: SWARM_ENV_ENS_API,
|
||||
EnvVar: SwarmEnvEnsApi,
|
||||
}
|
||||
SwarmApiFlag = cli.StringFlag{
|
||||
Name: "bzzapi",
|
||||
|
|
@ -126,7 +126,7 @@ var (
|
|||
SwarmAccessPasswordFlag = cli.StringFlag{
|
||||
Name: "password",
|
||||
Usage: "Password",
|
||||
EnvVar: SWARM_ACCESS_PASSWORD,
|
||||
EnvVar: SwarmAccessPassword,
|
||||
}
|
||||
SwarmDryRunFlag = cli.BoolFlag{
|
||||
Name: "dry-run",
|
||||
|
|
@ -135,22 +135,22 @@ var (
|
|||
CorsStringFlag = cli.StringFlag{
|
||||
Name: "corsdomain",
|
||||
Usage: "Domain on which to send Access-Control-Allow-Origin header (multiple domains can be supplied separated by a ',')",
|
||||
EnvVar: SWARM_ENV_CORS,
|
||||
EnvVar: SwarmEnvCors,
|
||||
}
|
||||
SwarmStorePath = cli.StringFlag{
|
||||
Name: "store.path",
|
||||
Usage: "Path to leveldb chunk DB (default <$GETH_ENV_DIR>/swarm/bzz-<$BZZ_KEY>/chunks)",
|
||||
EnvVar: SWARM_ENV_STORE_PATH,
|
||||
EnvVar: SwarmEnvStorePath,
|
||||
}
|
||||
SwarmStoreCapacity = cli.Uint64Flag{
|
||||
Name: "store.size",
|
||||
Usage: "Number of chunks (5M is roughly 20-25GB) (default 5000000)",
|
||||
EnvVar: SWARM_ENV_STORE_CAPACITY,
|
||||
EnvVar: SwarmEnvStoreCapacity,
|
||||
}
|
||||
SwarmStoreCacheCapacity = cli.UintFlag{
|
||||
Name: "store.cache.size",
|
||||
Usage: "Number of recent chunks cached in memory (default 5000)",
|
||||
EnvVar: SWARM_ENV_STORE_CACHE_CAPACITY,
|
||||
EnvVar: SwarmEnvStoreCacheCapacity,
|
||||
}
|
||||
SwarmCompressedFlag = cli.BoolFlag{
|
||||
Name: "compressed",
|
||||
|
|
@ -179,6 +179,6 @@ var (
|
|||
SwarmGlobalStoreAPIFlag = cli.StringFlag{
|
||||
Name: "globalstore-api",
|
||||
Usage: "URL of the Global Store API provider (only for testing)",
|
||||
EnvVar: SWARM_GLOBALSTORE_API,
|
||||
EnvVar: SwarmGlobalstoreApi,
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -76,8 +76,8 @@ var gitCommit string
|
|||
|
||||
//declare a few constant error messages, useful for later error check comparisons in test
|
||||
var (
|
||||
SWARM_ERR_NO_BZZACCOUNT = "bzzaccount option is required but not set; check your config file, command line or environment variables"
|
||||
SWARM_ERR_SWAP_SET_NO_API = "SWAP is enabled but --swap-api is not set"
|
||||
SwarmErrNoBzzaccount = "bzzaccount option is required but not set; check your config file, command line or environment variables"
|
||||
SwarmErrSwapSetNoApi = "SWAP is enabled but --swap-api is not set"
|
||||
)
|
||||
|
||||
// this help command gets added to any subcommand that does not define it explicitly
|
||||
|
|
@ -351,7 +351,7 @@ func registerBzzService(bzzconfig *bzzapi.Config, stack *node.Node) {
|
|||
func getAccount(bzzaccount string, ctx *cli.Context, stack *node.Node) *ecdsa.PrivateKey {
|
||||
//an account is mandatory
|
||||
if bzzaccount == "" {
|
||||
utils.Fatalf(SWARM_ERR_NO_BZZACCOUNT)
|
||||
utils.Fatalf(SwarmErrNoBzzaccount)
|
||||
}
|
||||
// Try to load the arg as a hex key file.
|
||||
if key, err := crypto.LoadECDSA(bzzaccount); err == nil {
|
||||
|
|
|
|||
|
|
@ -60,10 +60,10 @@ func upload(ctx *cli.Context) {
|
|||
autoDefaultPath = false
|
||||
file string
|
||||
)
|
||||
if autoDefaultPathString := os.Getenv(SWARM_AUTO_DEFAULTPATH); autoDefaultPathString != "" {
|
||||
if autoDefaultPathString := os.Getenv(SwarmAutoDefaultpath); autoDefaultPathString != "" {
|
||||
b, err := strconv.ParseBool(autoDefaultPathString)
|
||||
if err != nil {
|
||||
utils.Fatalf("invalid environment variable %s: %v", SWARM_AUTO_DEFAULTPATH, err)
|
||||
utils.Fatalf("invalid environment variable %s: %v", SwarmAutoDefaultpath, err)
|
||||
}
|
||||
autoDefaultPath = b
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,10 +120,10 @@ func (c *Console) init(preload []string) error {
|
|||
consoleObj.Object().Set("error", c.consoleOutput)
|
||||
|
||||
// Load all the internal utility JavaScript libraries
|
||||
if err := c.jsre.Compile("bignumber.js", jsre.BigNumber_JS); err != nil {
|
||||
if err := c.jsre.Compile("bignumber.js", jsre.BignumberJs); err != nil {
|
||||
return fmt.Errorf("bignumber.js: %v", err)
|
||||
}
|
||||
if err := c.jsre.Compile("web3.js", jsre.Web3_JS); err != nil {
|
||||
if err := c.jsre.Compile("web3.js", jsre.Web3Js); err != nil {
|
||||
return fmt.Errorf("web3.js: %v", err)
|
||||
}
|
||||
if _, err := c.jsre.Run("var Web3 = require('web3');"); err != nil {
|
||||
|
|
|
|||
|
|
@ -1275,13 +1275,13 @@ func TestTransactionPoolRepricingKeepsLocals(t *testing.T) {
|
|||
// Create transaction (both pending and queued) with a linearly growing gasprice
|
||||
for i := uint64(0); i < 500; i++ {
|
||||
// Add pending
|
||||
p_tx := pricedTransaction(i, 100000, big.NewInt(int64(i)), keys[2])
|
||||
if err := pool.AddLocal(p_tx); err != nil {
|
||||
pTx := pricedTransaction(i, 100000, big.NewInt(int64(i)), keys[2])
|
||||
if err := pool.AddLocal(pTx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Add queued
|
||||
q_tx := pricedTransaction(i+501, 100000, big.NewInt(int64(i)), keys[2])
|
||||
if err := pool.AddLocal(q_tx); err != nil {
|
||||
qTx := pricedTransaction(i+501, 100000, big.NewInt(int64(i)), keys[2])
|
||||
if err := pool.AddLocal(qTx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ func BenchmarkCall(b *testing.B) {
|
|||
}
|
||||
}
|
||||
}
|
||||
func benchmarkEVM_Create(bench *testing.B, code string) {
|
||||
func benchmarkevmCreate(bench *testing.B, code string) {
|
||||
var (
|
||||
statedb, _ = state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase()))
|
||||
sender = common.BytesToAddress([]byte("sender"))
|
||||
|
|
@ -189,17 +189,17 @@ func benchmarkEVM_Create(bench *testing.B, code string) {
|
|||
|
||||
func BenchmarkEVM_CREATE_500(bench *testing.B) {
|
||||
// initcode size 500K, repeatedly calls CREATE and then modifies the mem contents
|
||||
benchmarkEVM_Create(bench, "5b6207a120600080f0600152600056")
|
||||
benchmarkevmCreate(bench, "5b6207a120600080f0600152600056")
|
||||
}
|
||||
func BenchmarkEVM_CREATE2_500(bench *testing.B) {
|
||||
// initcode size 500K, repeatedly calls CREATE2 and then modifies the mem contents
|
||||
benchmarkEVM_Create(bench, "5b586207a120600080f5600152600056")
|
||||
benchmarkevmCreate(bench, "5b586207a120600080f5600152600056")
|
||||
}
|
||||
func BenchmarkEVM_CREATE_1200(bench *testing.B) {
|
||||
// initcode size 1200K, repeatedly calls CREATE and then modifies the mem contents
|
||||
benchmarkEVM_Create(bench, "5b62124f80600080f0600152600056")
|
||||
benchmarkevmCreate(bench, "5b62124f80600080f0600152600056")
|
||||
}
|
||||
func BenchmarkEVM_CREATE2_1200(bench *testing.B) {
|
||||
// initcode size 1200K, repeatedly calls CREATE2 and then modifies the mem contents
|
||||
benchmarkEVM_Create(bench, "5b5862124f80600080f5600152600056")
|
||||
benchmarkevmCreate(bench, "5b5862124f80600080f5600152600056")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,21 +40,21 @@ func TestPairings(t *testing.T) {
|
|||
t.Error("MultiAte check gave false negative!")
|
||||
}
|
||||
p0 := new(GT).Add(p1, pn1)
|
||||
p0_2 := Pair(a1, b0)
|
||||
if p0.String() != p0_2.String() {
|
||||
p02 := Pair(a1, b0)
|
||||
if p0.String() != p02.String() {
|
||||
t.Error("Pairing mismatch: e(a, b) * e(a, -b) != 1")
|
||||
}
|
||||
p0_3 := new(GT).ScalarMult(p1, bigFromBase10("21888242871839275222246405745257275088548364400416034343698204186575808495617"))
|
||||
if p0.String() != p0_3.String() {
|
||||
p03 := new(GT).ScalarMult(p1, bigFromBase10("21888242871839275222246405745257275088548364400416034343698204186575808495617"))
|
||||
if p0.String() != p03.String() {
|
||||
t.Error("Pairing mismatch: e(a, b) has wrong order")
|
||||
}
|
||||
p2 := Pair(a2, b1)
|
||||
p2_2 := Pair(a1, b2)
|
||||
p2_3 := new(GT).ScalarMult(p1, bigFromBase10("2"))
|
||||
if p2.String() != p2_2.String() {
|
||||
p22 := Pair(a1, b2)
|
||||
p23 := new(GT).ScalarMult(p1, bigFromBase10("2"))
|
||||
if p2.String() != p22.String() {
|
||||
t.Error("Pairing mismatch: e(a, b * 2) != e(a * 2, b)")
|
||||
}
|
||||
if p2.String() != p2_3.String() {
|
||||
if p2.String() != p23.String() {
|
||||
t.Error("Pairing mismatch: e(a, b * 2) != e(a, b) ** 2")
|
||||
}
|
||||
if p2.String() == p1.String() {
|
||||
|
|
@ -64,8 +64,8 @@ func TestPairings(t *testing.T) {
|
|||
t.Error("MultiAte check gave false positive!")
|
||||
}
|
||||
p999 := Pair(a37, b27)
|
||||
p999_2 := Pair(a1, b999)
|
||||
if p999.String() != p999_2.String() {
|
||||
p9992 := Pair(a1, b999)
|
||||
if p999.String() != p9992.String() {
|
||||
t.Error("Pairing mismatch: e(a * 37, b * 27) != e(a, b * 999)")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,21 +40,21 @@ func TestPairings(t *testing.T) {
|
|||
t.Error("MultiAte check gave false negative!")
|
||||
}
|
||||
p0 := new(GT).Add(p1, pn1)
|
||||
p0_2 := Pair(a1, b0)
|
||||
if p0.String() != p0_2.String() {
|
||||
p02 := Pair(a1, b0)
|
||||
if p0.String() != p02.String() {
|
||||
t.Error("Pairing mismatch: e(a, b) * e(a, -b) != 1")
|
||||
}
|
||||
p0_3 := new(GT).ScalarMult(p1, bigFromBase10("21888242871839275222246405745257275088548364400416034343698204186575808495617"))
|
||||
if p0.String() != p0_3.String() {
|
||||
p03 := new(GT).ScalarMult(p1, bigFromBase10("21888242871839275222246405745257275088548364400416034343698204186575808495617"))
|
||||
if p0.String() != p03.String() {
|
||||
t.Error("Pairing mismatch: e(a, b) has wrong order")
|
||||
}
|
||||
p2 := Pair(a2, b1)
|
||||
p2_2 := Pair(a1, b2)
|
||||
p2_3 := new(GT).ScalarMult(p1, bigFromBase10("2"))
|
||||
if p2.String() != p2_2.String() {
|
||||
p22 := Pair(a1, b2)
|
||||
p23 := new(GT).ScalarMult(p1, bigFromBase10("2"))
|
||||
if p2.String() != p22.String() {
|
||||
t.Error("Pairing mismatch: e(a, b * 2) != e(a * 2, b)")
|
||||
}
|
||||
if p2.String() != p2_3.String() {
|
||||
if p2.String() != p23.String() {
|
||||
t.Error("Pairing mismatch: e(a, b * 2) != e(a, b) ** 2")
|
||||
}
|
||||
if p2.String() == p1.String() {
|
||||
|
|
@ -64,8 +64,8 @@ func TestPairings(t *testing.T) {
|
|||
t.Error("MultiAte check gave false positive!")
|
||||
}
|
||||
p999 := Pair(a37, b27)
|
||||
p999_2 := Pair(a1, b999)
|
||||
if p999.String() != p999_2.String() {
|
||||
p9992 := Pair(a1, b999)
|
||||
if p999.String() != p9992.String() {
|
||||
t.Error("Pairing mismatch: e(a * 37, b * 27) != e(a, b * 999)")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -328,17 +328,17 @@ var testCases = []testCase{
|
|||
{
|
||||
Curve: elliptic.P256(),
|
||||
Name: "P256",
|
||||
Expected: ECIES_AES128_SHA256,
|
||||
Expected: EciesAes128Sha256,
|
||||
},
|
||||
{
|
||||
Curve: elliptic.P384(),
|
||||
Name: "P384",
|
||||
Expected: ECIES_AES256_SHA384,
|
||||
Expected: EciesAes256Sha384,
|
||||
},
|
||||
{
|
||||
Curve: elliptic.P521(),
|
||||
Name: "P521",
|
||||
Expected: ECIES_AES256_SHA512,
|
||||
Expected: EciesAes256Sha512,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ type ECIESParams struct {
|
|||
// * ECIES using AES256 and HMAC-SHA-512-64
|
||||
|
||||
var (
|
||||
ECIES_AES128_SHA256 = &ECIESParams{
|
||||
EciesAes128Sha256 = &ECIESParams{
|
||||
Hash: sha256.New,
|
||||
hashAlgo: crypto.SHA256,
|
||||
Cipher: aes.NewCipher,
|
||||
|
|
@ -74,7 +74,7 @@ var (
|
|||
KeyLen: 16,
|
||||
}
|
||||
|
||||
ECIES_AES256_SHA256 = &ECIESParams{
|
||||
EciesAes256Sha256 = &ECIESParams{
|
||||
Hash: sha256.New,
|
||||
hashAlgo: crypto.SHA256,
|
||||
Cipher: aes.NewCipher,
|
||||
|
|
@ -82,7 +82,7 @@ var (
|
|||
KeyLen: 32,
|
||||
}
|
||||
|
||||
ECIES_AES256_SHA384 = &ECIESParams{
|
||||
EciesAes256Sha384 = &ECIESParams{
|
||||
Hash: sha512.New384,
|
||||
hashAlgo: crypto.SHA384,
|
||||
Cipher: aes.NewCipher,
|
||||
|
|
@ -90,7 +90,7 @@ var (
|
|||
KeyLen: 32,
|
||||
}
|
||||
|
||||
ECIES_AES256_SHA512 = &ECIESParams{
|
||||
EciesAes256Sha512 = &ECIESParams{
|
||||
Hash: sha512.New,
|
||||
hashAlgo: crypto.SHA512,
|
||||
Cipher: aes.NewCipher,
|
||||
|
|
@ -100,10 +100,10 @@ var (
|
|||
)
|
||||
|
||||
var paramsFromCurve = map[elliptic.Curve]*ECIESParams{
|
||||
ethcrypto.S256(): ECIES_AES128_SHA256,
|
||||
elliptic.P256(): ECIES_AES128_SHA256,
|
||||
elliptic.P384(): ECIES_AES256_SHA384,
|
||||
elliptic.P521(): ECIES_AES256_SHA512,
|
||||
ethcrypto.S256(): EciesAes128Sha256,
|
||||
elliptic.P256(): EciesAes128Sha256,
|
||||
elliptic.P384(): EciesAes256Sha384,
|
||||
elliptic.P521(): EciesAes256Sha512,
|
||||
}
|
||||
|
||||
func AddParamsForCurve(curve elliptic.Curve, params *ECIESParams) {
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ type callTracerTest struct {
|
|||
}
|
||||
|
||||
func TestPrestateTracerCreate2(t *testing.T) {
|
||||
unsigned_tx := types.NewTransaction(1, common.HexToAddress("0x00000000000000000000000000000000deadbeef"),
|
||||
unsignedTx := types.NewTransaction(1, common.HexToAddress("0x00000000000000000000000000000000deadbeef"),
|
||||
new(big.Int), 5000000, big.NewInt(1), []byte{})
|
||||
|
||||
privateKeyECDSA, err := ecdsa.GenerateKey(crypto.S256(), rand.Reader)
|
||||
|
|
@ -129,7 +129,7 @@ func TestPrestateTracerCreate2(t *testing.T) {
|
|||
t.Fatalf("err %v", err)
|
||||
}
|
||||
signer := types.NewEIP155Signer(big.NewInt(1))
|
||||
tx, err := types.SignTx(unsigned_tx, signer, privateKeyECDSA)
|
||||
tx, err := types.SignTx(unsignedTx, signer, privateKeyECDSA)
|
||||
if err != nil {
|
||||
t.Fatalf("err %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ func newTestLDB() (*ethdb.LDBDatabase, func()) {
|
|||
}
|
||||
}
|
||||
|
||||
var test_values = []string{"", "a", "1251", "\x00123\x00"}
|
||||
var testValues = []string{"", "a", "1251", "\x00123\x00"}
|
||||
|
||||
func TestLDB_PutGet(t *testing.T) {
|
||||
db, remove := newTestLDB()
|
||||
|
|
@ -61,14 +61,14 @@ func TestMemoryDB_PutGet(t *testing.T) {
|
|||
func testPutGet(db ethdb.Database, t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, k := range test_values {
|
||||
for _, k := range testValues {
|
||||
err := db.Put([]byte(k), nil)
|
||||
if err != nil {
|
||||
t.Fatalf("put failed: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
for _, k := range test_values {
|
||||
for _, k := range testValues {
|
||||
data, err := db.Get([]byte(k))
|
||||
if err != nil {
|
||||
t.Fatalf("get failed: %v", err)
|
||||
|
|
@ -83,14 +83,14 @@ func testPutGet(db ethdb.Database, t *testing.T) {
|
|||
t.Fatalf("expect to return a not found error")
|
||||
}
|
||||
|
||||
for _, v := range test_values {
|
||||
for _, v := range testValues {
|
||||
err := db.Put([]byte(v), []byte(v))
|
||||
if err != nil {
|
||||
t.Fatalf("put failed: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
for _, v := range test_values {
|
||||
for _, v := range testValues {
|
||||
data, err := db.Get([]byte(v))
|
||||
if err != nil {
|
||||
t.Fatalf("get failed: %v", err)
|
||||
|
|
@ -100,14 +100,14 @@ func testPutGet(db ethdb.Database, t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
for _, v := range test_values {
|
||||
for _, v := range testValues {
|
||||
err := db.Put([]byte(v), []byte("?"))
|
||||
if err != nil {
|
||||
t.Fatalf("put override failed: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
for _, v := range test_values {
|
||||
for _, v := range testValues {
|
||||
data, err := db.Get([]byte(v))
|
||||
if err != nil {
|
||||
t.Fatalf("get failed: %v", err)
|
||||
|
|
@ -117,7 +117,7 @@ func testPutGet(db ethdb.Database, t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
for _, v := range test_values {
|
||||
for _, v := range testValues {
|
||||
orig, err := db.Get([]byte(v))
|
||||
if err != nil {
|
||||
t.Fatalf("get failed: %v", err)
|
||||
|
|
@ -132,14 +132,14 @@ func testPutGet(db ethdb.Database, t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
for _, v := range test_values {
|
||||
for _, v := range testValues {
|
||||
err := db.Delete([]byte(v))
|
||||
if err != nil {
|
||||
t.Fatalf("delete %q failed: %v", v, err)
|
||||
}
|
||||
}
|
||||
|
||||
for _, v := range test_values {
|
||||
for _, v := range testValues {
|
||||
_, err := db.Get([]byte(v))
|
||||
if err == nil {
|
||||
t.Fatalf("got deleted value %q", v)
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
BigNumber_JS = deps.MustAsset("bignumber.js")
|
||||
Web3_JS = deps.MustAsset("web3.js")
|
||||
BignumberJs = deps.MustAsset("bignumber.js")
|
||||
Web3Js = deps.MustAsset("web3.js")
|
||||
)
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -18,23 +18,23 @@
|
|||
package web3ext
|
||||
|
||||
var Modules = map[string]string{
|
||||
"accounting": Accounting_JS,
|
||||
"admin": Admin_JS,
|
||||
"chequebook": Chequebook_JS,
|
||||
"clique": Clique_JS,
|
||||
"ethash": Ethash_JS,
|
||||
"debug": Debug_JS,
|
||||
"eth": Eth_JS,
|
||||
"miner": Miner_JS,
|
||||
"net": Net_JS,
|
||||
"personal": Personal_JS,
|
||||
"rpc": RPC_JS,
|
||||
"shh": Shh_JS,
|
||||
"swarmfs": SWARMFS_JS,
|
||||
"txpool": TxPool_JS,
|
||||
"accounting": AccountingJs,
|
||||
"admin": AdminJs,
|
||||
"chequebook": ChequebookJs,
|
||||
"clique": CliqueJs,
|
||||
"ethash": EthashJs,
|
||||
"debug": DebugJs,
|
||||
"eth": EthJs,
|
||||
"miner": MinerJs,
|
||||
"net": NetJs,
|
||||
"personal": PersonalJs,
|
||||
"rpc": RpcJs,
|
||||
"shh": ShhJs,
|
||||
"swarmfs": SwarmfsJs,
|
||||
"txpool": TxpoolJs,
|
||||
}
|
||||
|
||||
const Chequebook_JS = `
|
||||
const ChequebookJs = `
|
||||
web3._extend({
|
||||
property: 'chequebook',
|
||||
methods: [
|
||||
|
|
@ -65,7 +65,7 @@ web3._extend({
|
|||
});
|
||||
`
|
||||
|
||||
const Clique_JS = `
|
||||
const CliqueJs = `
|
||||
web3._extend({
|
||||
property: 'clique',
|
||||
methods: [
|
||||
|
|
@ -111,7 +111,7 @@ web3._extend({
|
|||
});
|
||||
`
|
||||
|
||||
const Ethash_JS = `
|
||||
const EthashJs = `
|
||||
web3._extend({
|
||||
property: 'ethash',
|
||||
methods: [
|
||||
|
|
@ -139,7 +139,7 @@ web3._extend({
|
|||
});
|
||||
`
|
||||
|
||||
const Admin_JS = `
|
||||
const AdminJs = `
|
||||
web3._extend({
|
||||
property: 'admin',
|
||||
methods: [
|
||||
|
|
@ -217,7 +217,7 @@ web3._extend({
|
|||
});
|
||||
`
|
||||
|
||||
const Debug_JS = `
|
||||
const DebugJs = `
|
||||
web3._extend({
|
||||
property: 'debug',
|
||||
methods: [
|
||||
|
|
@ -448,7 +448,7 @@ web3._extend({
|
|||
});
|
||||
`
|
||||
|
||||
const Eth_JS = `
|
||||
const EthJs = `
|
||||
web3._extend({
|
||||
property: 'eth',
|
||||
methods: [
|
||||
|
|
@ -518,7 +518,7 @@ web3._extend({
|
|||
});
|
||||
`
|
||||
|
||||
const Miner_JS = `
|
||||
const MinerJs = `
|
||||
web3._extend({
|
||||
property: 'miner',
|
||||
methods: [
|
||||
|
|
@ -563,7 +563,7 @@ web3._extend({
|
|||
});
|
||||
`
|
||||
|
||||
const Net_JS = `
|
||||
const NetJs = `
|
||||
web3._extend({
|
||||
property: 'net',
|
||||
methods: [],
|
||||
|
|
@ -576,7 +576,7 @@ web3._extend({
|
|||
});
|
||||
`
|
||||
|
||||
const Personal_JS = `
|
||||
const PersonalJs = `
|
||||
web3._extend({
|
||||
property: 'personal',
|
||||
methods: [
|
||||
|
|
@ -622,7 +622,7 @@ web3._extend({
|
|||
})
|
||||
`
|
||||
|
||||
const RPC_JS = `
|
||||
const RpcJs = `
|
||||
web3._extend({
|
||||
property: 'rpc',
|
||||
methods: [],
|
||||
|
|
@ -635,7 +635,7 @@ web3._extend({
|
|||
});
|
||||
`
|
||||
|
||||
const Shh_JS = `
|
||||
const ShhJs = `
|
||||
web3._extend({
|
||||
property: 'shh',
|
||||
methods: [
|
||||
|
|
@ -655,7 +655,7 @@ web3._extend({
|
|||
});
|
||||
`
|
||||
|
||||
const SWARMFS_JS = `
|
||||
const SwarmfsJs = `
|
||||
web3._extend({
|
||||
property: 'swarmfs',
|
||||
methods:
|
||||
|
|
@ -679,7 +679,7 @@ web3._extend({
|
|||
});
|
||||
`
|
||||
|
||||
const TxPool_JS = `
|
||||
const TxpoolJs = `
|
||||
web3._extend({
|
||||
property: 'txpool',
|
||||
methods: [],
|
||||
|
|
@ -706,7 +706,7 @@ web3._extend({
|
|||
});
|
||||
`
|
||||
|
||||
const Accounting_JS = `
|
||||
const AccountingJs = `
|
||||
web3._extend({
|
||||
property: 'accounting',
|
||||
methods: [
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
test_networkid = 10
|
||||
protocol_version = 2123
|
||||
testNetworkid = 10
|
||||
protocolVersion = 2123
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -31,7 +31,7 @@ func TestPeerHandshakeSetAnnounceTypeToAnnounceTypeSignedForTrustedPeer(t *testi
|
|||
//peer to connect(on ulc side)
|
||||
p := peer{
|
||||
Peer: p2p.NewPeer(id, "test peer", []p2p.Cap{}),
|
||||
version: protocol_version,
|
||||
version: protocolVersion,
|
||||
isTrusted: true,
|
||||
rw: &rwStub{
|
||||
WriteHook: func(recvList keyValueList) {
|
||||
|
|
@ -60,7 +60,7 @@ func TestPeerHandshakeSetAnnounceTypeToAnnounceTypeSignedForTrustedPeer(t *testi
|
|||
return l
|
||||
},
|
||||
},
|
||||
network: test_networkid,
|
||||
network: testNetworkid,
|
||||
}
|
||||
|
||||
err := p.Handshake(td, hash, headNum, genesis, nil)
|
||||
|
|
@ -77,7 +77,7 @@ func TestPeerHandshakeAnnounceTypeSignedForTrustedPeersPeerNotInTrusted(t *testi
|
|||
var id enode.ID = newNodeID(t).ID()
|
||||
p := peer{
|
||||
Peer: p2p.NewPeer(id, "test peer", []p2p.Cap{}),
|
||||
version: protocol_version,
|
||||
version: protocolVersion,
|
||||
rw: &rwStub{
|
||||
WriteHook: func(recvList keyValueList) {
|
||||
//checking that ulc sends to peer allowedRequests=noRequests and announceType != announceTypeSigned
|
||||
|
|
@ -105,7 +105,7 @@ func TestPeerHandshakeAnnounceTypeSignedForTrustedPeersPeerNotInTrusted(t *testi
|
|||
return l
|
||||
},
|
||||
},
|
||||
network: test_networkid,
|
||||
network: testNetworkid,
|
||||
}
|
||||
|
||||
err := p.Handshake(td, hash, headNum, genesis, nil)
|
||||
|
|
@ -124,7 +124,7 @@ func TestPeerHandshakeDefaultAllRequests(t *testing.T) {
|
|||
|
||||
p := peer{
|
||||
Peer: p2p.NewPeer(id, "test peer", []p2p.Cap{}),
|
||||
version: protocol_version,
|
||||
version: protocolVersion,
|
||||
rw: &rwStub{
|
||||
ReadHook: func(l keyValueList) keyValueList {
|
||||
l = l.add("announceType", uint64(announceTypeSigned))
|
||||
|
|
@ -133,7 +133,7 @@ func TestPeerHandshakeDefaultAllRequests(t *testing.T) {
|
|||
return l
|
||||
},
|
||||
},
|
||||
network: test_networkid,
|
||||
network: testNetworkid,
|
||||
}
|
||||
|
||||
err := p.Handshake(td, hash, headNum, genesis, s)
|
||||
|
|
@ -154,7 +154,7 @@ func TestPeerHandshakeServerSendOnlyAnnounceRequestsHeaders(t *testing.T) {
|
|||
|
||||
p := peer{
|
||||
Peer: p2p.NewPeer(id, "test peer", []p2p.Cap{}),
|
||||
version: protocol_version,
|
||||
version: protocolVersion,
|
||||
rw: &rwStub{
|
||||
ReadHook: func(l keyValueList) keyValueList {
|
||||
l = l.add("announceType", uint64(announceTypeSigned))
|
||||
|
|
@ -172,7 +172,7 @@ func TestPeerHandshakeServerSendOnlyAnnounceRequestsHeaders(t *testing.T) {
|
|||
}
|
||||
},
|
||||
},
|
||||
network: test_networkid,
|
||||
network: testNetworkid,
|
||||
}
|
||||
|
||||
err := p.Handshake(td, hash, headNum, genesis, s)
|
||||
|
|
@ -185,7 +185,7 @@ func TestPeerHandshakeClientReceiveOnlyAnnounceRequestsHeaders(t *testing.T) {
|
|||
|
||||
p := peer{
|
||||
Peer: p2p.NewPeer(id, "test peer", []p2p.Cap{}),
|
||||
version: protocol_version,
|
||||
version: protocolVersion,
|
||||
rw: &rwStub{
|
||||
ReadHook: func(l keyValueList) keyValueList {
|
||||
l = l.add("flowControl/BL", uint64(0))
|
||||
|
|
@ -197,7 +197,7 @@ func TestPeerHandshakeClientReceiveOnlyAnnounceRequestsHeaders(t *testing.T) {
|
|||
return l
|
||||
},
|
||||
},
|
||||
network: test_networkid,
|
||||
network: testNetworkid,
|
||||
isTrusted: true,
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +216,7 @@ func TestPeerHandshakeClientReturnErrorOnUselessPeer(t *testing.T) {
|
|||
|
||||
p := peer{
|
||||
Peer: p2p.NewPeer(id, "test peer", []p2p.Cap{}),
|
||||
version: protocol_version,
|
||||
version: protocolVersion,
|
||||
rw: &rwStub{
|
||||
ReadHook: func(l keyValueList) keyValueList {
|
||||
l = l.add("flowControl/BL", uint64(0))
|
||||
|
|
@ -228,7 +228,7 @@ func TestPeerHandshakeClientReturnErrorOnUselessPeer(t *testing.T) {
|
|||
return l
|
||||
},
|
||||
},
|
||||
network: test_networkid,
|
||||
network: testNetworkid,
|
||||
}
|
||||
|
||||
err := p.Handshake(td, hash, headNum, genesis, nil)
|
||||
|
|
@ -261,8 +261,8 @@ type rwStub struct {
|
|||
|
||||
func (s *rwStub) ReadMsg() (p2p.Msg, error) {
|
||||
payload := keyValueList{}
|
||||
payload = payload.add("protocolVersion", uint64(protocol_version))
|
||||
payload = payload.add("networkId", uint64(test_networkid))
|
||||
payload = payload.add("protocolVersion", uint64(protocolVersion))
|
||||
payload = payload.add("networkId", uint64(testNetworkid))
|
||||
payload = payload.add("headTd", td)
|
||||
payload = payload.add("headHash", hash)
|
||||
payload = payload.add("headNum", headNum)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/rlp"
|
||||
)
|
||||
|
||||
var sha3_nil = crypto.Keccak256Hash(nil)
|
||||
var sha3Nil = crypto.Keccak256Hash(nil)
|
||||
|
||||
func GetHeaderByNumber(ctx context.Context, odr OdrBackend, number uint64) (*types.Header, error) {
|
||||
db := odr.Database()
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func (db *odrDatabase) CopyTrie(t state.Trie) state.Trie {
|
|||
}
|
||||
|
||||
func (db *odrDatabase) ContractCode(addrHash, codeHash common.Hash) ([]byte, error) {
|
||||
if codeHash == sha3_nil {
|
||||
if codeHash == sha3Nil {
|
||||
return nil, nil
|
||||
}
|
||||
if code, err := db.backend.Database().Get(codeHash[:]); err == nil {
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ OUTER:
|
|||
|
||||
connEventCount = nodeCount
|
||||
|
||||
OUTER_TWO:
|
||||
OuterTwo:
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
|
|
@ -210,7 +210,7 @@ OUTER_TWO:
|
|||
connEventCount--
|
||||
log.Debug("ev", "count", connEventCount)
|
||||
if connEventCount == 0 {
|
||||
break OUTER_TWO
|
||||
break OuterTwo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
BigNumber_JS = deps.MustAsset("bignumber.js")
|
||||
BignumberJs = deps.MustAsset("bignumber.js")
|
||||
)
|
||||
|
||||
// consoleOutput is an override for the console.log and console.error methods to
|
||||
|
|
@ -81,7 +81,7 @@ func (r *rulesetUI) execute(jsfunc string, jsarg interface{}) (otto.Value, error
|
|||
vm.Set("storage", r.storage)
|
||||
|
||||
// Load bootstrap libraries
|
||||
script, err := vm.Compile("bignumber.js", BigNumber_JS)
|
||||
script, err := vm.Compile("bignumber.js", BignumberJs)
|
||||
if err != nil {
|
||||
log.Warn("Failed loading libraries", "err", err)
|
||||
return otto.UndefinedValue(), err
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
const EMPTY_CREDENTIALS = ""
|
||||
const EmptyCredentials = ""
|
||||
|
||||
type AccessEntry struct {
|
||||
Type AccessType
|
||||
|
|
|
|||
|
|
@ -431,7 +431,7 @@ func (a *API) Delete(ctx context.Context, addr string, path string) (storage.Add
|
|||
apiDeleteFail.Inc(1)
|
||||
return nil, err
|
||||
}
|
||||
key, err := a.ResolveURI(ctx, uri, EMPTY_CREDENTIALS)
|
||||
key, err := a.ResolveURI(ctx, uri, EmptyCredentials)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -643,7 +643,7 @@ func (a *API) AddFile(ctx context.Context, mhash, path, fname string, content []
|
|||
apiAddFileFail.Inc(1)
|
||||
return nil, "", err
|
||||
}
|
||||
mkey, err := a.ResolveURI(ctx, uri, EMPTY_CREDENTIALS)
|
||||
mkey, err := a.ResolveURI(ctx, uri, EmptyCredentials)
|
||||
if err != nil {
|
||||
apiAddFileFail.Inc(1)
|
||||
return nil, "", err
|
||||
|
|
@ -760,7 +760,7 @@ func (a *API) RemoveFile(ctx context.Context, mhash string, path string, fname s
|
|||
apiRmFileFail.Inc(1)
|
||||
return "", err
|
||||
}
|
||||
mkey, err := a.ResolveURI(ctx, uri, EMPTY_CREDENTIALS)
|
||||
mkey, err := a.ResolveURI(ctx, uri, EmptyCredentials)
|
||||
if err != nil {
|
||||
apiRmFileFail.Inc(1)
|
||||
return "", err
|
||||
|
|
@ -827,7 +827,7 @@ func (a *API) AppendFile(ctx context.Context, mhash, path, fname string, existin
|
|||
apiAppendFileFail.Inc(1)
|
||||
return nil, "", err
|
||||
}
|
||||
mkey, err := a.ResolveURI(ctx, uri, EMPTY_CREDENTIALS)
|
||||
mkey, err := a.ResolveURI(ctx, uri, EmptyCredentials)
|
||||
if err != nil {
|
||||
apiAppendFileFail.Inc(1)
|
||||
return nil, "", err
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
Swarmfs_Version = "0.1"
|
||||
mountTimeout = time.Second * 5
|
||||
unmountTimeout = time.Second * 10
|
||||
maxFuseMounts = 5
|
||||
SwarmfsVersion = "0.1"
|
||||
mountTimeout = time.Second * 5
|
||||
unmountTimeout = time.Second * 10
|
||||
maxFuseMounts = 5
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -100,20 +100,20 @@ func NewPeer(peer *protocols.Peer, streamer *Registry) *Peer {
|
|||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
var len_maxi int
|
||||
var cap_maxi int
|
||||
var lenMaxi int
|
||||
var capMaxi int
|
||||
for k := range pq.Queues {
|
||||
if len_maxi < len(pq.Queues[k]) {
|
||||
len_maxi = len(pq.Queues[k])
|
||||
if lenMaxi < len(pq.Queues[k]) {
|
||||
lenMaxi = len(pq.Queues[k])
|
||||
}
|
||||
|
||||
if cap_maxi < cap(pq.Queues[k]) {
|
||||
cap_maxi = cap(pq.Queues[k])
|
||||
if capMaxi < cap(pq.Queues[k]) {
|
||||
capMaxi = cap(pq.Queues[k])
|
||||
}
|
||||
}
|
||||
|
||||
metrics.GetOrRegisterGauge(fmt.Sprintf("pq_len_%s", p.ID().TerminalString()), nil).Update(int64(len_maxi))
|
||||
metrics.GetOrRegisterGauge(fmt.Sprintf("pq_cap_%s", p.ID().TerminalString()), nil).Update(int64(cap_maxi))
|
||||
metrics.GetOrRegisterGauge(fmt.Sprintf("pq_len_%s", p.ID().TerminalString()), nil).Update(int64(lenMaxi))
|
||||
metrics.GetOrRegisterGauge(fmt.Sprintf("pq_cap_%s", p.ID().TerminalString()), nil).Update(int64(capMaxi))
|
||||
case <-p.quit:
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ func testIterator(t *testing.T, mock bool) {
|
|||
var i int
|
||||
var poc uint
|
||||
chunkkeys := NewAddressCollection(chunkcount)
|
||||
chunkkeys_results := NewAddressCollection(chunkcount)
|
||||
chunkkeysResults := NewAddressCollection(chunkcount)
|
||||
|
||||
db, cleanup, err := newTestDbStore(mock, false)
|
||||
defer cleanup()
|
||||
|
|
@ -218,7 +218,7 @@ func testIterator(t *testing.T, mock bool) {
|
|||
for poc = 0; poc <= 255; poc++ {
|
||||
err := db.SyncIterator(0, uint64(chunkkeys.Len()), uint8(poc), func(k Address, n uint64) bool {
|
||||
log.Trace(fmt.Sprintf("Got key %v number %d poc %d", k, n, uint8(poc)))
|
||||
chunkkeys_results[n] = k
|
||||
chunkkeysResults[n] = k
|
||||
i++
|
||||
return true
|
||||
})
|
||||
|
|
@ -228,8 +228,8 @@ func testIterator(t *testing.T, mock bool) {
|
|||
}
|
||||
|
||||
for i = 0; i < chunkcount; i++ {
|
||||
if !bytes.Equal(chunkkeys[i], chunkkeys_results[i]) {
|
||||
t.Fatalf("Chunk put #%d key '%v' does not match iterator's key '%v'", i, chunkkeys[i], chunkkeys_results[i])
|
||||
if !bytes.Equal(chunkkeys[i], chunkkeysResults[i]) {
|
||||
t.Fatalf("Chunk put #%d key '%v' does not match iterator's key '%v'", i, chunkkeys[i], chunkkeysResults[i])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -496,7 +496,7 @@ func (self *Swarm) APIs() []rpc.API {
|
|||
},
|
||||
{
|
||||
Namespace: "swarmfs",
|
||||
Version: fuse.Swarmfs_Version,
|
||||
Version: fuse.SwarmfsVersion,
|
||||
Service: self.sfs,
|
||||
Public: false,
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue