Merge branch 'release/0.6.8'

pull/137/head v0.6.8
obscuren 10 years ago
commit d1a6084bf7
  1. 62
      ethereum/flags.go
  2. 4
      ethereum/main.go
  3. 28
      mist/assets/ext/html_messaging.js
  4. 3
      mist/assets/ext/pre.js
  5. 21
      mist/assets/ext/qt_messaging_adapter.js
  6. 1788
      mist/assets/qml/main.qml
  7. 2
      mist/assets/qml/webapp.qml
  8. 21
      mist/gui.go
  9. 161
      utils/websockets.go

@ -10,36 +10,41 @@ import (
"github.com/ethereum/eth-go/ethlog"
)
var Identifier string
var KeyRing string
var DiffTool bool
var DiffType string
var KeyStore string
var StartRpc bool
var RpcPort int
var UseUPnP bool
var OutboundPort string
var ShowGenesis bool
var AddPeer string
var MaxPeer int
var GenAddr bool
var UseSeed bool
var SecretFile string
var ExportDir string
var NonInteractive bool
var Datadir string
var LogFile string
var ConfigFile string
var DebugFile string
var LogLevel int
var Dump bool
var DumpHash string
var DumpNumber int
var (
Identifier string
KeyRing string
DiffTool bool
DiffType string
KeyStore string
StartRpc bool
StartWebSockets bool
RpcPort int
UseUPnP bool
OutboundPort string
ShowGenesis bool
AddPeer string
MaxPeer int
GenAddr bool
UseSeed bool
SecretFile string
ExportDir string
NonInteractive bool
Datadir string
LogFile string
ConfigFile string
DebugFile string
LogLevel int
Dump bool
DumpHash string
DumpNumber int
)
// flags specific to cli client
var StartMining bool
var StartJsConsole bool
var InputFile string
var (
StartMining bool
StartJsConsole bool
InputFile string
)
func defaultDataDir() string {
usr, _ := user.Current()
@ -62,6 +67,7 @@ func Init() {
flag.IntVar(&MaxPeer, "maxpeer", 10, "maximum desired peers")
flag.IntVar(&RpcPort, "rpcport", 8080, "port to start json-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(&UseSeed, "seed", true, "seed peers")
flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key")

@ -103,6 +103,10 @@ func main() {
utils.StartRpc(ethereum, RpcPort)
}
if StartWebSockets {
utils.StartWebSockets(ethereum)
}
utils.StartEthereum(ethereum, UseSeed)
// this blocks the thread

@ -1,9 +1,8 @@
// The magic return variable. The magic return variable will be set during the execution of the QML call.
(function(window) {
function message(type, data) {
document.title = JSON.stringify({type: type, data: data});
return window.____returnData;
var Promise = window.Promise;
if(typeof(Promise) === "undefined") {
var Promise = Q.Promise;
}
function isPromise(o) {
@ -446,6 +445,7 @@
}
});
var g_seed = 1;
function postData(data, cb) {
data._seed = g_seed;
@ -459,24 +459,6 @@
g_seed++;
navigator.qt.postMessage(JSON.stringify(data));
}
navigator.qt.onmessage = function(ev) {
var data = JSON.parse(ev.data)
if(data._event !== undefined) {
eth.trigger(data._event, data.data);
} else {
if(data._seed) {
var cb = eth._callbacks[data._seed];
if(cb) {
cb.call(this, data.data)
// Remove the "trigger" callback
delete eth._callbacks[ev._seed];
}
}
}
window._messagingAdapter.call(this, JSON.stringify(data))
}
})(this);

@ -1,3 +0,0 @@
if(typeof(Promise) === "undefined") {
window.Promise = Q.Promise;
}

@ -0,0 +1,21 @@
window._messagingAdapter = function(data) {
navigator.qt.postMessage(data);
};
navigator.qt.onmessage = function(ev) {
var data = JSON.parse(ev.data)
if(data._event !== undefined) {
eth.trigger(data._event, data.data);
} else {
if(data._seed) {
var cb = eth._callbacks[data._seed];
if(cb) {
cb.call(this, data.data)
// Remove the "trigger" callback
delete eth._callbacks[ev._seed];
}
}
}
}

File diff suppressed because it is too large Load Diff

@ -164,7 +164,7 @@ import "../ext/qml_messaging.js" as Messaging
experimental.preferences.javascriptEnabled: true
experimental.preferences.navigatorQtObjectEnabled: true
experimental.preferences.developerExtrasEnabled: true
experimental.userScripts: ["../ext/q.js", "../ext/pre.js", "../ext/big.js", "../ext/string.js", "../ext/html_messaging.js"]
experimental.userScripts: ["../ext/qt_messaging_adapter.js", "../ext/q.js", "../ext/big.js", "../ext/string.js", "../ext/html_messaging.js"]
experimental.onMessageReceived: {
console.log("[onMessageReceived]: ", message.data)
// TODO move to messaging.js

@ -271,7 +271,8 @@ func (gui *Gui) loadAddressBook() {
}
func (gui *Gui) insertTransaction(window string, tx *ethchain.Transaction) {
nameReg := ethpipe.New(gui.eth).World().Config().Get("NameReg")
pipe := ethpipe.New(gui.eth)
nameReg := pipe.World().Config().Get("NameReg")
addr := gui.address()
var inout string
@ -282,14 +283,14 @@ func (gui *Gui) insertTransaction(window string, tx *ethchain.Transaction) {
}
var (
ptx = ethpipe.NewJSTx(tx)
ptx = ethpipe.NewJSTx(tx, pipe.World().State())
send = nameReg.Storage(tx.Sender())
rec = nameReg.Storage(tx.Recipient)
s, r string
)
if tx.CreatesContract() {
rec = nameReg.Storage(tx.CreationAddress())
rec = nameReg.Storage(tx.CreationAddress(pipe.World().State()))
}
if send.Len() != 0 {
@ -301,7 +302,7 @@ func (gui *Gui) insertTransaction(window string, tx *ethchain.Transaction) {
r = strings.Trim(rec.Str(), "\x00")
} else {
if tx.CreatesContract() {
r = ethutil.Bytes2Hex(tx.CreationAddress())
r = ethutil.Bytes2Hex(tx.CreationAddress(pipe.World().State()))
} else {
r = ethutil.Bytes2Hex(tx.Recipient)
}
@ -466,13 +467,11 @@ func (gui *Gui) update() {
var (
pct float64 = 1.0 / float64(chainLength) * float64(blockLength)
dlWidget = gui.win.Root().ObjectByName("downloadIndicator")
dlLabel = gui.win.Root().ObjectByName("downloadLabel")
)
if pct < 1.0 {
dlWidget.Set("visible", true)
dlWidget.Set("value", pct)
} else {
dlWidget.Set("visible", false)
}
dlWidget.Set("value", pct)
dlLabel.Set("text", fmt.Sprintf("%d / %d", blockLength, chainLength))
case <-statsUpdateTicker.C:
gui.setStatsPane()
@ -500,7 +499,7 @@ func (gui *Gui) setStatsPane() {
runtime.ReadMemStats(&memStats)
statsPane := gui.getObjectByName("statsPane")
statsPane.Set("text", fmt.Sprintf(`###### Mist 0.6.7 (%s) #######
statsPane.Set("text", fmt.Sprintf(`###### Mist 0.6.8 (%s) #######
eth %d (p2p = %d)

@ -0,0 +1,161 @@
package utils
import (
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethpipe"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/websocket"
)
func args(v ...interface{}) []interface{} {
return v
}
type WebSocketServer struct {
ethereum *eth.Ethereum
filterCallbacks map[int][]int
}
func NewWebSocketServer(eth *eth.Ethereum) *WebSocketServer {
return &WebSocketServer{eth, make(map[int][]int)}
}
func (self *WebSocketServer) Serv() {
pipe := ethpipe.NewJSPipe(self.ethereum)
wsServ := websocket.NewServer("/eth", ":40404")
wsServ.MessageFunc(func(c *websocket.Client, msg *websocket.Message) {
switch msg.Call {
case "compile":
data := ethutil.NewValue(msg.Args)
bcode, err := ethutil.Compile(data.Get(0).Str(), false)
if err != nil {
c.Write(args(nil, err.Error()), msg.Seed)
}
code := ethutil.Bytes2Hex(bcode)
c.Write(args(code, nil), msg.Seed)
case "getBlockByNumber":
args := msg.Arguments()
block := pipe.BlockByNumber(int32(args.Get(0).Uint()))
c.Write(block, msg.Seed)
case "getKey":
c.Write(pipe.Key().PrivateKey, msg.Seed)
case "transact":
if mp, ok := msg.Args[0].(map[string]interface{}); ok {
object := mapToTxParams(mp)
c.Write(
args(pipe.Transact(object["from"], object["to"], object["value"], object["gas"], object["gasPrice"], object["data"])),
msg.Seed,
)
}
case "getCoinBase":
c.Write(pipe.CoinBase(), msg.Seed)
case "getIsListening":
c.Write(pipe.IsListening(), msg.Seed)
case "getIsMining":
c.Write(pipe.IsMining(), msg.Seed)
case "getPeerCoint":
c.Write(pipe.PeerCount(), msg.Seed)
case "getCountAt":
args := msg.Arguments()
c.Write(pipe.TxCountAt(args.Get(0).Str()), msg.Seed)
case "getCodeAt":
args := msg.Arguments()
c.Write(len(pipe.CodeAt(args.Get(0).Str())), msg.Seed)
case "getBlockByHash":
args := msg.Arguments()
c.Write(pipe.BlockByHash(args.Get(0).Str()), msg.Seed)
case "getStorageAt":
args := msg.Arguments()
c.Write(pipe.StorageAt(args.Get(0).Str(), args.Get(1).Str()), msg.Seed)
case "getBalanceAt":
args := msg.Arguments()
c.Write(pipe.BalanceAt(args.Get(0).Str()), msg.Seed)
case "getSecretToAddress":
args := msg.Arguments()
c.Write(pipe.SecretToAddress(args.Get(0).Str()), msg.Seed)
case "newFilter":
case "newFilterString":
case "messages":
// TODO
}
})
wsServ.Listen()
}
func StartWebSockets(eth *eth.Ethereum) {
sock := NewWebSocketServer(eth)
go sock.Serv()
}
// TODO This is starting to become a generic method. Move to utils
func mapToTxParams(object map[string]interface{}) map[string]string {
// Default values
if object["from"] == nil {
object["from"] = ""
}
if object["to"] == nil {
object["to"] = ""
}
if object["value"] == nil {
object["value"] = ""
}
if object["gas"] == nil {
object["gas"] = ""
}
if object["gasPrice"] == nil {
object["gasPrice"] = ""
}
var dataStr string
var data []string
if str, ok := object["data"].(string); ok {
data = []string{str}
}
for _, str := range data {
if ethutil.IsHex(str) {
str = str[2:]
if len(str) != 64 {
str = ethutil.LeftPadString(str, 64)
}
} else {
str = ethutil.Bytes2Hex(ethutil.LeftPadBytes(ethutil.Big(str).Bytes(), 32))
}
dataStr += str
}
object["data"] = dataStr
conv := make(map[string]string)
for key, value := range object {
if v, ok := value.(string); ok {
conv[key] = v
}
}
return conv
}
Loading…
Cancel
Save