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
a5b27bbc
Commit
a5b27bbc
authored
Dec 04, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved and simplified wallet functions and behaviour
parent
8c7e4b29
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
33 deletions
+29
-33
wallet.qml
cmd/mist/assets/qml/views/wallet.qml
+14
-5
gui.go
cmd/mist/gui.go
+7
-22
block_manager.go
core/block_manager.go
+6
-4
transaction_pool.go
core/transaction_pool.go
+1
-1
miner.go
miner/miner.go
+1
-1
No files found.
cmd/mist/assets/qml/views/wallet.qml
View file @
a5b27bbc
...
@@ -155,10 +155,14 @@ Rectangle {
...
@@ -155,10 +155,14 @@ Rectangle {
model
:
ListModel
{
model
:
ListModel
{
id
:
txModel
id
:
txModel
Component.onCompleted
:
{
Component.onCompleted
:
{
var
filter
=
ethx
.
watch
({
latest
:
-
1
,
from
:
eth
.
key
().
address
});
var
me
=
eth
.
key
().
address
;
filter
.
changed
(
addTxs
)
var
filterTo
=
ethx
.
watch
({
latest
:
-
1
,
to
:
me
});
var
filterFrom
=
ethx
.
watch
({
latest
:
-
1
,
from
:
me
});
addTxs
(
filter
.
messages
())
filterTo
.
changed
(
addTxs
)
filterFrom
.
changed
(
addTxs
)
addTxs
(
filterTo
.
messages
())
addTxs
(
filterFrom
.
messages
())
}
}
function
addTxs
(
messages
)
{
function
addTxs
(
messages
)
{
...
@@ -167,7 +171,12 @@ Rectangle {
...
@@ -167,7 +171,12 @@ Rectangle {
for
(
var
i
=
0
;
i
<
messages
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
messages
.
length
;
i
++
)
{
var
message
=
messages
.
get
(
i
);
var
message
=
messages
.
get
(
i
);
var
to
=
eth
.
lookupName
(
message
.
to
);
var
to
=
eth
.
lookupName
(
message
.
to
);
var
from
=
eth
.
lookupName
(
message
.
from
);
var
from
;
if
(
message
.
from
.
length
==
0
)
{
from
=
"- MINED -"
;
}
else
{
from
=
eth
.
lookupName
(
message
.
from
);
}
txModel
.
insert
(
0
,
{
num
:
txModel
.
count
,
from
:
from
,
to
:
to
,
value
:
eth
.
numberToHuman
(
message
.
value
)})
txModel
.
insert
(
0
,
{
num
:
txModel
.
count
,
from
:
from
,
to
:
to
,
value
:
eth
.
numberToHuman
(
message
.
value
)})
}
}
}
}
...
...
cmd/mist/gui.go
View file @
a5b27bbc
...
@@ -404,7 +404,6 @@ func (gui *Gui) update() {
...
@@ -404,7 +404,6 @@ func (gui *Gui) update() {
state
:=
gui
.
eth
.
BlockManager
()
.
TransState
()
state
:=
gui
.
eth
.
BlockManager
()
.
TransState
()
unconfirmedFunds
:=
new
(
big
.
Int
)
gui
.
win
.
Root
()
.
Call
(
"setWalletValue"
,
fmt
.
Sprintf
(
"%v"
,
ethutil
.
CurrencyToString
(
state
.
GetAccount
(
gui
.
address
())
.
Balance
())))
gui
.
win
.
Root
()
.
Call
(
"setWalletValue"
,
fmt
.
Sprintf
(
"%v"
,
ethutil
.
CurrencyToString
(
state
.
GetAccount
(
gui
.
address
())
.
Balance
())))
lastBlockLabel
:=
gui
.
getObjectByName
(
"lastBlockLabel"
)
lastBlockLabel
:=
gui
.
getObjectByName
(
"lastBlockLabel"
)
...
@@ -438,15 +437,15 @@ func (gui *Gui) update() {
...
@@ -438,15 +437,15 @@ func (gui *Gui) update() {
case
core
.
TxPreEvent
:
case
core
.
TxPreEvent
:
tx
:=
ev
.
Tx
tx
:=
ev
.
Tx
object
:=
state
.
GetAccount
(
gui
.
address
())
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
tstate
:=
gui
.
eth
.
BlockManager
()
.
TransState
()
unconfirmedFunds
.
Sub
(
unconfirmedFunds
,
tx
.
Value
)
cstate
:=
gui
.
eth
.
BlockManager
()
.
CurrentState
()
}
else
if
bytes
.
Compare
(
tx
.
Recipient
,
gui
.
address
())
==
0
{
unconfirmedFunds
.
Add
(
unconfirmedFunds
,
tx
.
Value
)
}
gui
.
setWalletValue
(
object
.
Balance
(),
unconfirmedFunds
)
taccount
:=
tstate
.
GetAccount
(
gui
.
address
())
caccount
:=
cstate
.
GetAccount
(
gui
.
address
())
unconfirmedFunds
:=
new
(
big
.
Int
)
.
Sub
(
taccount
.
Balance
(),
caccount
.
Balance
())
gui
.
setWalletValue
(
taccount
.
Balance
(),
unconfirmedFunds
)
gui
.
insertTransaction
(
"pre"
,
tx
)
gui
.
insertTransaction
(
"pre"
,
tx
)
case
core
.
TxPostEvent
:
case
core
.
TxPostEvent
:
...
@@ -456,32 +455,18 @@ func (gui *Gui) update() {
...
@@ -456,32 +455,18 @@ func (gui *Gui) update() {
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
object
.
SubAmount
(
tx
.
Value
)
object
.
SubAmount
(
tx
.
Value
)
//gui.getObjectByName("transactionView").Call("addTx", xeth.NewJSTx(tx), "send")
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
}
else
if
bytes
.
Compare
(
tx
.
Recipient
,
gui
.
address
())
==
0
{
}
else
if
bytes
.
Compare
(
tx
.
Recipient
,
gui
.
address
())
==
0
{
object
.
AddAmount
(
tx
.
Value
)
object
.
AddAmount
(
tx
.
Value
)
//gui.getObjectByName("transactionView").Call("addTx", xeth.NewJSTx(tx), "recv")
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
}
}
gui
.
setWalletValue
(
object
.
Balance
(),
nil
)
gui
.
setWalletValue
(
object
.
Balance
(),
nil
)
state
.
UpdateStateObject
(
object
)
state
.
UpdateStateObject
(
object
)
// case object:
// gui.loadAddressBook()
case
eth
.
PeerListEvent
:
case
eth
.
PeerListEvent
:
gui
.
setPeerInfo
()
gui
.
setPeerInfo
()
/*
case miner.Event:
if ev.Type == miner.Started {
gui.miner = ev.Miner
} else {
gui.miner = nil
}
*/
}
}
case
<-
peerUpdateTicker
.
C
:
case
<-
peerUpdateTicker
.
C
:
...
...
core/block_manager.go
View file @
a5b27bbc
...
@@ -123,7 +123,7 @@ func (sm *BlockManager) TransitionState(statedb *state.StateDB, parent, block *t
...
@@ -123,7 +123,7 @@ func (sm *BlockManager) TransitionState(statedb *state.StateDB, parent, block *t
coinbase
.
SetGasPool
(
block
.
CalcGasLimit
(
parent
))
coinbase
.
SetGasPool
(
block
.
CalcGasLimit
(
parent
))
// Process the transactions on to current block
// Process the transactions on to current block
receipts
,
_
,
_
,
_
,
err
=
sm
.
ProcessTransactions
(
coinbase
,
statedb
,
block
,
parent
,
block
.
Transactions
()
)
receipts
,
_
,
_
,
_
,
err
=
sm
.
ApplyTransactions
(
coinbase
,
statedb
,
block
,
block
.
Transactions
(),
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -131,7 +131,7 @@ func (sm *BlockManager) TransitionState(statedb *state.StateDB, parent, block *t
...
@@ -131,7 +131,7 @@ func (sm *BlockManager) TransitionState(statedb *state.StateDB, parent, block *t
return
receipts
,
nil
return
receipts
,
nil
}
}
func
(
self
*
BlockManager
)
ProcessTransactions
(
coinbase
*
state
.
StateObject
,
state
*
state
.
StateDB
,
block
,
parent
*
types
.
Block
,
txs
types
.
Transactions
)
(
types
.
Receipts
,
types
.
Transactions
,
types
.
Transactions
,
types
.
Transactions
,
error
)
{
func
(
self
*
BlockManager
)
ApplyTransactions
(
coinbase
*
state
.
StateObject
,
state
*
state
.
StateDB
,
block
*
types
.
Block
,
txs
types
.
Transactions
,
transientProcess
bool
)
(
types
.
Receipts
,
types
.
Transactions
,
types
.
Transactions
,
types
.
Transactions
,
error
)
{
var
(
var
(
receipts
types
.
Receipts
receipts
types
.
Receipts
handled
,
unhandled
types
.
Transactions
handled
,
unhandled
types
.
Transactions
...
@@ -180,7 +180,9 @@ done:
...
@@ -180,7 +180,9 @@ done:
receipt
.
Bloom
=
types
.
CreateBloom
(
types
.
Receipts
{
receipt
})
receipt
.
Bloom
=
types
.
CreateBloom
(
types
.
Receipts
{
receipt
})
// Notify all subscribers
// Notify all subscribers
go
self
.
eth
.
EventMux
()
.
Post
(
TxPostEvent
{
tx
})
if
!
transientProcess
{
go
self
.
eth
.
EventMux
()
.
Post
(
TxPostEvent
{
tx
})
}
receipts
=
append
(
receipts
,
receipt
)
receipts
=
append
(
receipts
,
receipt
)
handled
=
append
(
handled
,
tx
)
handled
=
append
(
handled
,
tx
)
...
@@ -378,7 +380,7 @@ func (sm *BlockManager) AccumelateRewards(statedb *state.StateDB, block, parent
...
@@ -378,7 +380,7 @@ func (sm *BlockManager) AccumelateRewards(statedb *state.StateDB, block, parent
account
.
AddAmount
(
reward
)
account
.
AddAmount
(
reward
)
statedb
.
Manifest
()
.
AddMessage
(
&
state
.
Message
{
statedb
.
Manifest
()
.
AddMessage
(
&
state
.
Message
{
To
:
block
.
Coinbase
,
From
:
block
.
Coinbase
,
To
:
block
.
Coinbase
,
Input
:
nil
,
Input
:
nil
,
Origin
:
nil
,
Origin
:
nil
,
Block
:
block
.
Hash
(),
Timestamp
:
block
.
Time
,
Coinbase
:
block
.
Coinbase
,
Number
:
block
.
Number
,
Block
:
block
.
Hash
(),
Timestamp
:
block
.
Time
,
Coinbase
:
block
.
Coinbase
,
Number
:
block
.
Number
,
...
...
core/transaction_pool.go
View file @
a5b27bbc
...
@@ -164,7 +164,7 @@ func (self *TxPool) Add(tx *types.Transaction) error {
...
@@ -164,7 +164,7 @@ func (self *TxPool) Add(tx *types.Transaction) error {
txplogger
.
Debugf
(
"(t) %x => %x (%v) %x
\n
"
,
tx
.
Sender
()[
:
4
],
tmp
,
tx
.
Value
,
tx
.
Hash
())
txplogger
.
Debugf
(
"(t) %x => %x (%v) %x
\n
"
,
tx
.
Sender
()[
:
4
],
tmp
,
tx
.
Value
,
tx
.
Hash
())
// Notify the subscribers
// Notify the subscribers
self
.
Ethereum
.
EventMux
()
.
Post
(
TxPreEvent
{
tx
})
go
self
.
Ethereum
.
EventMux
()
.
Post
(
TxPreEvent
{
tx
})
return
nil
return
nil
}
}
...
...
miner/miner.go
View file @
a5b27bbc
...
@@ -192,7 +192,7 @@ func (self *Miner) mine() {
...
@@ -192,7 +192,7 @@ func (self *Miner) mine() {
// Accumulate all valid transactions and apply them to the new state
// Accumulate all valid transactions and apply them to the new state
// Error may be ignored. It's not important during mining
// Error may be ignored. It's not important during mining
receipts
,
txs
,
_
,
erroneous
,
err
:=
blockManager
.
ProcessTransactions
(
coinbase
,
block
.
State
(),
block
,
block
,
transactions
)
receipts
,
txs
,
_
,
erroneous
,
err
:=
blockManager
.
ApplyTransactions
(
coinbase
,
block
.
State
(),
block
,
transactions
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
minerlogger
.
Debugln
(
err
)
minerlogger
.
Debugln
(
err
)
}
}
...
...
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