Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
91ca5d72
Commit
91ca5d72
authored
Sep 13, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reworked filters
parent
893e9256
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
833 additions
and
788 deletions
+833
-788
filter.js
ethereal/assets/ext/filter.js
+29
-11
wallet.qml
ethereal/assets/qml/views/wallet.qml
+2
-3
wallet.qml
ethereal/assets/qml/wallet.qml
+744
-743
gui.go
ethereal/gui.go
+36
-0
ui_lib.go
ethereal/ui_lib.go
+22
-31
No files found.
ethereal/assets/ext/filter.js
View file @
91ca5d72
var
ethx
=
{
prototype
:
Object
,
watch
:
function
(
options
)
{
return
new
Filter
(
options
);
},
note
:
function
()
{
var
args
=
Array
.
prototype
.
slice
.
call
(
arguments
,
0
);
var
o
=
[]
for
(
var
i
=
0
;
i
<
args
.
length
;
i
++
)
{
o
.
push
(
args
[
i
].
toString
())
}
eth
.
notef
(
o
);
},
};
var
Filter
=
function
(
options
)
{
this
.
callbacks
=
{};
this
.
seed
=
Math
.
floor
(
Math
.
random
()
*
1000000
);
this
.
callbacks
=
[];
this
.
options
=
options
;
if
(
options
===
"chain"
)
{
eth
.
registerFilterString
(
options
,
this
.
seed
);
this
.
id
=
eth
.
newFilterString
(
options
);
}
else
if
(
typeof
options
===
"object"
)
{
eth
.
registerFilter
(
options
,
this
.
seed
);
this
.
id
=
eth
.
newFilter
(
options
);
}
};
Filter
.
prototype
.
changed
=
function
(
callback
)
{
var
cbseed
=
Math
.
floor
(
Math
.
random
()
*
1000000
);
eth
.
registerFilterCallback
(
this
.
seed
,
cbseed
);
this
.
callbacks
.
push
(
callback
);
var
self
=
this
;
message
.
connect
(
function
(
messages
,
seed
,
callbackSeed
)
{
if
(
seed
==
self
.
seed
&&
callbackSeed
==
cbseed
)
{
callback
.
call
(
self
,
messages
);
message
.
connect
(
function
(
messages
,
id
)
{
if
(
id
==
self
.
id
)
{
for
(
var
i
=
0
;
i
<
self
.
callbacks
.
length
;
i
++
)
{
self
.
callbacks
[
i
].
call
(
self
,
messages
);
}
}
});
};
Filter
.
prototype
.
uninstall
=
function
()
{
eth
.
uninstallFilter
(
this
.
see
d
)
eth
.
uninstallFilter
(
this
.
i
d
)
}
Filter
.
prototype
.
messages
=
function
()
{
return
JSON
.
parse
(
eth
.
messages
(
this
.
options
)
)
return
eth
.
messages
(
this
.
id
)
}
ethereal/assets/qml/views/wallet.qml
View file @
91ca5d72
...
...
@@ -5,7 +5,6 @@ import QtQuick.Dialogs 1.0;
import
QtQuick
.
Window
2.1
;
import
QtQuick
.
Controls
.
Styles
1.1
import
Ethereum
1.0
import
"../../ext/filter.js"
as
Eth
Rectangle
{
id
:
root
...
...
@@ -152,7 +151,7 @@ Rectangle {
model
:
ListModel
{
id
:
txModel
Component.onCompleted
:
{
var
filter
=
new
Eth
.
Filter
({
latest
:
-
1
,
from
:
eth
.
key
().
address
})
var
filter
=
ethx
.
watch
({
latest
:
-
1
,
from
:
eth
.
key
().
address
});
filter
.
changed
(
addTxs
)
addTxs
(
filter
.
messages
())
...
...
@@ -160,7 +159,7 @@ Rectangle {
function
addTxs
(
messages
)
{
for
(
var
i
=
0
;
i
<
messages
.
length
;
i
++
)
{
var
message
=
messages
[
i
]
;
var
message
=
messages
.
get
(
i
)
;
txModel
.
insert
(
0
,
{
num
:
txModel
.
count
,
from
:
message
.
from
,
to
:
message
.
to
,
value
:
eth
.
numberToHuman
(
message
.
value
)})
}
}
...
...
ethereal/assets/qml/wallet.qml
View file @
91ca5d72
...
...
@@ -12,21 +12,21 @@ ApplicationWindow {
id
:
root
property
alias
miningButtonText
:
miningButton
.
text
property
var
ethx
:
Eth
.
ethx
width
:
900
height
:
600
minimumHeight
:
300
title
:
"Ethegate
"
title
:
"Ether Browser
"
// This signal is used by the filter API. The filter API connects using this signal handler from
// the different QML files and plugins.
signal
message
(
var
callback
,
int
seed
,
int
seedCallback
);
function
invokeFilterCallback
(
data
,
receiverSeed
,
callback
Seed
)
{
var
messages
=
JSON
.
parse
(
data
)
signal
message
(
var
callback
,
int
seed
);
function
invokeFilterCallback
(
data
,
receiver
Seed
)
{
//
var messages = JSON.parse(data)
// Signal handler
message
(
messages
,
receiverSeed
,
callback
Seed
);
message
(
data
,
receiver
Seed
);
}
TextField
{
...
...
@@ -42,16 +42,16 @@ ApplicationWindow {
// Takes care of loading all default plugins
Component.onCompleted
:
{
var
walletView
=
addPlugin
(
"./views/wallet.qml"
,
{
noAdd
:
true
,
section
:
"ethereum"
,
active
:
true
})
var
newTxView
=
addPlugin
(
"./views/transaction.qml"
,
{
noAdd
:
true
,
section
:
"legacy"
})
var
chainView
=
addPlugin
(
"./views/chain.qml"
,
{
noAdd
:
true
,
section
:
"legacy"
})
var
infoView
=
addPlugin
(
"./views/info.qml"
,
{
noAdd
:
true
,
section
:
"legacy"
})
var
pendingTxView
=
addPlugin
(
"./views/pending_tx.qml"
,
{
noAdd
:
true
,
section
:
"legacy"
})
var
pendingTxView
=
addPlugin
(
"./views/javascript.qml"
,
{
noAdd
:
true
,
section
:
"legacy"
})
addPlugin
(
"./views/wallet.qml"
,
{
noAdd
:
true
,
section
:
"ethereum"
,
active
:
true
});
// Call the ready handler
gui
.
done
()
addPlugin
(
"./views/transaction.qml"
,
{
noAdd
:
true
,
section
:
"legacy"
});
addPlugin
(
"./views/chain.qml"
,
{
noAdd
:
true
,
section
:
"legacy"
});
addPlugin
(
"./views/info.qml"
,
{
noAdd
:
true
,
section
:
"legacy"
});
addPlugin
(
"./views/pending_tx.qml"
,
{
noAdd
:
true
,
section
:
"legacy"
});
addPlugin
(
"./views/javascript.qml"
,
{
noAdd
:
true
,
section
:
"legacy"
});
// Call the ready handler
gui
.
done
();
}
function
addPlugin
(
path
,
options
)
{
...
...
@@ -59,7 +59,7 @@ ApplicationWindow {
var
component
=
Qt
.
createComponent
(
path
);
if
(
component
.
status
!=
Component
.
Ready
)
{
if
(
component
.
status
==
Component
.
Error
)
{
console
.
debug
(
"Error:"
+
component
.
errorString
());
ethx
.
note
(
"error: "
,
component
.
errorString
());
}
return
...
...
@@ -76,6 +76,7 @@ ApplicationWindow {
return
views
.
view
}
catch
(
e
)
{
eth
.
note
(
e
)
}
}
...
...
ethereal/gui.go
View file @
91ca5d72
package
main
// #include "/Users/jeffrey/go/src/github.com/go-qml/qml/cpp/capi.h"
import
"C"
import
(
"bytes"
"encoding/json"
...
...
@@ -10,7 +13,9 @@ import (
"strconv"
"strings"
"time"
"unsafe"
"bitbucket.org/binet/go-ffi/pkg/ffi"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethdb"
...
...
@@ -23,6 +28,29 @@ import (
"gopkg.in/qml.v1"
)
func
LoadExtension
(
path
string
)
(
uintptr
,
error
)
{
lib
,
err
:=
ffi
.
NewLibrary
(
path
)
if
err
!=
nil
{
return
0
,
err
}
so
,
err
:=
lib
.
Fct
(
"sharedObject"
,
ffi
.
Pointer
,
nil
)
if
err
!=
nil
{
return
0
,
err
}
ptr
:=
so
()
/*
err = lib.Close()
if err != nil {
return 0, err
}
*/
return
ptr
.
Interface
()
.
(
uintptr
),
nil
}
var
logger
=
ethlog
.
NewLogger
(
"GUI"
)
type
Gui
struct
{
...
...
@@ -91,6 +119,14 @@ func (gui *Gui) Start(assetPath string) {
context
.
SetVar
(
"gui"
,
gui
)
context
.
SetVar
(
"eth"
,
gui
.
uiLib
)
vec
,
errr
:=
LoadExtension
(
"/Users/jeffrey/Desktop/build-libqmltest-Desktop_Qt_5_2_1_clang_64bit-Debug/liblibqmltest_debug.dylib"
)
fmt
.
Printf
(
"Fetched vec with addr: %#x
\n
"
,
vec
)
if
errr
!=
nil
{
fmt
.
Println
(
errr
)
}
else
{
context
.
SetVar
(
"vec"
,
(
unsafe
.
Pointer
)(
vec
))
}
// Load the main QML interface
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"KeyRing"
))
...
...
ethereal/ui_lib.go
View file @
91ca5d72
...
...
@@ -37,15 +37,15 @@ type UiLib struct {
jsEngine
*
javascript
.
JSRE
filterCallbacks
map
[
int
][]
int
filters
map
[
int
]
*
Gui
Filter
//filters map[int]*ethpipe.JS
Filter
}
func
NewUiLib
(
engine
*
qml
.
Engine
,
eth
*
eth
.
Ethereum
,
assetPath
string
)
*
UiLib
{
return
&
UiLib
{
JSPipe
:
ethpipe
.
NewJSPipe
(
eth
),
engine
:
engine
,
eth
:
eth
,
assetPath
:
assetPath
,
jsEngine
:
javascript
.
NewJSRE
(
eth
),
filterCallbacks
:
make
(
map
[
int
][]
int
)
,
filters
:
make
(
map
[
int
]
*
Gui
Filter
)}
return
&
UiLib
{
JSPipe
:
ethpipe
.
NewJSPipe
(
eth
),
engine
:
engine
,
eth
:
eth
,
assetPath
:
assetPath
,
jsEngine
:
javascript
.
NewJSRE
(
eth
),
filterCallbacks
:
make
(
map
[
int
][]
int
)
}
//, filters: make(map[int]*ethpipe.JS
Filter)}
}
func
(
self
*
UiLib
)
Note
(
msg
string
)
{
logger
.
Infoln
(
msg
)
func
(
self
*
UiLib
)
Note
f
(
args
[]
interface
{}
)
{
logger
.
Infoln
(
args
...
)
}
func
(
self
*
UiLib
)
LookupDomain
(
domain
string
)
string
{
...
...
@@ -164,46 +164,37 @@ func (self *UiLib) StartDebugger() {
dbWindow
.
Show
()
}
func
(
self
*
UiLib
)
RegisterFilter
(
object
map
[
string
]
interface
{},
seed
int
)
{
filter
:=
&
GuiFilter
{
ethpipe
.
NewJSFilterFromMap
(
object
,
self
.
eth
),
seed
}
self
.
filters
[
seed
]
=
filter
func
(
self
*
UiLib
)
NewFilter
(
object
map
[
string
]
interface
{})
int
{
filter
,
id
:=
self
.
eth
.
InstallFilter
(
object
)
filter
.
MessageCallback
=
func
(
messages
ethstate
.
Messages
)
{
for
_
,
callbackSeed
:=
range
self
.
filterCallbacks
[
seed
]
{
self
.
win
.
Root
()
.
Call
(
"invokeFilterCallback"
,
filter
.
MessagesToJson
(
messages
),
seed
,
callbackSeed
)
}
self
.
win
.
Root
()
.
Call
(
"invokeFilterCallback"
,
ethpipe
.
ToJSMessages
(
messages
),
id
)
}
return
id
}
func
(
self
*
UiLib
)
RegisterFilterString
(
typ
string
,
seed
int
)
{
filter
:=
&
GuiFilter
{
ethpipe
.
NewJSFilterFromMap
(
nil
,
self
.
eth
),
seed
}
self
.
filters
[
seed
]
=
filter
if
typ
==
"chain"
{
func
(
self
*
UiLib
)
NewFilterString
(
typ
string
)
int
{
filter
,
id
:=
self
.
eth
.
InstallFilter
(
nil
)
filter
.
BlockCallback
=
func
(
block
*
ethchain
.
Block
)
{
for
_
,
callbackSeed
:=
range
self
.
filterCallbacks
[
seed
]
{
self
.
win
.
Root
()
.
Call
(
"invokeFilterCallback"
,
"{}"
,
seed
,
callbackSeed
)
}
self
.
win
.
Root
()
.
Call
(
"invokeFilterCallback"
,
"{}"
,
id
)
}
}
}
func
(
self
*
UiLib
)
RegisterFilterCallback
(
seed
,
cbSeed
int
)
{
self
.
filterCallbacks
[
seed
]
=
append
(
self
.
filterCallbacks
[
seed
],
cbSeed
)
return
id
}
func
(
self
*
UiLib
)
UninstallFilter
(
seed
int
)
{
filter
:=
self
.
filters
[
seed
]
func
(
self
*
UiLib
)
Messages
(
id
int
)
*
ethutil
.
List
{
filter
:=
self
.
eth
.
GetFilter
(
id
)
if
filter
!=
nil
{
filter
.
Uninstall
()
delete
(
self
.
filters
,
seed
)
messages
:=
filter
.
Find
()
return
ethpipe
.
ToJSMessages
(
messages
)
}
return
ethutil
.
EmptyList
()
}
type
GuiFilter
struct
{
*
ethpipe
.
JSFilter
seed
int
func
(
self
*
UiLib
)
UninstallFilter
(
id
int
)
{
self
.
eth
.
UninstallFilter
(
id
)
}
func
(
self
*
UiLib
)
Transact
(
object
map
[
string
]
interface
{})
(
*
ethpipe
.
JSReceipt
,
error
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment