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
f9e2e527
Commit
f9e2e527
authored
Jul 07, 2014
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #100 from ethersphere/feature/ethutil-refactor
ethreact - Feature/ethutil refactor
parents
8e511744
1e4ae241
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
64 deletions
+68
-64
ext_app.go
ethereal/ext_app.go
+5
-4
gui.go
ethereal/gui.go
+55
-52
javascript_runtime.go
ethereum/javascript_runtime.go
+8
-8
No files found.
ethereal/ext_app.go
View file @
f9e2e527
...
...
@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethreact"
"github.com/ethereum/eth-go/ethutil"
"github.com/go-qml/qml"
)
...
...
@@ -24,8 +25,8 @@ type AppContainer interface {
type
ExtApplication
struct
{
*
ethpub
.
PEthereum
blockChan
chan
eth
util
.
Reac
t
changeChan
chan
eth
util
.
Reac
t
blockChan
chan
eth
react
.
Even
t
changeChan
chan
eth
react
.
Even
t
quitChan
chan
bool
watcherQuitChan
chan
bool
...
...
@@ -37,8 +38,8 @@ type ExtApplication struct {
func
NewExtApplication
(
container
AppContainer
,
lib
*
UiLib
)
*
ExtApplication
{
app
:=
&
ExtApplication
{
ethpub
.
NewPEthereum
(
lib
.
eth
),
make
(
chan
eth
util
.
React
,
1
),
make
(
chan
eth
util
.
React
,
1
),
make
(
chan
eth
react
.
Event
),
make
(
chan
eth
react
.
Event
),
make
(
chan
bool
),
make
(
chan
bool
),
container
,
...
...
ethereal/gui.go
View file @
f9e2e527
...
...
@@ -8,6 +8,7 @@ import (
"github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethreact"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
"github.com/ethereum/go-ethereum/utils"
...
...
@@ -143,7 +144,7 @@ func (gui *Gui) showWallet(context *qml.Context) (*qml.Window, error) {
gui
.
readPreviousTransactions
()
gui
.
setPeerInfo
()
g
o
g
ui
.
update
()
gui
.
update
()
return
win
,
nil
}
...
...
@@ -266,20 +267,10 @@ func (gui *Gui) setWalletValue(amount, unconfirmedFunds *big.Int) {
func
(
gui
*
Gui
)
update
()
{
reactor
:=
gui
.
eth
.
Reactor
()
blockChan
:=
make
(
chan
ethutil
.
React
,
1
)
txChan
:=
make
(
chan
ethutil
.
React
,
1
)
objectChan
:=
make
(
chan
ethutil
.
React
,
1
)
peerChan
:=
make
(
chan
ethutil
.
React
,
1
)
reactor
.
Subscribe
(
"newBlock"
,
blockChan
)
reactor
.
Subscribe
(
"newTx:pre"
,
txChan
)
reactor
.
Subscribe
(
"newTx:post"
,
txChan
)
nameReg
:=
ethpub
.
EthereumConfig
(
gui
.
eth
.
StateManager
())
.
NameReg
()
if
nameReg
!=
nil
{
reactor
.
Subscribe
(
"object:"
+
string
(
nameReg
.
Address
()),
objectChan
)
}
reactor
.
Subscribe
(
"peerList"
,
peerChan
)
blockChan
:=
make
(
chan
ethreact
.
Event
)
txChan
:=
make
(
chan
ethreact
.
Event
)
objectChan
:=
make
(
chan
ethreact
.
Event
)
peerChan
:=
make
(
chan
ethreact
.
Event
)
ticker
:=
time
.
NewTicker
(
5
*
time
.
Second
)
...
...
@@ -288,54 +279,66 @@ func (gui *Gui) update() {
unconfirmedFunds
:=
new
(
big
.
Int
)
gui
.
win
.
Root
()
.
Call
(
"setWalletValue"
,
fmt
.
Sprintf
(
"%v"
,
ethutil
.
CurrencyToString
(
state
.
GetAccount
(
gui
.
address
())
.
Amount
)))
for
{
select
{
case
b
:=
<-
blockChan
:
block
:=
b
.
Resource
.
(
*
ethchain
.
Block
)
gui
.
processBlock
(
block
,
false
)
if
bytes
.
Compare
(
block
.
Coinbase
,
gui
.
address
())
==
0
{
gui
.
setWalletValue
(
gui
.
eth
.
StateManager
()
.
CurrentState
()
.
GetAccount
(
gui
.
address
())
.
Amount
,
nil
)
}
go
func
()
{
for
{
select
{
case
b
:=
<-
blockChan
:
block
:=
b
.
Resource
.
(
*
ethchain
.
Block
)
gui
.
processBlock
(
block
,
false
)
if
bytes
.
Compare
(
block
.
Coinbase
,
gui
.
address
())
==
0
{
gui
.
setWalletValue
(
gui
.
eth
.
StateManager
()
.
CurrentState
()
.
GetAccount
(
gui
.
address
())
.
Amount
,
nil
)
}
case
txMsg
:=
<-
txChan
:
tx
:=
txMsg
.
Resource
.
(
*
ethchain
.
Transaction
)
case
txMsg
:=
<-
txChan
:
tx
:=
txMsg
.
Resource
.
(
*
ethchain
.
Transaction
)
if
txMsg
.
Event
==
"newTx:pre"
{
object
:=
state
.
GetAccount
(
gui
.
address
())
if
txMsg
.
Name
==
"newTx:pre"
{
object
:=
state
.
GetAccount
(
gui
.
address
())
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
gui
.
win
.
Root
()
.
Call
(
"addTx"
,
ethpub
.
NewPTx
(
tx
),
"send"
)
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
gui
.
win
.
Root
()
.
Call
(
"addTx"
,
ethpub
.
NewPTx
(
tx
),
"send"
)
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
unconfirmedFunds
.
Sub
(
unconfirmedFunds
,
tx
.
Value
)
}
else
if
bytes
.
Compare
(
tx
.
Recipient
,
gui
.
address
())
==
0
{
gui
.
win
.
Root
()
.
Call
(
"addTx"
,
ethpub
.
NewPTx
(
tx
),
"recv"
)
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
unconfirmedFunds
.
Sub
(
unconfirmedFunds
,
tx
.
Value
)
}
else
if
bytes
.
Compare
(
tx
.
Recipient
,
gui
.
address
())
==
0
{
gui
.
win
.
Root
()
.
Call
(
"addTx"
,
ethpub
.
NewPTx
(
tx
),
"recv"
)
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
unconfirmedFunds
.
Add
(
unconfirmedFunds
,
tx
.
Value
)
}
unconfirmedFunds
.
Add
(
unconfirmedFunds
,
tx
.
Value
)
}
gui
.
setWalletValue
(
object
.
Amount
,
unconfirmedFunds
)
}
else
{
object
:=
state
.
GetAccount
(
gui
.
address
())
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
object
.
SubAmount
(
tx
.
Value
)
}
else
if
bytes
.
Compare
(
tx
.
Recipient
,
gui
.
address
())
==
0
{
object
.
AddAmount
(
tx
.
Value
)
}
gui
.
setWalletValue
(
object
.
Amount
,
unconfirmedFunds
)
}
else
{
object
:=
state
.
GetAccount
(
gui
.
address
())
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
object
.
SubAmount
(
tx
.
Value
)
}
else
if
bytes
.
Compare
(
tx
.
Recipient
,
gui
.
address
())
==
0
{
object
.
AddAmount
(
tx
.
Value
)
}
gui
.
setWalletValue
(
object
.
Amount
,
nil
)
gui
.
setWalletValue
(
object
.
Amount
,
nil
)
state
.
UpdateStateObject
(
object
)
state
.
UpdateStateObject
(
object
)
}
case
<-
objectChan
:
gui
.
loadAddressBook
()
case
<-
peerChan
:
gui
.
setPeerInfo
()
case
<-
ticker
.
C
:
gui
.
setPeerInfo
()
}
case
<-
objectChan
:
gui
.
loadAddressBook
()
case
<-
peerChan
:
gui
.
setPeerInfo
()
case
<-
ticker
.
C
:
gui
.
setPeerInfo
()
}
}()
reactor
.
Subscribe
(
"newBlock"
,
blockChan
)
reactor
.
Subscribe
(
"newTx:pre"
,
txChan
)
reactor
.
Subscribe
(
"newTx:post"
,
txChan
)
nameReg
:=
ethpub
.
EthereumConfig
(
gui
.
eth
.
StateManager
())
.
NameReg
()
if
nameReg
!=
nil
{
reactor
.
Subscribe
(
"object:"
+
string
(
nameReg
.
Address
()),
objectChan
)
}
reactor
.
Subscribe
(
"peerList"
,
peerChan
)
}
func
(
gui
*
Gui
)
setPeerInfo
()
{
...
...
ethereum/javascript_runtime.go
View file @
f9e2e527
...
...
@@ -6,6 +6,7 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethreact"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/utils"
"github.com/obscuren/otto"
...
...
@@ -22,8 +23,8 @@ type JSRE struct {
vm
*
otto
.
Otto
lib
*
ethpub
.
PEthereum
blockChan
chan
eth
util
.
Reac
t
changeChan
chan
eth
util
.
Reac
t
blockChan
chan
eth
react
.
Even
t
changeChan
chan
eth
react
.
Even
t
quitChan
chan
bool
objectCb
map
[
string
][]
otto
.
Value
...
...
@@ -48,8 +49,8 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE {
ethereum
,
otto
.
New
(),
ethpub
.
NewPEthereum
(
ethereum
),
make
(
chan
eth
util
.
React
,
1
),
make
(
chan
eth
util
.
React
,
1
),
make
(
chan
eth
react
.
Event
),
make
(
chan
eth
react
.
Event
),
make
(
chan
bool
),
make
(
map
[
string
][]
otto
.
Value
),
}
...
...
@@ -63,6 +64,9 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE {
// We have to make sure that, whoever calls this, calls "Stop"
go
re
.
mainLoop
()
// Subscribe to events
reactor
:=
ethereum
.
Reactor
()
reactor
.
Subscribe
(
"newBlock"
,
re
.
blockChan
)
re
.
Bind
(
"eth"
,
&
JSEthereum
{
re
.
lib
,
re
.
vm
})
...
...
@@ -108,10 +112,6 @@ func (self *JSRE) Stop() {
}
func
(
self
*
JSRE
)
mainLoop
()
{
// Subscribe to events
reactor
:=
self
.
ethereum
.
Reactor
()
reactor
.
Subscribe
(
"newBlock"
,
self
.
blockChan
)
out
:
for
{
select
{
...
...
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