diff options
-rw-r--r-- | accounts/keystore/key.go | 8 | ||||
-rw-r--r-- | accounts/keystore/keystore_passphrase.go | 4 | ||||
-rw-r--r-- | accounts/usbwallet/ledger_hub.go | 9 | ||||
-rw-r--r-- | cmd/evm/disasm.go | 5 | ||||
-rw-r--r-- | cmd/puppeth/ssh.go | 2 | ||||
-rw-r--r-- | cmd/puppeth/wizard.go | 2 | ||||
-rw-r--r-- | cmd/puppeth/wizard_network.go | 26 | ||||
-rw-r--r-- | common/bitutil/compress_test.go | 8 | ||||
-rw-r--r-- | common/hexutil/json.go | 9 | ||||
-rw-r--r-- | console/console_test.go | 2 | ||||
-rw-r--r-- | core/tx_pool_test.go | 4 | ||||
-rw-r--r-- | ethstats/ethstats.go | 3 | ||||
-rw-r--r-- | log/format.go | 2 | ||||
-rw-r--r-- | miner/remote_agent.go | 5 | ||||
-rw-r--r-- | miner/worker.go | 13 | ||||
-rw-r--r-- | node/config.go | 4 | ||||
-rw-r--r-- | node/utils_test.go | 2 |
17 files changed, 40 insertions, 68 deletions
diff --git a/accounts/keystore/key.go b/accounts/keystore/key.go index ecc955d74..211fa863d 100644 --- a/accounts/keystore/key.go +++ b/accounts/keystore/key.go @@ -91,14 +91,6 @@ type cipherparamsJSON struct { IV string `json:"iv"` } -type scryptParamsJSON struct { - N int `json:"n"` - R int `json:"r"` - P int `json:"p"` - DkLen int `json:"dklen"` - Salt string `json:"salt"` -} - func (k *Key) MarshalJSON() (j []byte, err error) { jStruct := plainKeyJSON{ hex.EncodeToString(k.Address[:]), diff --git a/accounts/keystore/keystore_passphrase.go b/accounts/keystore/keystore_passphrase.go index 679fc15d6..535608a60 100644 --- a/accounts/keystore/keystore_passphrase.go +++ b/accounts/keystore/keystore_passphrase.go @@ -140,7 +140,7 @@ func EncryptKey(key *Key, auth string, scryptN, scryptP int) ([]byte, error) { Cipher: "aes-128-ctr", CipherText: hex.EncodeToString(cipherText), CipherParams: cipherParamsJSON, - KDF: "scrypt", + KDF: keyHeaderKDF, KDFParams: scryptParamsJSON, MAC: hex.EncodeToString(mac), } @@ -275,7 +275,7 @@ func getKDFKey(cryptoJSON cryptoJSON, auth string) ([]byte, error) { } dkLen := ensureInt(cryptoJSON.KDFParams["dklen"]) - if cryptoJSON.KDF == "scrypt" { + if cryptoJSON.KDF == keyHeaderKDF { n := ensureInt(cryptoJSON.KDFParams["n"]) r := ensureInt(cryptoJSON.KDFParams["r"]) p := ensureInt(cryptoJSON.KDFParams["p"]) diff --git a/accounts/usbwallet/ledger_hub.go b/accounts/usbwallet/ledger_hub.go index fcbc24c0f..2b0d56097 100644 --- a/accounts/usbwallet/ledger_hub.go +++ b/accounts/usbwallet/ledger_hub.go @@ -197,11 +197,10 @@ func (hub *LedgerHub) Subscribe(sink chan<- accounts.WalletEvent) event.Subscrip // is not running). func (hub *LedgerHub) updater() { for { - // Wait for a USB hotplug event (not supported yet) or a refresh timeout - select { - //case <-hub.changes: // reenable on hutplug implementation - case <-time.After(ledgerRefreshCycle): - } + // TODO: Wait for a USB hotplug event (not supported yet) or a refresh timeout + // <-hub.changes + time.Sleep(ledgerRefreshCycle) + // Run the wallet refresher hub.refreshWallets() diff --git a/cmd/evm/disasm.go b/cmd/evm/disasm.go index a78b2a8e1..4a442cf78 100644 --- a/cmd/evm/disasm.go +++ b/cmd/evm/disasm.go @@ -46,8 +46,5 @@ func disasmCmd(ctx *cli.Context) error { code := strings.TrimSpace(string(in[:])) fmt.Printf("%v\n", code) - if err = asm.PrintDisassembled(code); err != nil { - return err - } - return nil + return asm.PrintDisassembled(code) } diff --git a/cmd/puppeth/ssh.go b/cmd/puppeth/ssh.go index 93668945c..26f846685 100644 --- a/cmd/puppeth/ssh.go +++ b/cmd/puppeth/ssh.go @@ -122,7 +122,7 @@ func dial(server string, pubkey []byte) (*sshClient, error) { } } // If a public key exists for this SSH server, check that it matches - if bytes.Compare(pubkey, key.Marshal()) == 0 { + if bytes.Equal(pubkey, key.Marshal()) { return nil } // We have a mismatch, forbid connecting diff --git a/cmd/puppeth/wizard.go b/cmd/puppeth/wizard.go index 288b67508..f19bcbbcd 100644 --- a/cmd/puppeth/wizard.go +++ b/cmd/puppeth/wizard.go @@ -160,6 +160,7 @@ func (w *wizard) readDefaultInt(def int) int { } } +/* // readFloat reads a single line from stdin, trimming if from spaces, enforcing it // to parse into a float. func (w *wizard) readFloat() float64 { @@ -180,6 +181,7 @@ func (w *wizard) readFloat() float64 { return val } } +*/ // readDefaultFloat reads a single line from stdin, trimming if from spaces, enforcing // it to parse into a float. If an empty line is entered, the default value is returned. diff --git a/cmd/puppeth/wizard_network.go b/cmd/puppeth/wizard_network.go index 0455e1ef3..ff2ff74f5 100644 --- a/cmd/puppeth/wizard_network.go +++ b/cmd/puppeth/wizard_network.go @@ -71,22 +71,20 @@ func (w *wizard) makeServer() string { fmt.Println() fmt.Println("Please enter remote server's address:") - for { - // Read and fial the server to ensure docker is present - input := w.readString() - - client, err := dial(input, nil) - if err != nil { - log.Error("Server not ready for puppeth", "err", err) - return "" - } - // All checks passed, start tracking the server - w.servers[input] = client - w.conf.Servers[input] = client.pubkey - w.conf.flush() + // Read and fial the server to ensure docker is present + input := w.readString() - return input + client, err := dial(input, nil) + if err != nil { + log.Error("Server not ready for puppeth", "err", err) + return "" } + // All checks passed, start tracking the server + w.servers[input] = client + w.conf.Servers[input] = client.pubkey + w.conf.flush() + + return input } // selectServer lists the user all the currnetly known servers to choose from, diff --git a/common/bitutil/compress_test.go b/common/bitutil/compress_test.go index 805ab0369..9bd1de103 100644 --- a/common/bitutil/compress_test.go +++ b/common/bitutil/compress_test.go @@ -121,20 +121,20 @@ func TestCompression(t *testing.T) { in := hexutil.MustDecode("0x4912385c0e7b64000000") out := hexutil.MustDecode("0x80fe4912385c0e7b64") - if data := CompressBytes(in); bytes.Compare(data, out) != 0 { + if data := CompressBytes(in); !bytes.Equal(data, out) { t.Errorf("encoding mismatch for sparse data: have %x, want %x", data, out) } - if data, err := DecompressBytes(out, len(in)); err != nil || bytes.Compare(data, in) != 0 { + if data, err := DecompressBytes(out, len(in)); err != nil || !bytes.Equal(data, in) { t.Errorf("decoding mismatch for sparse data: have %x, want %x, error %v", data, in, err) } // Check the the compression returns the input if the bitset encoding is longer in = hexutil.MustDecode("0xdf7070533534333636313639343638373532313536346c1bc33339343837313070706336343035336336346c65fefb3930393233383838ac2f65fefb") out = hexutil.MustDecode("0xdf7070533534333636313639343638373532313536346c1bc33339343837313070706336343035336336346c65fefb3930393233383838ac2f65fefb") - if data := CompressBytes(in); bytes.Compare(data, out) != 0 { + if data := CompressBytes(in); !bytes.Equal(data, out) { t.Errorf("encoding mismatch for dense data: have %x, want %x", data, out) } - if data, err := DecompressBytes(out, len(in)); err != nil || bytes.Compare(data, in) != 0 { + if data, err := DecompressBytes(out, len(in)); err != nil || !bytes.Equal(data, in) { t.Errorf("decoding mismatch for dense data: have %x, want %x, error %v", data, in, err) } // Check that decompressing a longer input than the target fails diff --git a/common/hexutil/json.go b/common/hexutil/json.go index 943288fad..11e14cae7 100644 --- a/common/hexutil/json.go +++ b/common/hexutil/json.go @@ -26,11 +26,10 @@ import ( ) var ( - textZero = []byte(`0x0`) - bytesT = reflect.TypeOf(Bytes(nil)) - bigT = reflect.TypeOf((*Big)(nil)) - uintT = reflect.TypeOf(Uint(0)) - uint64T = reflect.TypeOf(Uint64(0)) + bytesT = reflect.TypeOf(Bytes(nil)) + bigT = reflect.TypeOf((*Big)(nil)) + uintT = reflect.TypeOf(Uint(0)) + uint64T = reflect.TypeOf(Uint64(0)) ) // Bytes marshals/unmarshals as a JSON string with 0x prefix. diff --git a/console/console_test.go b/console/console_test.go index 0fc0e7051..8ac499bd1 100644 --- a/console/console_test.go +++ b/console/console_test.go @@ -77,8 +77,6 @@ type tester struct { console *Console input *hookedPrompter output *bytes.Buffer - - lastConfirm string } // newTester creates a test environment based on which the console can operate. diff --git a/core/tx_pool_test.go b/core/tx_pool_test.go index 80bc0b384..9a03caf61 100644 --- a/core/tx_pool_test.go +++ b/core/tx_pool_test.go @@ -750,14 +750,14 @@ func TestTransactionQueueTimeLimitingNoLocals(t *testing.T) { testTransactionQue func testTransactionQueueTimeLimiting(t *testing.T, nolocals bool) { // Reduce the eviction interval to a testable amount defer func(old time.Duration) { evictionInterval = old }(evictionInterval) - evictionInterval = 250 * time.Millisecond + evictionInterval = time.Second // Create the pool to test the non-expiration enforcement db, _ := ethdb.NewMemDatabase() statedb, _ := state.New(common.Hash{}, state.NewDatabase(db)) config := testTxPoolConfig - config.Lifetime = 250 * time.Millisecond + config.Lifetime = time.Second config.NoLocals = nolocals pool := NewTxPool(config, params.TestChainConfig, new(event.TypeMux), func() (*state.StateDB, error) { return statedb, nil }, func() *big.Int { return big.NewInt(1000000) }) diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go index 333c975c9..b75c5e6da 100644 --- a/ethstats/ethstats.go +++ b/ethstats/ethstats.go @@ -39,7 +39,6 @@ import ( "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/les" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/rpc" "golang.org/x/net/websocket" @@ -52,8 +51,6 @@ const historyUpdateRange = 50 // Service implements an Ethereum netstats reporting daemon that pushes local // chain statistics up to a monitoring server. type Service struct { - stack *node.Node // Temporary workaround, remove when API finalized - server *p2p.Server // Peer-to-peer server to retrieve networking infos eth *eth.Ethereum // Full Ethereum service if monitoring a full node les *les.LightEthereum // Light Ethereum service if monitoring a light node diff --git a/log/format.go b/log/format.go index 6c19c7a55..0b07abb2a 100644 --- a/log/format.go +++ b/log/format.go @@ -330,7 +330,7 @@ func escapeString(s string) string { needsEscape = true } } - if needsEscape == false && needsQuotes == false { + if !needsEscape && !needsQuotes { return s } e := stringBufPool.Get().(*bytes.Buffer) diff --git a/miner/remote_agent.go b/miner/remote_agent.go index bb223ba1b..aac7ce865 100644 --- a/miner/remote_agent.go +++ b/miner/remote_agent.go @@ -169,7 +169,8 @@ func (a *RemoteAgent) SubmitWork(nonce types.BlockNonce, mixDigest, hash common. // RemoteAgent.Start() constantly recreates these channels, so the loop code cannot // assume data stability in these member fields. func (a *RemoteAgent) loop(workCh chan *Work, quitCh chan struct{}) { - ticker := time.Tick(5 * time.Second) + ticker := time.NewTicker(5 * time.Second) + defer ticker.Stop() for { select { @@ -179,7 +180,7 @@ func (a *RemoteAgent) loop(workCh chan *Work, quitCh chan struct{}) { a.mu.Lock() a.currentWork = work a.mu.Unlock() - case <-ticker: + case <-ticker.C: // cleanup a.mu.Lock() for hash, work := range a.work { diff --git a/miner/worker.go b/miner/worker.go index 411bc4e1b..dab192c24 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -24,7 +24,6 @@ import ( "sync/atomic" "time" - "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/consensus/misc" @@ -109,9 +108,6 @@ type worker struct { uncleMu sync.Mutex possibleUncles map[common.Hash]*types.Block - txQueueMu sync.Mutex - txQueue map[common.Hash]*types.Transaction - unconfirmed *unconfirmedBlocks // set of locally mined blocks pending canonicalness confirmations // atomic status counters @@ -133,9 +129,8 @@ func newWorker(config *params.ChainConfig, engine consensus.Engine, coinbase com proc: eth.BlockChain().Validator(), possibleUncles: make(map[common.Hash]*types.Block), coinbase: coinbase, - txQueue: make(map[common.Hash]*types.Transaction), agents: make(map[Agent]struct{}), - unconfirmed: newUnconfirmedBlocks(eth.BlockChain(), 5), + unconfirmed: newUnconfirmedBlocks(eth.BlockChain(), miningLogAtDepth), fullValidation: false, } worker.events = worker.mux.Subscribe(core.ChainHeadEvent{}, core.ChainSideEvent{}, core.TxPreEvent{}) @@ -362,11 +357,7 @@ func (self *worker) makeCurrent(parent *types.Block, header *types.Header) error work.family.Add(ancestor.Hash()) work.ancestors.Add(ancestor.Hash()) } - wallets := self.eth.AccountManager().Wallets() - accounts := make([]accounts.Account, 0, len(wallets)) - for _, wallet := range wallets { - accounts = append(accounts, wallet.Accounts()...) - } + // Keep track of transactions which return errors so they can be removed work.tcount = 0 self.current = work diff --git a/node/config.go b/node/config.go index abbe64f43..e9693277a 100644 --- a/node/config.go +++ b/node/config.go @@ -35,7 +35,7 @@ import ( "github.com/ethereum/go-ethereum/p2p/discover" ) -var ( +const ( datadirPrivateKey = "nodekey" // Path within the datadir to the node's private key datadirDefaultKeyStore = "keystore" // Path within the datadir to the keystore datadirStaticNodes = "static-nodes.json" // Path within the datadir to the static node list @@ -160,7 +160,7 @@ func (c *Config) NodeDB() string { if c.DataDir == "" { return "" // ephemeral } - return c.resolvePath("nodes") + return c.resolvePath(datadirNodeDatabase) } // DefaultIPCEndpoint returns the IPC path used by default. diff --git a/node/utils_test.go b/node/utils_test.go index 7cdfc2b3a..8eddce3ed 100644 --- a/node/utils_test.go +++ b/node/utils_test.go @@ -41,12 +41,10 @@ func NewNoopService(*ServiceContext) (Service, error) { return new(NoopService), type NoopServiceA struct{ NoopService } type NoopServiceB struct{ NoopService } type NoopServiceC struct{ NoopService } -type NoopServiceD struct{ NoopService } func NewNoopServiceA(*ServiceContext) (Service, error) { return new(NoopServiceA), nil } func NewNoopServiceB(*ServiceContext) (Service, error) { return new(NoopServiceB), nil } func NewNoopServiceC(*ServiceContext) (Service, error) { return new(NoopServiceC), nil } -func NewNoopServiceD(*ServiceContext) (Service, error) { return new(NoopServiceD), nil } // InstrumentedService is an implementation of Service for which all interface // methods can be instrumented both return value as well as event hook wise. |