From 40adb7feb657cd1cb2e4c7a02c8a9db95b18e67c Mon Sep 17 00:00:00 2001 From: Maran Date: Mon, 23 Feb 2015 11:28:20 +0100 Subject: Implement OS sensitive dataDirs --- cmd/ethereum/flags.go | 11 +++-------- cmd/mist/flags.go | 10 +++------- 2 files changed, 6 insertions(+), 15 deletions(-) (limited to 'cmd') diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index 577bee442..7d410c8e4 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -26,10 +26,10 @@ import ( "fmt" "log" "os" - "os/user" "path" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/vm" @@ -79,12 +79,7 @@ var ( InputFile string ) -func defaultDataDir() string { - usr, _ := user.Current() - return path.Join(usr.HomeDir, ".ethereum") -} - -var defaultConfigFile = path.Join(defaultDataDir(), "conf.ini") +var defaultConfigFile = path.Join(ethutil.DefaultDataDir(), "conf.ini") func Init() { // TODO: move common flag processing to cmd/util @@ -107,7 +102,7 @@ func Init() { flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)") flag.StringVar(&ExportDir, "export", "", "exports the session keyring to files in the directory given") flag.StringVar(&LogFile, "logfile", "", "log file (defaults to standard output)") - flag.StringVar(&Datadir, "datadir", defaultDataDir(), "specifies the datadir to use") + flag.StringVar(&Datadir, "datadir", ethutil.DefaultDataDir(), "specifies the datadir to use") flag.StringVar(&ConfigFile, "conf", defaultConfigFile, "config file") flag.StringVar(&DebugFile, "debug", "", "debug file (no debugging if not set)") flag.IntVar(&LogLevel, "loglevel", int(logger.InfoLevel), "loglevel: 0-5: silent,error,warn,info,debug,debug detail)") diff --git a/cmd/mist/flags.go b/cmd/mist/flags.go index d9487de9e..d5ed60a21 100644 --- a/cmd/mist/flags.go +++ b/cmd/mist/flags.go @@ -26,13 +26,13 @@ import ( "fmt" "log" "os" - "os/user" "path" "path/filepath" "runtime" "bitbucket.org/kardianos/osext" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/vm" @@ -94,12 +94,8 @@ func defaultAssetPath() string { } return assetPath } -func defaultDataDir() string { - usr, _ := user.Current() - return path.Join(usr.HomeDir, ".ethereum") -} -var defaultConfigFile = path.Join(defaultDataDir(), "conf.ini") +var defaultConfigFile = path.Join(ethutil.DefaultDataDir(), "conf.ini") func Init() { // TODO: move common flag processing to cmd/utils @@ -121,7 +117,7 @@ func Init() { flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)") flag.StringVar(&ExportDir, "export", "", "exports the session keyring to files in the directory given") flag.StringVar(&LogFile, "logfile", "", "log file (defaults to standard output)") - flag.StringVar(&Datadir, "datadir", defaultDataDir(), "specifies the datadir to use") + flag.StringVar(&Datadir, "datadir", ethutil.DefaultDataDir(), "specifies the datadir to use") flag.StringVar(&ConfigFile, "conf", defaultConfigFile, "config file") flag.StringVar(&DebugFile, "debug", "", "debug file (no debugging if not set)") flag.IntVar(&LogLevel, "loglevel", int(logger.InfoLevel), "loglevel: 0-5: silent,error,warn,info,debug,debug detail)") -- cgit From b2a225a52e45315f3ec90e11707fefa6059d13f5 Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 23 Feb 2015 15:43:41 +0100 Subject: Properly uninstall filters. Mining issue fixed #closes #365 * Added an additional tx state which is used to get the current nonce * Refresh transient state each time a new canonical block is found * Properly uninstall filters. Fixes a possible crash in RPC --- cmd/mist/assets/examples/coin.html | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/assets/examples/coin.html b/cmd/mist/assets/examples/coin.html index 18a6811d7..509a9aeeb 100644 --- a/cmd/mist/assets/examples/coin.html +++ b/cmd/mist/assets/examples/coin.html @@ -19,6 +19,7 @@ Amount: +
@@ -95,17 +96,28 @@ } function transact() { - var to = document.querySelector("#address").value; - if( to.length == 0 ) { + var to = document.querySelector("#address"); + if( to.value.length == 0 ) { to = "0x4205b06c2cfa0e30359edcab94543266cb6fa1d3"; } else { - to = "0x"+to; + if (to.value.substr(0,2) != "0x") + to.value = "0x"+to.value; } - var value = parseInt( document.querySelector("#amount").value ); - console.log("transact: ", to, " => ", value) + var value = document.querySelector("#amount"); + var amount = parseInt( value.value ); + console.log("transact: ", to.value, " => ", amount) - contract.send( to, value ); + contract.send( to.value, amount ); + + to.value = ""; + value.value = ""; + + var message = document.querySelector("#message") + message.innerHTML = "Submitted"; + setTimeout(function() { + message.innerHTML = ""; + }, 1000); } refresh(); -- cgit From 8eeab7ea3fb7a01a610e46940141eecf7435873a Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 26 Feb 2015 02:24:20 +0100 Subject: Update osext import path --- cmd/mist/flags.go | 2 +- cmd/utils/cmd.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/flags.go b/cmd/mist/flags.go index d5ed60a21..c4edb8dae 100644 --- a/cmd/mist/flags.go +++ b/cmd/mist/flags.go @@ -30,12 +30,12 @@ import ( "path/filepath" "runtime" - "bitbucket.org/kardianos/osext" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/vm" + "github.com/kardianos/osext" ) var ( diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index bc8fafafb..d78b6a94d 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -30,7 +30,6 @@ import ( "regexp" "runtime" - "bitbucket.org/kardianos/osext" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth" @@ -42,6 +41,7 @@ import ( rpcws "github.com/ethereum/go-ethereum/rpc/ws" "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/xeth" + "github.com/kardianos/osext" ) var clilogger = logger.NewLogger("CLI") -- cgit From d5aed82b11589bb3f8b0df4544081fe898b8c724 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 26 Feb 2015 02:32:27 +0100 Subject: DRY DefaultAssetPath() --- cmd/mist/flags.go | 29 +---------------------------- cmd/utils/cmd.go | 26 -------------------------- 2 files changed, 1 insertion(+), 54 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/flags.go b/cmd/mist/flags.go index c4edb8dae..8dab59d80 100644 --- a/cmd/mist/flags.go +++ b/cmd/mist/flags.go @@ -68,33 +68,6 @@ var ( // flags specific to gui client var AssetPath string - -//TODO: If we re-use the one defined in cmd.go the binary osx image crashes. If somebody finds out why we can dry this up. -func defaultAssetPath() string { - var assetPath string - // If the current working directory is the go-ethereum dir - // assume a debug build and use the source directory as - // asset directory. - pwd, _ := os.Getwd() - if pwd == path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist") { - assetPath = path.Join(pwd, "assets") - } else { - switch runtime.GOOS { - case "darwin": - // Get Binary Directory - exedir, _ := osext.ExecutableFolder() - assetPath = filepath.Join(exedir, "../Resources") - case "linux": - assetPath = "/usr/share/mist" - case "windows": - assetPath = "./assets" - default: - assetPath = "." - } - } - return assetPath -} - var defaultConfigFile = path.Join(ethutil.DefaultDataDir(), "conf.ini") func Init() { @@ -122,7 +95,7 @@ func Init() { flag.StringVar(&DebugFile, "debug", "", "debug file (no debugging if not set)") flag.IntVar(&LogLevel, "loglevel", int(logger.InfoLevel), "loglevel: 0-5: silent,error,warn,info,debug,debug detail)") - flag.StringVar(&AssetPath, "asset_path", defaultAssetPath(), "absolute path to GUI assets directory") + flag.StringVar(&AssetPath, "asset_path", ethutil.DefaultAssetPath(), "absolute path to GUI assets directory") // Network stuff var ( diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index d78b6a94d..a65476e69 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -41,7 +41,6 @@ import ( rpcws "github.com/ethereum/go-ethereum/rpc/ws" "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/xeth" - "github.com/kardianos/osext" ) var clilogger = logger.NewLogger("CLI") @@ -132,31 +131,6 @@ func StartEthereum(ethereum *eth.Ethereum) { }) } -func DefaultAssetPath() string { - var assetPath string - // If the current working directory is the go-ethereum dir - // assume a debug build and use the source directory as - // asset directory. - pwd, _ := os.Getwd() - if pwd == path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist") { - assetPath = path.Join(pwd, "assets") - } else { - switch runtime.GOOS { - case "darwin": - // Get Binary Directory - exedir, _ := osext.ExecutableFolder() - assetPath = filepath.Join(exedir, "../Resources") - case "linux": - assetPath = "/usr/share/mist" - case "windows": - assetPath = "./assets" - default: - assetPath = "." - } - } - return assetPath -} - func KeyTasks(keyManager *crypto.KeyManager, KeyRing string, GenAddr bool, SecretFile string, ExportDir string, NonInteractive bool) { var err error -- cgit From 739b7cc2ac7de9c6c24547be00de81338089d724 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 26 Feb 2015 02:36:06 +0100 Subject: Cleanup imports --- cmd/mist/flags.go | 2 -- cmd/utils/cmd.go | 3 --- 2 files changed, 5 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/flags.go b/cmd/mist/flags.go index 8dab59d80..0010df826 100644 --- a/cmd/mist/flags.go +++ b/cmd/mist/flags.go @@ -27,7 +27,6 @@ import ( "log" "os" "path" - "path/filepath" "runtime" "github.com/ethereum/go-ethereum/crypto" @@ -35,7 +34,6 @@ import ( "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/vm" - "github.com/kardianos/osext" ) var ( diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index a65476e69..a36c10e3b 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -25,10 +25,7 @@ import ( "fmt" "os" "os/signal" - "path" - "path/filepath" "regexp" - "runtime" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" -- cgit From a1c830cd3c53bce7748d97e3f99fe6a90d526adb Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 26 Feb 2015 12:06:10 +0100 Subject: Defautl block --- cmd/mist/assets/examples/info.html | 7 +- cmd/mist/assets/ext/ethereum.js/dist/ethereum.js | 734 ++++++++++++++--------- 2 files changed, 457 insertions(+), 284 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/assets/examples/info.html b/cmd/mist/assets/examples/info.html index 2a405c280..3b958a494 100644 --- a/cmd/mist/assets/examples/info.html +++ b/cmd/mist/assets/examples/info.html @@ -62,6 +62,8 @@ web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8545')); + eth.defaultBlock = -2 + document.querySelector("#number").innerHTML = eth.number; document.querySelector("#coinbase").innerHTML = eth.coinbase document.querySelector("#peer_count").innerHTML = eth.peerCount; @@ -72,8 +74,9 @@ document.querySelector("#mining").innerHTML = eth.mining; document.querySelector("#listening").innerHTML = eth.listening; eth.watch('chain').changed(function() { - document.querySelector("#number").innerHTML = eth.number; - }); + document.querySelector("#number").innerHTML = eth.number; + }); + diff --git a/cmd/mist/assets/ext/ethereum.js/dist/ethereum.js b/cmd/mist/assets/ext/ethereum.js/dist/ethereum.js index 83b598b3f..522b77ebf 100644 --- a/cmd/mist/assets/ext/ethereum.js/dist/ethereum.js +++ b/cmd/mist/assets/ext/ethereum.js/dist/ethereum.js @@ -53,7 +53,6 @@ var inputTypes = types.inputTypes(); /// @returns bytes representation of input params var formatInput = function (inputs, params) { var bytes = ""; - var padding = c.ETH_PADDING * 2; /// first we iterate in search for dynamic inputs.forEach(function (input, index) { @@ -110,6 +109,7 @@ var formatOutput = function (outs, output) { output = output.slice(dynamicPartLength); outs.forEach(function (out, i) { + /*jshint maxcomplexity:6 */ var typeMatch = false; for (var j = 0; j < outputTypes.length && !typeMatch; j++) { typeMatch = outputTypes[j].type(outs[i].type); @@ -210,7 +210,7 @@ module.exports = { }; -},{"./const":2,"./formatters":6,"./types":11,"./utils":12,"./web3":13}],2:[function(require,module,exports){ +},{"./const":2,"./formatters":8,"./types":14,"./utils":15,"./web3":17}],2:[function(require,module,exports){ /* This file is part of ethereum.js. @@ -264,7 +264,8 @@ module.exports = { ETH_PADDING: 32, ETH_SIGNATURE_LENGTH: 4, ETH_UNITS: ETH_UNITS, - ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN } + ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN }, + ETH_POLLING_TIMEOUT: 1000 }; @@ -340,6 +341,7 @@ var addFunctionsToContract = function (contract, desc, address) { var typeName = utils.extractTypeName(method.name); var impl = function () { + /*jshint maxcomplexity:7 */ var params = Array.prototype.slice.call(arguments); var signature = abi.signatureFromAscii(method.name); var parsed = inputParser[displayName][typeName].apply(null, params); @@ -416,11 +418,11 @@ var addEventsToContract = function (contract, desc, address) { var signature = abi.eventSignatureFromAscii(e.name); var event = eventImpl.inputParser(address, signature, e); var o = event.apply(null, params); - o._onWatchEventResult = function (data) { + var outputFormatter = function (data) { var parser = eventImpl.outputParser(e); return parser(data); }; - return web3.eth.watch(o); + return web3.eth.watch(o, undefined, undefined, outputFormatter); }; // this property should be used by eth.filter to check if object is an event @@ -487,7 +489,131 @@ var contract = function (address, desc) { module.exports = contract; -},{"./abi":1,"./event":4,"./utils":12,"./web3":13}],4:[function(require,module,exports){ +},{"./abi":1,"./event":6,"./utils":15,"./web3":17}],4:[function(require,module,exports){ +/* + This file is part of ethereum.js. + + ethereum.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + ethereum.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with ethereum.js. If not, see . +*/ +/** @file db.js + * @authors: + * Marek Kotewicz + * @date 2015 + */ + +/// @returns an array of objects describing web3.db api methods +var methods = function () { + return [ + { name: 'put', call: 'db_put' }, + { name: 'get', call: 'db_get' }, + { name: 'putString', call: 'db_putString' }, + { name: 'getString', call: 'db_getString' } + ]; +}; + +module.exports = { + methods: methods +}; + +},{}],5:[function(require,module,exports){ +/* + This file is part of ethereum.js. + + ethereum.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + ethereum.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with ethereum.js. If not, see . +*/ +/** @file eth.js + * @authors: + * Marek Kotewicz + * @date 2015 + */ + +/// @returns an array of objects describing web3.eth api methods +var methods = function () { + var blockCall = function (args) { + return typeof args[0] === "string" ? "eth_blockByHash" : "eth_blockByNumber"; + }; + + var transactionCall = function (args) { + return typeof args[0] === "string" ? 'eth_transactionByHash' : 'eth_transactionByNumber'; + }; + + var uncleCall = function (args) { + return typeof args[0] === "string" ? 'eth_uncleByHash' : 'eth_uncleByNumber'; + }; + + var transactionCountCall = function (args) { + return typeof args[0] === "string" ? 'eth_transactionCountByHash' : 'eth_transactionCountByNumber'; + }; + + var uncleCountCall = function (args) { + return typeof args[0] === "string" ? 'eth_uncleCountByHash' : 'eth_uncleCountByNumber'; + }; + + return [ + { name: 'balanceAt', call: 'eth_balanceAt' }, + { name: 'stateAt', call: 'eth_stateAt' }, + { name: 'storageAt', call: 'eth_storageAt' }, + { name: 'countAt', call: 'eth_countAt'}, + { name: 'codeAt', call: 'eth_codeAt' }, + { name: 'transact', call: 'eth_transact' }, + { name: 'call', call: 'eth_call' }, + { name: 'block', call: blockCall }, + { name: 'transaction', call: transactionCall }, + { name: 'uncle', call: uncleCall }, + { name: 'compilers', call: 'eth_compilers' }, + { name: 'flush', call: 'eth_flush' }, + { name: 'lll', call: 'eth_lll' }, + { name: 'solidity', call: 'eth_solidity' }, + { name: 'serpent', call: 'eth_serpent' }, + { name: 'logs', call: 'eth_logs' }, + { name: 'transactionCount', call: transactionCountCall }, + { name: 'uncleCount', call: uncleCountCall } + ]; +}; + +/// @returns an array of objects describing web3.eth api properties +var properties = function () { + return [ + { name: 'coinbase', getter: 'eth_coinbase', setter: 'eth_setCoinbase' }, + { name: 'listening', getter: 'eth_listening', setter: 'eth_setListening' }, + { name: 'mining', getter: 'eth_mining', setter: 'eth_setMining' }, + { name: 'gasPrice', getter: 'eth_gasPrice' }, + { name: 'accounts', getter: 'eth_accounts' }, + { name: 'peerCount', getter: 'eth_peerCount' }, + { name: 'defaultBlock', getter: 'eth_defaultBlock', setter: 'eth_setDefaultBlock' }, + { name: 'number', getter: 'eth_number'} + ]; +}; + +module.exports = { + methods: methods, + properties: properties +}; + + +},{}],6:[function(require,module,exports){ /* This file is part of ethereum.js. @@ -571,9 +697,9 @@ var getArgumentsObject = function (inputs, indexed, notIndexed) { return inputs.reduce(function (acc, current) { var value; if (current.indexed) - value = indexed.splice(0, 1)[0]; + value = indexedCopy.splice(0, 1)[0]; else - value = notIndexed.splice(0, 1)[0]; + value = notIndexedCopy.splice(0, 1)[0]; acc[current.name] = value; return acc; @@ -589,6 +715,7 @@ var outputParser = function (event) { args: {} }; + output.topics = output.topic; // fallback for go-ethereum if (!output.topic) { return result; } @@ -624,7 +751,7 @@ module.exports = { }; -},{"./abi":1,"./utils":12}],5:[function(require,module,exports){ +},{"./abi":1,"./utils":15}],7:[function(require,module,exports){ /* This file is part of ethereum.js. @@ -650,84 +777,96 @@ module.exports = { * @date 2014 */ -var web3 = require('./web3'); // jshint ignore:line - -/// should be used when we want to watch something -/// it's using inner polling mechanism and is notified about changes -/// TODO: change 'options' name cause it may be not the best matching one, since we have events -var Filter = function(options, impl) { - - if (typeof options !== "string") { - - // topics property is deprecated, warn about it! - if (options.topics) { - console.warn('"topics" is deprecated, use "topic" instead'); - } - - this._onWatchResult = options._onWatchEventResult; - - // evaluate lazy properties - options = { - to: options.to, - topic: options.topic, - earliest: options.earliest, - latest: options.latest, - max: options.max, - skip: options.skip, - address: options.address - }; - +/// Should be called to check if filter implementation is valid +/// @returns true if it is, otherwise false +var implementationIsValid = function (i) { + return !!i && + typeof i.newFilter === 'function' && + typeof i.getMessages === 'function' && + typeof i.uninstallFilter === 'function' && + typeof i.startPolling === 'function' && + typeof i.stopPolling === 'function'; +}; + +/// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones +/// @param should be string or object +/// @returns options string or object +var getOptions = function (options) { + if (typeof options === 'string') { + return options; + } + + options = options || {}; + + if (options.topics) { + console.warn('"topics" is deprecated, is "topic" instead'); } - - this.impl = impl; - this.callbacks = []; - this.id = impl.newFilter(options); - web3.provider.startPolling({method: impl.changed, params: [this.id]}, this.id, this.trigger.bind(this)); + // evaluate lazy properties + return { + to: options.to, + topic: options.topic, + earliest: options.earliest, + latest: options.latest, + max: options.max, + skip: options.skip, + address: options.address + }; }; -/// alias for changed* -Filter.prototype.arrived = function(callback) { - this.changed(callback); -}; -Filter.prototype.happened = function(callback) { - this.changed(callback); -}; +/// Should be used when we want to watch something +/// it's using inner polling mechanism and is notified about changes +/// @param options are filter options +/// @param implementation, an abstract polling implementation +/// @param formatter (optional), callback function which formats output before 'real' callback +var filter = function(options, implementation, formatter) { + if (!implementationIsValid(implementation)) { + console.error('filter implemenation is invalid'); + return; + } -/// gets called when there is new eth/shh message -Filter.prototype.changed = function(callback) { - this.callbacks.push(callback); -}; + options = getOptions(options); + var callbacks = []; + var filterId = implementation.newFilter(options); + var onMessages = function (messages) { + messages.forEach(function (message) { + message = formatter ? formatter(message) : message; + callbacks.forEach(function (callback) { + callback(message); + }); + }); + }; -/// trigger calling new message from people -Filter.prototype.trigger = function(messages) { - for (var i = 0; i < this.callbacks.length; i++) { - for (var j = 0; j < messages.length; j++) { - var message = this._onWatchResult ? this._onWatchResult(messages[j]) : messages[j]; - this.callbacks[i].call(this, message); - } - } -}; + implementation.startPolling(filterId, onMessages, implementation.uninstallFilter); -/// should be called to uninstall current filter -Filter.prototype.uninstall = function() { - this.impl.uninstallFilter(this.id); - web3.provider.stopPolling(this.id); -}; + var changed = function (callback) { + callbacks.push(callback); + }; -/// should be called to manually trigger getting latest messages from the client -Filter.prototype.messages = function() { - return this.impl.getMessages(this.id); -}; + var messages = function () { + return implementation.getMessages(filterId); + }; + + var uninstall = function () { + implementation.stopPolling(filterId); + implementation.uninstallFilter(filterId); + callbacks = []; + }; -/// alias for messages -Filter.prototype.logs = function () { - return this.messages(); + return { + changed: changed, + arrived: changed, + happened: changed, + messages: messages, + logs: messages, + uninstall: uninstall + }; }; -module.exports = Filter; +module.exports = filter; + -},{"./web3":13}],6:[function(require,module,exports){ +},{}],8:[function(require,module,exports){ /* This file is part of ethereum.js. @@ -770,6 +909,7 @@ var padLeft = function (string, chars, sign) { /// If the value is floating point, round it down /// @returns right-aligned byte representation of int var formatInputInt = function (value) { + /*jshint maxcomplexity:7 */ var padding = c.ETH_PADDING * 2; if (value instanceof BigNumber || typeof value === 'number') { if (typeof value === 'number') @@ -883,7 +1023,7 @@ module.exports = { }; -},{"./const":2,"./utils":12}],7:[function(require,module,exports){ +},{"./const":2,"./utils":15}],9:[function(require,module,exports){ /* This file is part of ethereum.js. @@ -918,20 +1058,22 @@ var HttpSyncProvider = function (host) { HttpSyncProvider.prototype.send = function (payload) { //var data = formatJsonRpcObject(payload); - + var request = new XMLHttpRequest(); request.open('POST', this.host, false); request.send(JSON.stringify(payload)); - - // check request.status + var result = request.responseText; + // check request.status + if(request.status !== 200) + return; return JSON.parse(result); }; module.exports = HttpSyncProvider; -},{}],8:[function(require,module,exports){ +},{}],10:[function(require,module,exports){ /* This file is part of ethereum.js. @@ -998,7 +1140,7 @@ module.exports = { -},{}],9:[function(require,module,exports){ +},{}],11:[function(require,module,exports){ /* This file is part of ethereum.js. @@ -1015,7 +1157,42 @@ module.exports = { You should have received a copy of the GNU Lesser General Public License along with ethereum.js. If not, see . */ -/** @file providermanager.js +/** @file qtsync.js + * @authors: + * Marek Kotewicz + * Marian Oancea + * @date 2014 + */ + +var QtSyncProvider = function () { +}; + +QtSyncProvider.prototype.send = function (payload) { + var result = navigator.qt.callMethod(JSON.stringify(payload)); + return JSON.parse(result); +}; + +module.exports = QtSyncProvider; + + +},{}],12:[function(require,module,exports){ +/* + This file is part of ethereum.js. + + ethereum.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + ethereum.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with ethereum.js. If not, see . +*/ +/** @file requestmanager.js * @authors: * Jeffrey Wilcke * Marek Kotewicz @@ -1024,85 +1201,95 @@ module.exports = { * @date 2014 */ -var web3 = require('./web3'); var jsonrpc = require('./jsonrpc'); - +var c = require('./const'); /** - * Provider manager object prototype * It's responsible for passing messages to providers - * If no provider is set it's responsible for queuing requests * It's also responsible for polling the ethereum node for incoming messages - * Default poll timeout is 12 seconds - * If we are running ethereum.js inside ethereum browser, there are backend based tools responsible for polling, - * and provider manager polling mechanism is not used + * Default poll timeout is 1 second */ -var ProviderManager = function() { - this.polls = []; - this.provider = undefined; +var requestManager = function() { + var polls = []; + var timeout = null; + var provider; - var self = this; - var poll = function () { - self.polls.forEach(function (data) { - var result = self.send(data.data); - - if (!(result instanceof Array) || result.length === 0) { - return; - } + var send = function (data) { + var payload = jsonrpc.toPayload(data.method, data.params); + + if (!provider) { + console.error('provider is not set'); + return null; + } - data.callback(result); - }); + var result = provider.send(payload); - setTimeout(poll, 1000); + if (!jsonrpc.isValidResponse(result)) { + console.log(result); + return null; + } + + return result.result; }; - poll(); -}; - -/// sends outgoing requests -/// @params data - an object with at least 'method' property -ProviderManager.prototype.send = function(data) { - var payload = jsonrpc.toPayload(data.method, data.params); - if (this.provider === undefined) { - console.error('provider is not set'); - return null; - } + var setProvider = function (p) { + provider = p; + }; - var result = this.provider.send(payload); + /*jshint maxparams:4 */ + var startPolling = function (data, pollId, callback, uninstall) { + polls.push({data: data, id: pollId, callback: callback, uninstall: uninstall}); + }; + /*jshint maxparams:3 */ - if (!jsonrpc.isValidResponse(result)) { - console.log(result); - return null; - } + var stopPolling = function (pollId) { + for (var i = polls.length; i--;) { + var poll = polls[i]; + if (poll.id === pollId) { + polls.splice(i, 1); + } + } + }; - return result.result; -}; + var reset = function () { + polls.forEach(function (poll) { + poll.uninstall(poll.id); + }); + polls = []; -/// setups provider, which will be used for sending messages -ProviderManager.prototype.set = function(provider) { - this.provider = provider; -}; + if (timeout) { + clearTimeout(timeout); + timeout = null; + } + poll(); + }; -/// this method is only used, when we do not have native qt bindings and have to do polling on our own -/// should be callled, on start watching for eth/shh changes -ProviderManager.prototype.startPolling = function (data, pollId, callback) { - this.polls.push({data: data, id: pollId, callback: callback}); -}; + var poll = function () { + polls.forEach(function (data) { + var result = send(data.data); + if (!(result instanceof Array) || result.length === 0) { + return; + } + data.callback(result); + }); + timeout = setTimeout(poll, c.ETH_POLLING_TIMEOUT); + }; + + poll(); -/// should be called to stop polling for certain watch changes -ProviderManager.prototype.stopPolling = function (pollId) { - for (var i = this.polls.length; i--;) { - var poll = this.polls[i]; - if (poll.id === pollId) { - this.polls.splice(i, 1); - } - } + return { + send: send, + setProvider: setProvider, + startPolling: startPolling, + stopPolling: stopPolling, + reset: reset + }; }; -module.exports = ProviderManager; +module.exports = requestManager; -},{"./jsonrpc":8,"./web3":13}],10:[function(require,module,exports){ +},{"./const":2,"./jsonrpc":10}],13:[function(require,module,exports){ /* This file is part of ethereum.js. @@ -1119,25 +1306,29 @@ module.exports = ProviderManager; You should have received a copy of the GNU Lesser General Public License along with ethereum.js. If not, see . */ -/** @file qtsync.js +/** @file shh.js * @authors: * Marek Kotewicz - * Marian Oancea - * @date 2014 + * @date 2015 */ -var QtSyncProvider = function () { +/// @returns an array of objects describing web3.shh api methods +var methods = function () { + return [ + { name: 'post', call: 'shh_post' }, + { name: 'newIdentity', call: 'shh_newIdentity' }, + { name: 'haveIdentity', call: 'shh_haveIdentity' }, + { name: 'newGroup', call: 'shh_newGroup' }, + { name: 'addToGroup', call: 'shh_addToGroup' } + ]; }; -QtSyncProvider.prototype.send = function (payload) { - var result = navigator.qt.callMethod(JSON.stringify(payload)); - return JSON.parse(result); +module.exports = { + methods: methods }; -module.exports = QtSyncProvider; - -},{}],11:[function(require,module,exports){ +},{}],14:[function(require,module,exports){ /* This file is part of ethereum.js. @@ -1218,7 +1409,7 @@ module.exports = { }; -},{"./formatters":6}],12:[function(require,module,exports){ +},{"./formatters":8}],15:[function(require,module,exports){ /* This file is part of ethereum.js. @@ -1328,6 +1519,7 @@ var filterEvents = function (json) { /// TODO: use BigNumber.js to parse int /// TODO: add tests for it! var toEth = function (str) { + /*jshint maxcomplexity:7 */ var val = typeof str === "string" ? str.indexOf('0x') === 0 ? parseInt(str.substr(2), 16) : parseInt(str) : str; var unit = 0; var units = c.ETH_UNITS; @@ -1362,7 +1554,7 @@ module.exports = { }; -},{"./const":2}],13:[function(require,module,exports){ +},{"./const":2}],16:[function(require,module,exports){ /* This file is part of ethereum.js. @@ -1379,102 +1571,14 @@ module.exports = { You should have received a copy of the GNU Lesser General Public License along with ethereum.js. If not, see . */ -/** @file web3.js +/** @file watches.js * @authors: - * Jeffrey Wilcke * Marek Kotewicz - * Marian Oancea - * Gav Wood - * @date 2014 + * @date 2015 */ -if ("build" !== 'build') {/* - var BigNumber = require('bignumber.js'); -*/} - -var utils = require('./utils'); - -/// @returns an array of objects describing web3 api methods -var web3Methods = function () { - return [ - { name: 'sha3', call: 'web3_sha3' } - ]; -}; - -/// @returns an array of objects describing web3.eth api methods -var ethMethods = function () { - var blockCall = function (args) { - return typeof args[0] === "string" ? "eth_blockByHash" : "eth_blockByNumber"; - }; - - var transactionCall = function (args) { - return typeof args[0] === "string" ? 'eth_transactionByHash' : 'eth_transactionByNumber'; - }; - - var uncleCall = function (args) { - return typeof args[0] === "string" ? 'eth_uncleByHash' : 'eth_uncleByNumber'; - }; - - var methods = [ - { name: 'balanceAt', call: 'eth_balanceAt' }, - { name: 'register', call: 'eth_register' }, - { name: 'unregister', call: 'eth_unregister' }, - { name: 'stateAt', call: 'eth_stateAt' }, - { name: 'storageAt', call: 'eth_storageAt' }, - { name: 'countAt', call: 'eth_countAt'}, - { name: 'codeAt', call: 'eth_codeAt' }, - { name: 'transact', call: 'eth_transact' }, - { name: 'call', call: 'eth_call' }, - { name: 'block', call: blockCall }, - { name: 'transaction', call: transactionCall }, - { name: 'uncle', call: uncleCall }, - { name: 'compilers', call: 'eth_compilers' }, - { name: 'flush', call: 'eth_flush' }, - { name: 'lll', call: 'eth_lll' }, - { name: 'solidity', call: 'eth_solidity' }, - { name: 'serpent', call: 'eth_serpent' }, - { name: 'logs', call: 'eth_logs' } - ]; - return methods; -}; - -/// @returns an array of objects describing web3.eth api properties -var ethProperties = function () { - return [ - { name: 'coinbase', getter: 'eth_coinbase', setter: 'eth_setCoinbase' }, - { name: 'listening', getter: 'eth_listening', setter: 'eth_setListening' }, - { name: 'mining', getter: 'eth_mining', setter: 'eth_setMining' }, - { name: 'gasPrice', getter: 'eth_gasPrice' }, - { name: 'accounts', getter: 'eth_accounts' }, - { name: 'peerCount', getter: 'eth_peerCount' }, - { name: 'defaultBlock', getter: 'eth_defaultBlock', setter: 'eth_setDefaultBlock' }, - { name: 'number', getter: 'eth_number'} - ]; -}; - -/// @returns an array of objects describing web3.db api methods -var dbMethods = function () { - return [ - { name: 'put', call: 'db_put' }, - { name: 'get', call: 'db_get' }, - { name: 'putString', call: 'db_putString' }, - { name: 'getString', call: 'db_getString' } - ]; -}; - -/// @returns an array of objects describing web3.shh api methods -var shhMethods = function () { - return [ - { name: 'post', call: 'shh_post' }, - { name: 'newIdentity', call: 'shh_newIdentity' }, - { name: 'haveIdentity', call: 'shh_haveIdentity' }, - { name: 'newGroup', call: 'shh_newGroup' }, - { name: 'addToGroup', call: 'shh_addToGroup' } - ]; -}; - /// @returns an array of objects describing web3.eth.watch api methods -var ethWatchMethods = function () { +var eth = function () { var newFilter = function (args) { return typeof args[0] === 'string' ? 'eth_newFilterString' : 'eth_newFilter'; }; @@ -1487,7 +1591,7 @@ var ethWatchMethods = function () { }; /// @returns an array of objects describing web3.shh.watch api methods -var shhWatchMethods = function () { +var shh = function () { return [ { name: 'newFilter', call: 'shh_newFilter' }, { name: 'uninstallFilter', call: 'shh_uninstallFilter' }, @@ -1495,6 +1599,57 @@ var shhWatchMethods = function () { ]; }; +module.exports = { + eth: eth, + shh: shh +}; + + +},{}],17:[function(require,module,exports){ +/* + This file is part of ethereum.js. + + ethereum.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + ethereum.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with ethereum.js. If not, see . +*/ +/** @file web3.js + * @authors: + * Jeffrey Wilcke + * Marek Kotewicz + * Marian Oancea + * Gav Wood + * @date 2014 + */ + +if ("build" !== 'build') {/* + var BigNumber = require('bignumber.js'); +*/} + +var eth = require('./eth'); +var db = require('./db'); +var shh = require('./shh'); +var watches = require('./watches'); +var filter = require('./filter'); +var utils = require('./utils'); +var requestManager = require('./requestmanager'); + +/// @returns an array of objects describing web3 api methods +var web3Methods = function () { + return [ + { name: 'sha3', call: 'web3_sha3' } + ]; +}; + /// creates methods in a given object based on method description on input /// setups api calls for these methods var setupMethods = function (obj, methods) { @@ -1502,7 +1657,7 @@ var setupMethods = function (obj, methods) { obj[method.name] = function () { var args = Array.prototype.slice.call(arguments); var call = typeof method.call === 'function' ? method.call(args) : method.call; - return web3.provider.send({ + return web3.manager.send({ method: call, params: args }); @@ -1516,14 +1671,14 @@ var setupProperties = function (obj, properties) { properties.forEach(function (property) { var proto = {}; proto.get = function () { - return web3.provider.send({ + return web3.manager.send({ method: property.getter }); }; if (property.setter) { proto.set = function (val) { - return web3.provider.send({ + return web3.manager.send({ method: property.setter, params: [val] }); @@ -1533,10 +1688,32 @@ var setupProperties = function (obj, properties) { }); }; +/*jshint maxparams:4 */ +var startPolling = function (method, id, callback, uninstall) { + web3.manager.startPolling({ + method: method, + params: [id] + }, id, callback, uninstall); +}; +/*jshint maxparams:3 */ + +var stopPolling = function (id) { + web3.manager.stopPolling(id); +}; + +var ethWatch = { + startPolling: startPolling.bind(null, 'eth_changed'), + stopPolling: stopPolling +}; + +var shhWatch = { + startPolling: startPolling.bind(null, 'shh_changed'), + stopPolling: stopPolling +}; + /// setups web3 object, and it's in-browser executed methods var web3 = { - _callbacks: {}, - _events: {}, + manager: requestManager(), providers: {}, /// @returns ascii string representation of hex value prefixed with 0x @@ -1575,12 +1752,15 @@ var web3 = { /// @param filter may be a string, object or event /// @param indexed is optional, this is an object with optional event indexed params /// @param options is optional, this is an object with optional event options ('max'...) - watch: function (filter, indexed, options) { - if (filter._isEvent) { - return filter(indexed, options); + /// TODO: fix it, 4 params? no way + /*jshint maxparams:4 */ + watch: function (fil, indexed, options, formatter) { + if (fil._isEvent) { + return fil(indexed, options); } - return new web3.filter(filter, ethWatch); + return filter(fil, ethWatch, formatter); } + /*jshint maxparams:3 */ }, /// db object prototype @@ -1588,54 +1768,44 @@ var web3 = { /// shh object prototype shh: { - /// @param filter may be a string, object or event - watch: function (filter, indexed) { - return new web3.filter(filter, shhWatch); + watch: function (fil) { + return filter(fil, shhWatch); } }, + setProvider: function (provider) { + web3.manager.setProvider(provider); + }, + + /// Should be called to reset state of web3 object + /// Resets everything except manager + reset: function () { + web3.manager.reset(); + } }; /// setups all api methods setupMethods(web3, web3Methods()); -setupMethods(web3.eth, ethMethods()); -setupProperties(web3.eth, ethProperties()); -setupMethods(web3.db, dbMethods()); -setupMethods(web3.shh, shhMethods()); - -var ethWatch = { - changed: 'eth_changed' -}; - -setupMethods(ethWatch, ethWatchMethods()); - -var shhWatch = { - changed: 'shh_changed' -}; - -setupMethods(shhWatch, shhWatchMethods()); - -web3.setProvider = function(provider) { - web3.provider.set(provider); -}; +setupMethods(web3.eth, eth.methods()); +setupProperties(web3.eth, eth.properties()); +setupMethods(web3.db, db.methods()); +setupMethods(web3.shh, shh.methods()); +setupMethods(ethWatch, watches.eth()); +setupMethods(shhWatch, watches.shh()); module.exports = web3; -},{"./utils":12}],"web3":[function(require,module,exports){ +},{"./db":4,"./eth":5,"./filter":7,"./requestmanager":12,"./shh":13,"./utils":15,"./watches":16}],"web3":[function(require,module,exports){ var web3 = require('./lib/web3'); -var ProviderManager = require('./lib/providermanager'); -web3.provider = new ProviderManager(); -web3.filter = require('./lib/filter'); web3.providers.HttpSyncProvider = require('./lib/httpsync'); web3.providers.QtSyncProvider = require('./lib/qtsync'); web3.eth.contract = require('./lib/contract'); web3.abi = require('./lib/abi'); - module.exports = web3; -},{"./lib/abi":1,"./lib/contract":3,"./lib/filter":5,"./lib/httpsync":7,"./lib/providermanager":9,"./lib/qtsync":10,"./lib/web3":13}]},{},["web3"]) +},{"./lib/abi":1,"./lib/contract":3,"./lib/httpsync":9,"./lib/qtsync":11,"./lib/web3":17}]},{},["web3"]) //# sourceMappingURL=ethereum.js.map -- cgit From 3ab05ddd25aa805510ac304c1fd8f7c5c620dff4 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 26 Feb 2015 20:26:37 +0100 Subject: Bump --- cmd/ethereum/main.go | 2 +- cmd/mist/assets/qml/main.qml | 2 +- cmd/mist/main.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'cmd') diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index 9c840de58..45e6f7b93 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -37,7 +37,7 @@ import ( const ( ClientIdentifier = "Ethereum(G)" - Version = "0.8.5" + Version = "0.8.6" ) var clilogger = logger.NewLogger("CLI") diff --git a/cmd/mist/assets/qml/main.qml b/cmd/mist/assets/qml/main.qml index e80bd87e0..a909916b7 100644 --- a/cmd/mist/assets/qml/main.qml +++ b/cmd/mist/assets/qml/main.qml @@ -964,7 +964,7 @@ ApplicationWindow { anchors.top: parent.top anchors.topMargin: 30 font.pointSize: 12 - text: "

Mist (0.8.5)


Development

Jeffrey Wilcke
Viktor Trón
Felix Lange
Taylor Gerring
Daniel Nagy
Gustav Simonsson

UX/UI

Alex van de Sande
Fabian Vogelsteller" + text: "

Mist (0.8.6)


Development

Jeffrey Wilcke
Viktor Trón
Felix Lange
Taylor Gerring
Daniel Nagy
Gustav Simonsson

UX/UI

Alex van de Sande
Fabian Vogelsteller" } } diff --git a/cmd/mist/main.go b/cmd/mist/main.go index ad6eb5bec..3abe16767 100644 --- a/cmd/mist/main.go +++ b/cmd/mist/main.go @@ -36,7 +36,7 @@ import ( const ( ClientIdentifier = "Mist" - Version = "0.8.5" + Version = "0.8.6" ) var ethereum *eth.Ethereum -- cgit From f6e821fd335911c26d515094ac0af4fa69526279 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sat, 28 Feb 2015 01:00:42 +0100 Subject: Add flag to set RPC port --- cmd/ethereum/flags.go | 70 ++++++++++++++++++++++++++------------------------- cmd/ethereum/main.go | 2 +- cmd/mist/flags.go | 52 ++++++++++++++++++++------------------ cmd/mist/main.go | 2 +- cmd/utils/cmd.go | 4 +-- 5 files changed, 67 insertions(+), 63 deletions(-) (limited to 'cmd') diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index 7d410c8e4..79a60039c 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -36,40 +36,41 @@ import ( ) var ( - Identifier string - KeyRing string - DiffTool bool - DiffType string - KeyStore string - StartRpc bool - StartWebSockets bool - RpcPort int - WsPort int - OutboundPort string - ShowGenesis bool - AddPeer string - MaxPeer int - GenAddr bool - BootNodes string - NodeKey *ecdsa.PrivateKey - NAT nat.Interface - SecretFile string - ExportDir string - NonInteractive bool - Datadir string - LogFile string - ConfigFile string - DebugFile string - LogLevel int - LogFormat string - Dump bool - DumpHash string - DumpNumber int - VmType int - ImportChain string - SHH bool - Dial bool - PrintVersion bool + Identifier string + KeyRing string + DiffTool bool + DiffType string + KeyStore string + StartRpc bool + StartWebSockets bool + RpcListenAddress string + RpcPort int + WsPort int + OutboundPort string + ShowGenesis bool + AddPeer string + MaxPeer int + GenAddr bool + BootNodes string + NodeKey *ecdsa.PrivateKey + NAT nat.Interface + SecretFile string + ExportDir string + NonInteractive bool + Datadir string + LogFile string + ConfigFile string + DebugFile string + LogLevel int + LogFormat string + Dump bool + DumpHash string + DumpNumber int + VmType int + ImportChain string + SHH bool + Dial bool + PrintVersion bool ) // flags specific to cli client @@ -93,6 +94,7 @@ func Init() { flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use") flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)") + flag.StringVar(&RpcListenAddress, "rpcaddr", "127.0.0.1", "address for json-rpc server to listen on") flag.IntVar(&RpcPort, "rpcport", 8545, "port to start json-rpc server on") flag.IntVar(&WsPort, "wsport", 40404, "port to start websocket rpc server on") flag.BoolVar(&StartRpc, "rpc", false, "start rpc server") diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index 45e6f7b93..8afab5d28 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -128,7 +128,7 @@ func main() { } if StartRpc { - utils.StartRpc(ethereum, RpcPort) + utils.StartRpc(ethereum, RpcListenAddress, RpcPort) } if StartWebSockets { diff --git a/cmd/mist/flags.go b/cmd/mist/flags.go index 0010df826..1ffeb1915 100644 --- a/cmd/mist/flags.go +++ b/cmd/mist/flags.go @@ -37,31 +37,32 @@ import ( ) var ( - Identifier string - KeyRing string - KeyStore string - StartRpc bool - StartWebSockets bool - RpcPort int - WsPort int - OutboundPort string - ShowGenesis bool - AddPeer string - MaxPeer int - GenAddr bool - BootNodes string - NodeKey *ecdsa.PrivateKey - NAT nat.Interface - SecretFile string - ExportDir string - NonInteractive bool - Datadir string - LogFile string - ConfigFile string - DebugFile string - LogLevel int - VmType int - MinerThreads int + Identifier string + KeyRing string + KeyStore string + StartRpc bool + StartWebSockets bool + RpcListenAddress string + RpcPort int + WsPort int + OutboundPort string + ShowGenesis bool + AddPeer string + MaxPeer int + GenAddr bool + BootNodes string + NodeKey *ecdsa.PrivateKey + NAT nat.Interface + SecretFile string + ExportDir string + NonInteractive bool + Datadir string + LogFile string + ConfigFile string + DebugFile string + LogLevel int + VmType int + MinerThreads int ) // flags specific to gui client @@ -79,6 +80,7 @@ func Init() { flag.StringVar(&Identifier, "id", "", "Custom client identifier") flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use") flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)") + flag.StringVar(&RpcListenAddress, "rpcaddr", "127.0.0.1", "address for json-rpc server to listen on") flag.IntVar(&RpcPort, "rpcport", 8545, "port to start json-rpc server on") flag.IntVar(&WsPort, "wsport", 40404, "port to start websocket rpc server on") flag.BoolVar(&StartRpc, "rpc", true, "start rpc server") diff --git a/cmd/mist/main.go b/cmd/mist/main.go index 3abe16767..c9a07bfde 100644 --- a/cmd/mist/main.go +++ b/cmd/mist/main.go @@ -73,7 +73,7 @@ func run() error { utils.KeyTasks(ethereum.KeyManager(), KeyRing, GenAddr, SecretFile, ExportDir, NonInteractive) if StartRpc { - utils.StartRpc(ethereum, RpcPort) + utils.StartRpc(ethereum, RpcListenAddress, RpcPort) } if StartWebSockets { diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index a36c10e3b..5c7ec3221 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -160,9 +160,9 @@ func KeyTasks(keyManager *crypto.KeyManager, KeyRing string, GenAddr bool, Secre clilogger.Infof("Main address %x\n", keyManager.Address()) } -func StartRpc(ethereum *eth.Ethereum, RpcPort int) { +func StartRpc(ethereum *eth.Ethereum, RpcListenAddress string, RpcPort int) { var err error - ethereum.RpcServer, err = rpchttp.NewRpcHttpServer(xeth.New(ethereum), RpcPort) + ethereum.RpcServer, err = rpchttp.NewRpcHttpServer(xeth.New(ethereum), RpcListenAddress, RpcPort) if err != nil { clilogger.Errorf("Could not start RPC interface (port %v): %v", RpcPort, err) } else { -- cgit From 6ea7aae29ca71e6fe857b85296b574e09df57184 Mon Sep 17 00:00:00 2001 From: obscuren Date: Sat, 28 Feb 2015 19:15:57 +0100 Subject: Removed some methods from the JS REPL --- cmd/ethereum/flags.go | 6 ++++++ cmd/ethereum/main.go | 3 +++ cmd/ethereum/repl/repl.go | 1 + 3 files changed, 10 insertions(+) (limited to 'cmd') diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index 7d410c8e4..c42083160 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -135,6 +135,12 @@ func Init() { flag.Parse() + // When the javascript console is started log to a file instead + // of stdout + if StartJsConsole { + LogFile = path.Join(Datadir, "ethereum.log") + } + var err error if NAT, err = nat.Parse(*natstr); err != nil { log.Fatalf("-nat: %v", err) diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index 45e6f7b93..1562165cd 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -137,6 +137,9 @@ func main() { utils.StartEthereum(ethereum) + latestBlock := ethereum.ChainManager().CurrentBlock() + fmt.Printf("Welcome to the FRONTIER\n") + if StartJsConsole { InitJsConsole(ethereum) } else if len(InputFile) > 0 { diff --git a/cmd/ethereum/repl/repl.go b/cmd/ethereum/repl/repl.go index 4a7880ff4..11b812617 100644 --- a/cmd/ethereum/repl/repl.go +++ b/cmd/ethereum/repl/repl.go @@ -60,6 +60,7 @@ func (self *JSRepl) Start() { if !self.running { self.running = true repllogger.Infoln("init JS Console") + reader := bufio.NewReader(self.history) for { line, err := reader.ReadString('\n') -- cgit From 7ab13e0f17e9d1b783d93bd4952cc6d7cc77ea7f Mon Sep 17 00:00:00 2001 From: obscuren Date: Sat, 28 Feb 2015 20:24:20 +0100 Subject: Unused variable --- cmd/ethereum/main.go | 1 - 1 file changed, 1 deletion(-) (limited to 'cmd') diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index 1562165cd..f72b11e14 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -137,7 +137,6 @@ func main() { utils.StartEthereum(ethereum) - latestBlock := ethereum.ChainManager().CurrentBlock() fmt.Printf("Welcome to the FRONTIER\n") if StartJsConsole { -- cgit From fdf939a6f9b5360d76415c7118969d92af2774f9 Mon Sep 17 00:00:00 2001 From: obscuren Date: Sat, 28 Feb 2015 23:01:41 +0100 Subject: Fixed miner threads for ethereum CLI --- cmd/ethereum/flags.go | 3 +++ cmd/ethereum/main.go | 37 +++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 18 deletions(-) (limited to 'cmd') diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index 1a0c13c82..356571a23 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -27,6 +27,7 @@ import ( "log" "os" "path" + "runtime" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethutil" @@ -71,6 +72,7 @@ var ( SHH bool Dial bool PrintVersion bool + MinerThreads int ) // flags specific to cli client @@ -121,6 +123,7 @@ func Init() { flag.BoolVar(&StartMining, "mine", false, "start dagger mining") flag.BoolVar(&StartJsConsole, "js", false, "launches javascript console") flag.BoolVar(&PrintVersion, "version", false, "prints version number") + flag.IntVar(&MinerThreads, "minerthreads", runtime.NumCPU(), "number of miner threads") // Network stuff var ( diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index 07ef0d5dd..f79f948d1 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -62,20 +62,21 @@ func main() { utils.InitConfig(VmType, ConfigFile, Datadir, "ETH") ethereum, err := eth.New(ð.Config{ - Name: p2p.MakeName(ClientIdentifier, Version), - KeyStore: KeyStore, - DataDir: Datadir, - LogFile: LogFile, - LogLevel: LogLevel, - LogFormat: LogFormat, - MaxPeers: MaxPeer, - Port: OutboundPort, - NAT: NAT, - KeyRing: KeyRing, - Shh: true, - Dial: Dial, - BootNodes: BootNodes, - NodeKey: NodeKey, + Name: p2p.MakeName(ClientIdentifier, Version), + KeyStore: KeyStore, + DataDir: Datadir, + LogFile: LogFile, + LogLevel: LogLevel, + LogFormat: LogFormat, + MaxPeers: MaxPeer, + Port: OutboundPort, + NAT: NAT, + KeyRing: KeyRing, + Shh: true, + Dial: Dial, + BootNodes: BootNodes, + NodeKey: NodeKey, + MinerThreads: MinerThreads, }) if err != nil { @@ -113,10 +114,6 @@ func main() { return } - if StartMining { - utils.StartMining(ethereum) - } - if len(ImportChain) > 0 { start := time.Now() err := utils.ImportChain(ethereum, ImportChain) @@ -139,6 +136,10 @@ func main() { fmt.Printf("Welcome to the FRONTIER\n") + if StartMining { + ethereum.Miner().Start() + } + if StartJsConsole { InitJsConsole(ethereum) } else if len(InputFile) > 0 { -- cgit From cfe037028081ebb84ee35caa5b16fed5d125b58a Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sun, 1 Mar 2015 16:19:06 +0100 Subject: Remove Websockets RPC transport --- cmd/ethereum/flags.go | 3 --- cmd/ethereum/main.go | 4 ---- cmd/mist/flags.go | 3 --- cmd/mist/main.go | 4 ---- cmd/utils/cmd.go | 13 ------------- 5 files changed, 27 deletions(-) (limited to 'cmd') diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index 7d410c8e4..fd8aee90b 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -44,7 +44,6 @@ var ( StartRpc bool StartWebSockets bool RpcPort int - WsPort int OutboundPort string ShowGenesis bool AddPeer string @@ -94,9 +93,7 @@ func Init() { flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)") flag.IntVar(&RpcPort, "rpcport", 8545, "port to start json-rpc server on") - flag.IntVar(&WsPort, "wsport", 40404, "port to start websocket rpc server on") flag.BoolVar(&StartRpc, "rpc", false, "start rpc server") - flag.BoolVar(&StartWebSockets, "ws", false, "start websocket server") flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)") flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key") flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)") diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index 45e6f7b93..63585b0f5 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -131,10 +131,6 @@ func main() { utils.StartRpc(ethereum, RpcPort) } - if StartWebSockets { - utils.StartWebSockets(ethereum, WsPort) - } - utils.StartEthereum(ethereum) if StartJsConsole { diff --git a/cmd/mist/flags.go b/cmd/mist/flags.go index 0010df826..06768657d 100644 --- a/cmd/mist/flags.go +++ b/cmd/mist/flags.go @@ -43,7 +43,6 @@ var ( StartRpc bool StartWebSockets bool RpcPort int - WsPort int OutboundPort string ShowGenesis bool AddPeer string @@ -80,9 +79,7 @@ func Init() { flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use") flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)") flag.IntVar(&RpcPort, "rpcport", 8545, "port to start json-rpc server on") - flag.IntVar(&WsPort, "wsport", 40404, "port to start websocket rpc server on") flag.BoolVar(&StartRpc, "rpc", true, "start rpc server") - flag.BoolVar(&StartWebSockets, "ws", false, "start websocket server") flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)") flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key") flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)") diff --git a/cmd/mist/main.go b/cmd/mist/main.go index 3abe16767..a330bbcb1 100644 --- a/cmd/mist/main.go +++ b/cmd/mist/main.go @@ -76,10 +76,6 @@ func run() error { utils.StartRpc(ethereum, RpcPort) } - if StartWebSockets { - utils.StartWebSockets(ethereum, WsPort) - } - gui := NewWindow(ethereum, config, KeyRing, LogLevel) utils.RegisterInterrupt(func(os.Signal) { diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index a36c10e3b..20165fa97 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -35,7 +35,6 @@ import ( "github.com/ethereum/go-ethereum/miner" "github.com/ethereum/go-ethereum/rlp" rpchttp "github.com/ethereum/go-ethereum/rpc/http" - rpcws "github.com/ethereum/go-ethereum/rpc/ws" "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/xeth" ) @@ -170,18 +169,6 @@ func StartRpc(ethereum *eth.Ethereum, RpcPort int) { } } -func StartWebSockets(eth *eth.Ethereum, wsPort int) { - clilogger.Infoln("Starting WebSockets") - - var err error - eth.WsServer, err = rpcws.NewWebSocketServer(xeth.New(eth), wsPort) - if err != nil { - clilogger.Errorf("Could not start RPC interface (port %v): %v", wsPort, err) - } else { - go eth.WsServer.Start() - } -} - var gminer *miner.Miner func GetMiner() *miner.Miner { -- cgit From deb2e50296658d356c47f8382331193b180b29d4 Mon Sep 17 00:00:00 2001 From: zelig Date: Tue, 3 Mar 2015 01:45:50 +0700 Subject: minor cleanup --- cmd/ethereum/flags.go | 9 +++++---- cmd/mist/flags.go | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'cmd') diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index 356571a23..d7a6427eb 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -94,7 +94,7 @@ func Init() { flag.IntVar(&VmType, "vm", 0, "Virtual Machine type: 0-1: standard, debug") flag.StringVar(&Identifier, "id", "", "Custom client identifier") flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use") - flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)") + flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file") flag.StringVar(&RpcListenAddress, "rpcaddr", "127.0.0.1", "address for json-rpc server to listen on") flag.IntVar(&RpcPort, "rpcport", 8545, "port to start json-rpc server on") @@ -109,8 +109,8 @@ func Init() { flag.StringVar(&Datadir, "datadir", ethutil.DefaultDataDir(), "specifies the datadir to use") flag.StringVar(&ConfigFile, "conf", defaultConfigFile, "config file") flag.StringVar(&DebugFile, "debug", "", "debug file (no debugging if not set)") - flag.IntVar(&LogLevel, "loglevel", int(logger.InfoLevel), "loglevel: 0-5: silent,error,warn,info,debug,debug detail)") - flag.StringVar(&LogFormat, "logformat", "std", "logformat: std,raw)") + flag.IntVar(&LogLevel, "loglevel", int(logger.InfoLevel), "loglevel: 0-5 (= silent,error,warn,info,debug,debug detail)") + flag.StringVar(&LogFormat, "logformat", "std", "logformat: std,raw") flag.BoolVar(&DiffTool, "difftool", false, "creates output for diff'ing. Sets LogLevel=0") flag.StringVar(&DiffType, "diff", "all", "sets the level of diff output [vm, all]. Has no effect if difftool=false") flag.BoolVar(&ShowGenesis, "genesis", false, "Dump the genesis block") @@ -120,7 +120,7 @@ func Init() { flag.StringVar(&DumpHash, "hash", "", "specify arg in hex") flag.IntVar(&DumpNumber, "number", -1, "specify arg in number") - flag.BoolVar(&StartMining, "mine", false, "start dagger mining") + flag.BoolVar(&StartMining, "mine", false, "start mining") flag.BoolVar(&StartJsConsole, "js", false, "launches javascript console") flag.BoolVar(&PrintVersion, "version", false, "prints version number") flag.IntVar(&MinerThreads, "minerthreads", runtime.NumCPU(), "number of miner threads") @@ -137,6 +137,7 @@ func Init() { flag.StringVar(&BootNodes, "bootnodes", "", "space-separated node URLs for discovery bootstrap") flag.IntVar(&MaxPeer, "maxpeer", 30, "maximum desired peers") + flag.IntVar(&MinerThreads, "minerthreads", runtime.NumCPU(), "number of miner threads") flag.Parse() diff --git a/cmd/mist/flags.go b/cmd/mist/flags.go index 1ffeb1915..2bbd1f416 100644 --- a/cmd/mist/flags.go +++ b/cmd/mist/flags.go @@ -79,7 +79,7 @@ func Init() { flag.IntVar(&VmType, "vm", 0, "Virtual Machine type: 0-1: standard, debug") flag.StringVar(&Identifier, "id", "", "Custom client identifier") flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use") - flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)") + flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file") flag.StringVar(&RpcListenAddress, "rpcaddr", "127.0.0.1", "address for json-rpc server to listen on") flag.IntVar(&RpcPort, "rpcport", 8545, "port to start json-rpc server on") flag.IntVar(&WsPort, "wsport", 40404, "port to start websocket rpc server on") @@ -93,7 +93,7 @@ func Init() { flag.StringVar(&Datadir, "datadir", ethutil.DefaultDataDir(), "specifies the datadir to use") flag.StringVar(&ConfigFile, "conf", defaultConfigFile, "config file") flag.StringVar(&DebugFile, "debug", "", "debug file (no debugging if not set)") - flag.IntVar(&LogLevel, "loglevel", int(logger.InfoLevel), "loglevel: 0-5: silent,error,warn,info,debug,debug detail)") + flag.IntVar(&LogLevel, "loglevel", int(logger.InfoLevel), "loglevel: 0-5 (= silent,error,warn,info,debug,debug detail)") flag.StringVar(&AssetPath, "asset_path", ethutil.DefaultAssetPath(), "absolute path to GUI assets directory") -- cgit From 827ea4347836033b9d699f3f9b52159adcb16386 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 3 Mar 2015 20:38:28 +0100 Subject: removed all old filters --- cmd/mist/ext_app.go | 5 ----- 1 file changed, 5 deletions(-) (limited to 'cmd') diff --git a/cmd/mist/ext_app.go b/cmd/mist/ext_app.go index 7ac51db0b..84041a553 100644 --- a/cmd/mist/ext_app.go +++ b/cmd/mist/ext_app.go @@ -24,7 +24,6 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" - "github.com/ethereum/go-ethereum/ui/qt" "github.com/ethereum/go-ethereum/xeth" "github.com/obscuren/qml" ) @@ -116,7 +115,3 @@ func (app *ExtApplication) mainLoop() { } } } - -func (self *ExtApplication) Watch(filterOptions map[string]interface{}, identifier string) { - self.filters[identifier] = qt.NewFilterFromMap(filterOptions, self.eth) -} -- cgit From a56243075a7527d65d14c4cf3480029feb0a1e3f Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 4 Mar 2015 10:51:17 +0100 Subject: removed double flag. Closes #421 --- cmd/ethereum/flags.go | 1 - 1 file changed, 1 deletion(-) (limited to 'cmd') diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index fe848397c..a3004f503 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -134,7 +134,6 @@ func Init() { flag.StringVar(&BootNodes, "bootnodes", "", "space-separated node URLs for discovery bootstrap") flag.IntVar(&MaxPeer, "maxpeer", 30, "maximum desired peers") - flag.IntVar(&MinerThreads, "minerthreads", runtime.NumCPU(), "number of miner threads") flag.Parse() -- cgit