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
f59a3b67
Commit
f59a3b67
authored
Nov 04, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
StateManager => BlockManager
parent
1025d097
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
51 additions
and
67 deletions
+51
-67
block_pool.go
block_pool.go
+1
-1
block_manager.go
chain/block_manager.go
+19
-33
bloom9_test.go
chain/bloom9_test.go
+2
-4
filter.go
chain/filter.go
+1
-1
transaction_pool.go
chain/transaction_pool.go
+2
-2
bindings.go
cmd/mist/bindings.go
+1
-1
debugger.go
cmd/mist/debugger.go
+2
-2
gui.go
cmd/mist/gui.go
+2
-2
ui_lib.go
cmd/mist/ui_lib.go
+1
-1
cmd.go
cmd/utils/cmd.go
+1
-1
ethereum.go
ethereum.go
+6
-6
javascript_runtime.go
javascript/javascript_runtime.go
+1
-1
miner.go
miner/miner.go
+5
-5
hexface.go
xeth/hexface.go
+2
-2
pipe.go
xeth/pipe.go
+4
-4
world.go
xeth/world.go
+1
-1
No files found.
block_pool.go
View file @
f59a3b67
...
@@ -315,7 +315,7 @@ out:
...
@@ -315,7 +315,7 @@ out:
// otherwise process and don't emit anything
// otherwise process and don't emit anything
var
err
error
var
err
error
for
i
,
block
:=
range
blocks
{
for
i
,
block
:=
range
blocks
{
err
=
self
.
eth
.
State
Manager
()
.
Process
(
block
)
err
=
self
.
eth
.
Block
Manager
()
.
Process
(
block
)
if
err
!=
nil
{
if
err
!=
nil
{
poollogger
.
Infoln
(
err
)
poollogger
.
Infoln
(
err
)
poollogger
.
Debugf
(
"Block #%v failed (%x...)
\n
"
,
block
.
Number
,
block
.
Hash
()[
0
:
4
])
poollogger
.
Debugf
(
"Block #%v failed (%x...)
\n
"
,
block
.
Number
,
block
.
Hash
()[
0
:
4
])
...
...
chain/
state
_manager.go
→
chain/
block
_manager.go
View file @
f59a3b67
...
@@ -32,7 +32,7 @@ type Peer interface {
...
@@ -32,7 +32,7 @@ type Peer interface {
}
}
type
EthManager
interface
{
type
EthManager
interface
{
StateManager
()
*
State
Manager
BlockManager
()
*
Block
Manager
ChainManager
()
*
ChainManager
ChainManager
()
*
ChainManager
TxPool
()
*
TxPool
TxPool
()
*
TxPool
Broadcast
(
msgType
wire
.
MsgType
,
data
[]
interface
{})
Broadcast
(
msgType
wire
.
MsgType
,
data
[]
interface
{})
...
@@ -46,7 +46,7 @@ type EthManager interface {
...
@@ -46,7 +46,7 @@ type EthManager interface {
EventMux
()
*
event
.
TypeMux
EventMux
()
*
event
.
TypeMux
}
}
type
State
Manager
struct
{
type
Block
Manager
struct
{
// Mutex for locking the block processor. Blocks can only be handled one at a time
// Mutex for locking the block processor. Blocks can only be handled one at a time
mutex
sync
.
Mutex
mutex
sync
.
Mutex
// Canonical block chain
// Canonical block chain
...
@@ -74,8 +74,8 @@ type StateManager struct {
...
@@ -74,8 +74,8 @@ type StateManager struct {
events
event
.
Subscription
events
event
.
Subscription
}
}
func
New
StateManager
(
ethereum
EthManager
)
*
State
Manager
{
func
New
BlockManager
(
ethereum
EthManager
)
*
Block
Manager
{
sm
:=
&
State
Manager
{
sm
:=
&
Block
Manager
{
mem
:
make
(
map
[
string
]
*
big
.
Int
),
mem
:
make
(
map
[
string
]
*
big
.
Int
),
Pow
:
&
EasyPow
{},
Pow
:
&
EasyPow
{},
eth
:
ethereum
,
eth
:
ethereum
,
...
@@ -87,18 +87,18 @@ func NewStateManager(ethereum EthManager) *StateManager {
...
@@ -87,18 +87,18 @@ func NewStateManager(ethereum EthManager) *StateManager {
return
sm
return
sm
}
}
func
(
self
*
State
Manager
)
Start
()
{
func
(
self
*
Block
Manager
)
Start
()
{
statelogger
.
Debugln
(
"Starting state manager"
)
statelogger
.
Debugln
(
"Starting state manager"
)
self
.
events
=
self
.
eth
.
EventMux
()
.
Subscribe
(
Blocks
(
nil
))
self
.
events
=
self
.
eth
.
EventMux
()
.
Subscribe
(
Blocks
(
nil
))
go
self
.
updateThread
()
go
self
.
updateThread
()
}
}
func
(
self
*
State
Manager
)
Stop
()
{
func
(
self
*
Block
Manager
)
Stop
()
{
statelogger
.
Debugln
(
"Stopping state manager"
)
statelogger
.
Debugln
(
"Stopping state manager"
)
self
.
events
.
Unsubscribe
()
self
.
events
.
Unsubscribe
()
}
}
func
(
self
*
State
Manager
)
updateThread
()
{
func
(
self
*
Block
Manager
)
updateThread
()
{
for
ev
:=
range
self
.
events
.
Chan
()
{
for
ev
:=
range
self
.
events
.
Chan
()
{
for
_
,
block
:=
range
ev
.
(
Blocks
)
{
for
_
,
block
:=
range
ev
.
(
Blocks
)
{
err
:=
self
.
Process
(
block
)
err
:=
self
.
Process
(
block
)
...
@@ -112,29 +112,29 @@ func (self *StateManager) updateThread() {
...
@@ -112,29 +112,29 @@ func (self *StateManager) updateThread() {
}
}
}
}
func
(
sm
*
State
Manager
)
CurrentState
()
*
state
.
State
{
func
(
sm
*
Block
Manager
)
CurrentState
()
*
state
.
State
{
return
sm
.
eth
.
ChainManager
()
.
CurrentBlock
.
State
()
return
sm
.
eth
.
ChainManager
()
.
CurrentBlock
.
State
()
}
}
func
(
sm
*
State
Manager
)
TransState
()
*
state
.
State
{
func
(
sm
*
Block
Manager
)
TransState
()
*
state
.
State
{
return
sm
.
transState
return
sm
.
transState
}
}
func
(
sm
*
State
Manager
)
MiningState
()
*
state
.
State
{
func
(
sm
*
Block
Manager
)
MiningState
()
*
state
.
State
{
return
sm
.
miningState
return
sm
.
miningState
}
}
func
(
sm
*
State
Manager
)
NewMiningState
()
*
state
.
State
{
func
(
sm
*
Block
Manager
)
NewMiningState
()
*
state
.
State
{
sm
.
miningState
=
sm
.
eth
.
ChainManager
()
.
CurrentBlock
.
State
()
.
Copy
()
sm
.
miningState
=
sm
.
eth
.
ChainManager
()
.
CurrentBlock
.
State
()
.
Copy
()
return
sm
.
miningState
return
sm
.
miningState
}
}
func
(
sm
*
State
Manager
)
ChainManager
()
*
ChainManager
{
func
(
sm
*
Block
Manager
)
ChainManager
()
*
ChainManager
{
return
sm
.
bc
return
sm
.
bc
}
}
func
(
self
*
State
Manager
)
ProcessTransactions
(
coinbase
*
state
.
StateObject
,
state
*
state
.
State
,
block
,
parent
*
Block
,
txs
Transactions
)
(
Receipts
,
Transactions
,
Transactions
,
Transactions
,
error
)
{
func
(
self
*
Block
Manager
)
ProcessTransactions
(
coinbase
*
state
.
StateObject
,
state
*
state
.
State
,
block
,
parent
*
Block
,
txs
Transactions
)
(
Receipts
,
Transactions
,
Transactions
,
Transactions
,
error
)
{
var
(
var
(
receipts
Receipts
receipts
Receipts
handled
,
unhandled
Transactions
handled
,
unhandled
Transactions
...
@@ -209,7 +209,7 @@ done:
...
@@ -209,7 +209,7 @@ done:
return
receipts
,
handled
,
unhandled
,
erroneous
,
err
return
receipts
,
handled
,
unhandled
,
erroneous
,
err
}
}
func
(
sm
*
State
Manager
)
Process
(
block
*
Block
)
(
err
error
)
{
func
(
sm
*
Block
Manager
)
Process
(
block
*
Block
)
(
err
error
)
{
// Processing a blocks may never happen simultaneously
// Processing a blocks may never happen simultaneously
sm
.
mutex
.
Lock
()
sm
.
mutex
.
Lock
()
defer
sm
.
mutex
.
Unlock
()
defer
sm
.
mutex
.
Unlock
()
...
@@ -298,7 +298,7 @@ func (sm *StateManager) Process(block *Block) (err error) {
...
@@ -298,7 +298,7 @@ func (sm *StateManager) Process(block *Block) (err error) {
return
nil
return
nil
}
}
func
(
sm
*
State
Manager
)
ApplyDiff
(
state
*
state
.
State
,
parent
,
block
*
Block
)
(
receipts
Receipts
,
err
error
)
{
func
(
sm
*
Block
Manager
)
ApplyDiff
(
state
*
state
.
State
,
parent
,
block
*
Block
)
(
receipts
Receipts
,
err
error
)
{
coinbase
:=
state
.
GetOrNewStateObject
(
block
.
Coinbase
)
coinbase
:=
state
.
GetOrNewStateObject
(
block
.
Coinbase
)
coinbase
.
SetGasPool
(
block
.
CalcGasLimit
(
parent
))
coinbase
.
SetGasPool
(
block
.
CalcGasLimit
(
parent
))
...
@@ -311,7 +311,7 @@ func (sm *StateManager) ApplyDiff(state *state.State, parent, block *Block) (rec
...
@@ -311,7 +311,7 @@ func (sm *StateManager) ApplyDiff(state *state.State, parent, block *Block) (rec
return
receipts
,
nil
return
receipts
,
nil
}
}
func
(
sm
*
State
Manager
)
CalculateTD
(
block
*
Block
)
bool
{
func
(
sm
*
Block
Manager
)
CalculateTD
(
block
*
Block
)
bool
{
uncleDiff
:=
new
(
big
.
Int
)
uncleDiff
:=
new
(
big
.
Int
)
for
_
,
uncle
:=
range
block
.
Uncles
{
for
_
,
uncle
:=
range
block
.
Uncles
{
uncleDiff
=
uncleDiff
.
Add
(
uncleDiff
,
uncle
.
Difficulty
)
uncleDiff
=
uncleDiff
.
Add
(
uncleDiff
,
uncle
.
Difficulty
)
...
@@ -337,7 +337,7 @@ func (sm *StateManager) CalculateTD(block *Block) bool {
...
@@ -337,7 +337,7 @@ func (sm *StateManager) CalculateTD(block *Block) bool {
// Validates the current block. Returns an error if the block was invalid,
// Validates the current block. Returns an error if the block was invalid,
// an uncle or anything that isn't on the current block chain.
// an uncle or anything that isn't on the current block chain.
// Validation validates easy over difficult (dagger takes longer time = difficult)
// Validation validates easy over difficult (dagger takes longer time = difficult)
func
(
sm
*
State
Manager
)
ValidateBlock
(
block
*
Block
)
error
{
func
(
sm
*
Block
Manager
)
ValidateBlock
(
block
*
Block
)
error
{
// Check each uncle's previous hash. In order for it to be valid
// Check each uncle's previous hash. In order for it to be valid
// is if it has the same block hash as the current
// is if it has the same block hash as the current
parent
:=
sm
.
bc
.
GetBlock
(
block
.
PrevHash
)
parent
:=
sm
.
bc
.
GetBlock
(
block
.
PrevHash
)
...
@@ -374,7 +374,7 @@ func (sm *StateManager) ValidateBlock(block *Block) error {
...
@@ -374,7 +374,7 @@ func (sm *StateManager) ValidateBlock(block *Block) error {
return
nil
return
nil
}
}
func
(
sm
*
State
Manager
)
AccumelateRewards
(
state
*
state
.
State
,
block
,
parent
*
Block
)
error
{
func
(
sm
*
Block
Manager
)
AccumelateRewards
(
state
*
state
.
State
,
block
,
parent
*
Block
)
error
{
reward
:=
new
(
big
.
Int
)
.
Set
(
BlockReward
)
reward
:=
new
(
big
.
Int
)
.
Set
(
BlockReward
)
knownUncles
:=
ethutil
.
Set
(
parent
.
Uncles
)
knownUncles
:=
ethutil
.
Set
(
parent
.
Uncles
)
...
@@ -417,21 +417,7 @@ func (sm *StateManager) AccumelateRewards(state *state.State, block, parent *Blo
...
@@ -417,21 +417,7 @@ func (sm *StateManager) AccumelateRewards(state *state.State, block, parent *Blo
return
nil
return
nil
}
}
// Manifest will handle both creating notifications and generating bloom bin data
func
(
sm
*
BlockManager
)
GetMessages
(
block
*
Block
)
(
messages
[]
*
state
.
Message
,
err
error
)
{
func
(
sm
*
StateManager
)
createBloomFilter
(
state
*
state
.
State
)
*
BloomFilter
{
bloomf
:=
NewBloomFilter
(
nil
)
for
_
,
msg
:=
range
state
.
Manifest
()
.
Messages
{
bloomf
.
Set
(
msg
.
To
)
bloomf
.
Set
(
msg
.
From
)
}
sm
.
eth
.
EventMux
()
.
Post
(
state
.
Manifest
()
.
Messages
)
return
bloomf
}
func
(
sm
*
StateManager
)
GetMessages
(
block
*
Block
)
(
messages
[]
*
state
.
Message
,
err
error
)
{
if
!
sm
.
bc
.
HasBlock
(
block
.
PrevHash
)
{
if
!
sm
.
bc
.
HasBlock
(
block
.
PrevHash
)
{
return
nil
,
ParentError
(
block
.
PrevHash
)
return
nil
,
ParentError
(
block
.
PrevHash
)
}
}
...
...
chain/bloom9_test.go
View file @
f59a3b67
package
chain
package
chain
import
(
import
(
"fmt"
"testing"
"testing"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/state"
"github.com/ethgo.old/ethutil"
)
)
func
TestBloom9
(
t
*
testing
.
T
)
{
func
TestBloom9
(
t
*
testing
.
T
)
{
...
@@ -21,6 +17,7 @@ func TestBloom9(t *testing.T) {
...
@@ -21,6 +17,7 @@ func TestBloom9(t *testing.T) {
}
}
}
}
/*
func TestAddress(t *testing.T) {
func TestAddress(t *testing.T) {
block := &Block{}
block := &Block{}
block.Coinbase = ethutil.Hex2Bytes("22341ae42d6dd7384bc8584e50419ea3ac75b83f")
block.Coinbase = ethutil.Hex2Bytes("22341ae42d6dd7384bc8584e50419ea3ac75b83f")
...
@@ -29,3 +26,4 @@ func TestAddress(t *testing.T) {
...
@@ -29,3 +26,4 @@ func TestAddress(t *testing.T) {
bin := CreateBloom(block)
bin := CreateBloom(block)
fmt.Printf("bin = %x\n", ethutil.LeftPadBytes(bin, 64))
fmt.Printf("bin = %x\n", ethutil.LeftPadBytes(bin, 64))
}
}
*/
chain/filter.go
View file @
f59a3b67
...
@@ -100,7 +100,7 @@ func (self *Filter) Find() []*state.Message {
...
@@ -100,7 +100,7 @@ func (self *Filter) Find() []*state.Message {
// current parameters
// current parameters
if
self
.
bloomFilter
(
block
)
{
if
self
.
bloomFilter
(
block
)
{
// Get the messages of the block
// Get the messages of the block
msgs
,
err
:=
self
.
eth
.
State
Manager
()
.
GetMessages
(
block
)
msgs
,
err
:=
self
.
eth
.
Block
Manager
()
.
GetMessages
(
block
)
if
err
!=
nil
{
if
err
!=
nil
{
chainlogger
.
Warnln
(
"err: filter get messages "
,
err
)
chainlogger
.
Warnln
(
"err: filter get messages "
,
err
)
...
...
chain/transaction_pool.go
View file @
f59a3b67
...
@@ -114,8 +114,8 @@ func (pool *TxPool) ValidateTransaction(tx *Transaction) error {
...
@@ -114,8 +114,8 @@ func (pool *TxPool) ValidateTransaction(tx *Transaction) error {
}
}
// Get the sender
// Get the sender
//sender := pool.Ethereum.
State
Manager().procState.GetAccount(tx.Sender())
//sender := pool.Ethereum.
Block
Manager().procState.GetAccount(tx.Sender())
sender
:=
pool
.
Ethereum
.
State
Manager
()
.
CurrentState
()
.
GetAccount
(
tx
.
Sender
())
sender
:=
pool
.
Ethereum
.
Block
Manager
()
.
CurrentState
()
.
GetAccount
(
tx
.
Sender
())
totAmount
:=
new
(
big
.
Int
)
.
Set
(
tx
.
Value
)
totAmount
:=
new
(
big
.
Int
)
.
Set
(
tx
.
Value
)
// Make sure there's enough in the sender's account. Having insufficient
// Make sure there's enough in the sender's account. Having insufficient
...
...
cmd/mist/bindings.go
View file @
f59a3b67
...
@@ -108,7 +108,7 @@ func (self *Gui) DumpState(hash, path string) {
...
@@ -108,7 +108,7 @@ func (self *Gui) DumpState(hash, path string) {
var
stateDump
[]
byte
var
stateDump
[]
byte
if
len
(
hash
)
==
0
{
if
len
(
hash
)
==
0
{
stateDump
=
self
.
eth
.
State
Manager
()
.
CurrentState
()
.
Dump
()
stateDump
=
self
.
eth
.
Block
Manager
()
.
CurrentState
()
.
Dump
()
}
else
{
}
else
{
var
block
*
chain
.
Block
var
block
*
chain
.
Block
if
hash
[
0
]
==
'#'
{
if
hash
[
0
]
==
'#'
{
...
...
cmd/mist/debugger.go
View file @
f59a3b67
...
@@ -141,8 +141,8 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
...
@@ -141,8 +141,8 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
keyPair
=
self
.
lib
.
eth
.
KeyManager
()
.
KeyPair
()
keyPair
=
self
.
lib
.
eth
.
KeyManager
()
.
KeyPair
()
)
)
statedb
:=
self
.
lib
.
eth
.
State
Manager
()
.
TransState
()
statedb
:=
self
.
lib
.
eth
.
Block
Manager
()
.
TransState
()
account
:=
self
.
lib
.
eth
.
State
Manager
()
.
TransState
()
.
GetAccount
(
keyPair
.
Address
())
account
:=
self
.
lib
.
eth
.
Block
Manager
()
.
TransState
()
.
GetAccount
(
keyPair
.
Address
())
contract
:=
statedb
.
NewStateObject
([]
byte
{
0
})
contract
:=
statedb
.
NewStateObject
([]
byte
{
0
})
contract
.
SetBalance
(
value
)
contract
.
SetBalance
(
value
)
...
...
cmd/mist/gui.go
View file @
f59a3b67
...
@@ -396,7 +396,7 @@ func (gui *Gui) update() {
...
@@ -396,7 +396,7 @@ func (gui *Gui) update() {
generalUpdateTicker
:=
time
.
NewTicker
(
500
*
time
.
Millisecond
)
generalUpdateTicker
:=
time
.
NewTicker
(
500
*
time
.
Millisecond
)
statsUpdateTicker
:=
time
.
NewTicker
(
5
*
time
.
Second
)
statsUpdateTicker
:=
time
.
NewTicker
(
5
*
time
.
Second
)
state
:=
gui
.
eth
.
State
Manager
()
.
TransState
()
state
:=
gui
.
eth
.
Block
Manager
()
.
TransState
()
unconfirmedFunds
:=
new
(
big
.
Int
)
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
())))
...
@@ -428,7 +428,7 @@ func (gui *Gui) update() {
...
@@ -428,7 +428,7 @@ func (gui *Gui) update() {
case
chain
.
NewBlockEvent
:
case
chain
.
NewBlockEvent
:
gui
.
processBlock
(
ev
.
Block
,
false
)
gui
.
processBlock
(
ev
.
Block
,
false
)
if
bytes
.
Compare
(
ev
.
Block
.
Coinbase
,
gui
.
address
())
==
0
{
if
bytes
.
Compare
(
ev
.
Block
.
Coinbase
,
gui
.
address
())
==
0
{
gui
.
setWalletValue
(
gui
.
eth
.
State
Manager
()
.
CurrentState
()
.
GetAccount
(
gui
.
address
())
.
Balance
(),
nil
)
gui
.
setWalletValue
(
gui
.
eth
.
Block
Manager
()
.
CurrentState
()
.
GetAccount
(
gui
.
address
())
.
Balance
(),
nil
)
}
}
case
chain
.
TxPreEvent
:
case
chain
.
TxPreEvent
:
...
...
cmd/mist/ui_lib.go
View file @
f59a3b67
...
@@ -190,7 +190,7 @@ func (ui *UiLib) AssetPath(p string) string {
...
@@ -190,7 +190,7 @@ func (ui *UiLib) AssetPath(p string) string {
func
(
self
*
UiLib
)
StartDbWithContractAndData
(
contractHash
,
data
string
)
{
func
(
self
*
UiLib
)
StartDbWithContractAndData
(
contractHash
,
data
string
)
{
dbWindow
:=
NewDebuggerWindow
(
self
)
dbWindow
:=
NewDebuggerWindow
(
self
)
object
:=
self
.
eth
.
State
Manager
()
.
CurrentState
()
.
GetStateObject
(
ethutil
.
Hex2Bytes
(
contractHash
))
object
:=
self
.
eth
.
Block
Manager
()
.
CurrentState
()
.
GetStateObject
(
ethutil
.
Hex2Bytes
(
contractHash
))
if
len
(
object
.
Code
)
>
0
{
if
len
(
object
.
Code
)
>
0
{
dbWindow
.
SetCode
(
"0x"
+
ethutil
.
Bytes2Hex
(
object
.
Code
))
dbWindow
.
SetCode
(
"0x"
+
ethutil
.
Bytes2Hex
(
object
.
Code
))
}
}
...
...
cmd/utils/cmd.go
View file @
f59a3b67
...
@@ -317,7 +317,7 @@ func BlockDo(ethereum *eth.Ethereum, hash []byte) error {
...
@@ -317,7 +317,7 @@ func BlockDo(ethereum *eth.Ethereum, hash []byte) error {
parent
:=
ethereum
.
ChainManager
()
.
GetBlock
(
block
.
PrevHash
)
parent
:=
ethereum
.
ChainManager
()
.
GetBlock
(
block
.
PrevHash
)
_
,
err
:=
ethereum
.
State
Manager
()
.
ApplyDiff
(
parent
.
State
(),
parent
,
block
)
_
,
err
:=
ethereum
.
Block
Manager
()
.
ApplyDiff
(
parent
.
State
(),
parent
,
block
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
ethereum.go
View file @
f59a3b67
...
@@ -50,7 +50,7 @@ type Ethereum struct {
...
@@ -50,7 +50,7 @@ type Ethereum struct {
// DB interface
// DB interface
db
ethutil
.
Database
db
ethutil
.
Database
// State manager for processing new blocks and managing the over all states
// State manager for processing new blocks and managing the over all states
stateManager
*
chain
.
State
Manager
blockManager
*
chain
.
Block
Manager
// The transaction pool. Transaction can be pushed on this pool
// The transaction pool. Transaction can be pushed on this pool
// for later including in the blocks
// for later including in the blocks
txPool
*
chain
.
TxPool
txPool
*
chain
.
TxPool
...
@@ -130,7 +130,7 @@ func New(db ethutil.Database, clientIdentity wire.ClientIdentity, keyManager *cr
...
@@ -130,7 +130,7 @@ func New(db ethutil.Database, clientIdentity wire.ClientIdentity, keyManager *cr
ethereum
.
blockPool
=
NewBlockPool
(
ethereum
)
ethereum
.
blockPool
=
NewBlockPool
(
ethereum
)
ethereum
.
txPool
=
chain
.
NewTxPool
(
ethereum
)
ethereum
.
txPool
=
chain
.
NewTxPool
(
ethereum
)
ethereum
.
blockChain
=
chain
.
NewChainManager
(
ethereum
)
ethereum
.
blockChain
=
chain
.
NewChainManager
(
ethereum
)
ethereum
.
stateManager
=
chain
.
NewState
Manager
(
ethereum
)
ethereum
.
blockManager
=
chain
.
NewBlock
Manager
(
ethereum
)
// Start the tx pool
// Start the tx pool
ethereum
.
txPool
.
Start
()
ethereum
.
txPool
.
Start
()
...
@@ -150,8 +150,8 @@ func (s *Ethereum) ChainManager() *chain.ChainManager {
...
@@ -150,8 +150,8 @@ func (s *Ethereum) ChainManager() *chain.ChainManager {
return
s
.
blockChain
return
s
.
blockChain
}
}
func
(
s
*
Ethereum
)
StateManager
()
*
chain
.
State
Manager
{
func
(
s
*
Ethereum
)
BlockManager
()
*
chain
.
Block
Manager
{
return
s
.
state
Manager
return
s
.
block
Manager
}
}
func
(
s
*
Ethereum
)
TxPool
()
*
chain
.
TxPool
{
func
(
s
*
Ethereum
)
TxPool
()
*
chain
.
TxPool
{
...
@@ -392,7 +392,7 @@ func (s *Ethereum) reapDeadPeerHandler() {
...
@@ -392,7 +392,7 @@ func (s *Ethereum) reapDeadPeerHandler() {
// Start the ethereum
// Start the ethereum
func
(
s
*
Ethereum
)
Start
(
seed
bool
)
{
func
(
s
*
Ethereum
)
Start
(
seed
bool
)
{
s
.
blockPool
.
Start
()
s
.
blockPool
.
Start
()
s
.
state
Manager
.
Start
()
s
.
block
Manager
.
Start
()
// Bind to addr and port
// Bind to addr and port
ln
,
err
:=
net
.
Listen
(
"tcp"
,
":"
+
s
.
Port
)
ln
,
err
:=
net
.
Listen
(
"tcp"
,
":"
+
s
.
Port
)
...
@@ -516,7 +516,7 @@ func (s *Ethereum) Stop() {
...
@@ -516,7 +516,7 @@ func (s *Ethereum) Stop() {
s
.
RpcServer
.
Stop
()
s
.
RpcServer
.
Stop
()
}
}
s
.
txPool
.
Stop
()
s
.
txPool
.
Stop
()
s
.
state
Manager
.
Stop
()
s
.
block
Manager
.
Stop
()
s
.
blockPool
.
Stop
()
s
.
blockPool
.
Stop
()
loggerger
.
Infoln
(
"Server stopped"
)
loggerger
.
Infoln
(
"Server stopped"
)
...
...
javascript/javascript_runtime.go
View file @
f59a3b67
...
@@ -149,7 +149,7 @@ func (self *JSRE) dump(call otto.FunctionCall) otto.Value {
...
@@ -149,7 +149,7 @@ func (self *JSRE) dump(call otto.FunctionCall) otto.Value {
state
=
block
.
State
()
state
=
block
.
State
()
}
else
{
}
else
{
state
=
self
.
ethereum
.
State
Manager
()
.
CurrentState
()
state
=
self
.
ethereum
.
Block
Manager
()
.
CurrentState
()
}
}
v
,
_
:=
self
.
Vm
.
ToValue
(
state
.
Dump
())
v
,
_
:=
self
.
Vm
.
ToValue
(
state
.
Dump
())
...
...
miner/miner.go
View file @
f59a3b67
...
@@ -67,7 +67,7 @@ func (miner *Miner) Start() {
...
@@ -67,7 +67,7 @@ func (miner *Miner) Start() {
miner
.
events
=
mux
.
Subscribe
(
chain
.
NewBlockEvent
{},
chain
.
TxPreEvent
{})
miner
.
events
=
mux
.
Subscribe
(
chain
.
NewBlockEvent
{},
chain
.
TxPreEvent
{})
// Prepare inital block
// Prepare inital block
//miner.ethereum.
State
Manager().Prepare(miner.block.State(), miner.block.State())
//miner.ethereum.
Block
Manager().Prepare(miner.block.State(), miner.block.State())
go
miner
.
listener
()
go
miner
.
listener
()
minerlogger
.
Infoln
(
"Started"
)
minerlogger
.
Infoln
(
"Started"
)
...
@@ -161,7 +161,7 @@ func (miner *Miner) stopMining() {
...
@@ -161,7 +161,7 @@ func (miner *Miner) stopMining() {
}
}
func
(
self
*
Miner
)
mineNewBlock
()
{
func
(
self
*
Miner
)
mineNewBlock
()
{
stateManager
:=
self
.
ethereum
.
State
Manager
()
blockManager
:=
self
.
ethereum
.
Block
Manager
()
self
.
block
=
self
.
ethereum
.
ChainManager
()
.
NewBlock
(
self
.
coinbase
)
self
.
block
=
self
.
ethereum
.
ChainManager
()
.
NewBlock
(
self
.
coinbase
)
...
@@ -178,7 +178,7 @@ func (self *Miner) mineNewBlock() {
...
@@ -178,7 +178,7 @@ func (self *Miner) mineNewBlock() {
parent
:=
self
.
ethereum
.
ChainManager
()
.
GetBlock
(
self
.
block
.
PrevHash
)
parent
:=
self
.
ethereum
.
ChainManager
()
.
GetBlock
(
self
.
block
.
PrevHash
)
coinbase
:=
self
.
block
.
State
()
.
GetOrNewStateObject
(
self
.
block
.
Coinbase
)
coinbase
:=
self
.
block
.
State
()
.
GetOrNewStateObject
(
self
.
block
.
Coinbase
)
coinbase
.
SetGasPool
(
self
.
block
.
CalcGasLimit
(
parent
))
coinbase
.
SetGasPool
(
self
.
block
.
CalcGasLimit
(
parent
))
receipts
,
txs
,
unhandledTxs
,
erroneous
,
err
:=
state
Manager
.
ProcessTransactions
(
coinbase
,
self
.
block
.
State
(),
self
.
block
,
self
.
block
,
self
.
txs
)
receipts
,
txs
,
unhandledTxs
,
erroneous
,
err
:=
block
Manager
.
ProcessTransactions
(
coinbase
,
self
.
block
.
State
(),
self
.
block
,
self
.
block
,
self
.
txs
)
if
err
!=
nil
{
if
err
!=
nil
{
minerlogger
.
Debugln
(
err
)
minerlogger
.
Debugln
(
err
)
}
}
...
@@ -189,7 +189,7 @@ func (self *Miner) mineNewBlock() {
...
@@ -189,7 +189,7 @@ func (self *Miner) mineNewBlock() {
self
.
block
.
SetReceipts
(
receipts
)
self
.
block
.
SetReceipts
(
receipts
)
// Accumulate the rewards included for this block
// Accumulate the rewards included for this block
state
Manager
.
AccumelateRewards
(
self
.
block
.
State
(),
self
.
block
,
parent
)
block
Manager
.
AccumelateRewards
(
self
.
block
.
State
(),
self
.
block
,
parent
)
self
.
block
.
State
()
.
Update
()
self
.
block
.
State
()
.
Update
()
...
@@ -199,7 +199,7 @@ func (self *Miner) mineNewBlock() {
...
@@ -199,7 +199,7 @@ func (self *Miner) mineNewBlock() {
nonce
:=
self
.
pow
.
Search
(
self
.
block
,
self
.
powQuitChan
)
nonce
:=
self
.
pow
.
Search
(
self
.
block
,
self
.
powQuitChan
)
if
nonce
!=
nil
{
if
nonce
!=
nil
{
self
.
block
.
Nonce
=
nonce
self
.
block
.
Nonce
=
nonce
err
:=
self
.
ethereum
.
State
Manager
()
.
Process
(
self
.
block
)
err
:=
self
.
ethereum
.
Block
Manager
()
.
Process
(
self
.
block
)
if
err
!=
nil
{
if
err
!=
nil
{
minerlogger
.
Infoln
(
err
)
minerlogger
.
Infoln
(
err
)
}
else
{
}
else
{
...
...
xeth/hexface.go
View file @
f59a3b67
...
@@ -224,10 +224,10 @@ func (self *JSXEth) Transact(key, toStr, valueStr, gasStr, gasPriceStr, codeStr
...
@@ -224,10 +224,10 @@ func (self *JSXEth) Transact(key, toStr, valueStr, gasStr, gasPriceStr, codeStr
tx
=
chain
.
NewTransactionMessage
(
hash
,
value
,
gas
,
gasPrice
,
data
)
tx
=
chain
.
NewTransactionMessage
(
hash
,
value
,
gas
,
gasPrice
,
data
)
}
}
acc
:=
self
.
obj
.
State
Manager
()
.
TransState
()
.
GetOrNewStateObject
(
keyPair
.
Address
())
acc
:=
self
.
obj
.
Block
Manager
()
.
TransState
()
.
GetOrNewStateObject
(
keyPair
.
Address
())
tx
.
Nonce
=
acc
.
Nonce
tx
.
Nonce
=
acc
.
Nonce
acc
.
Nonce
+=
1
acc
.
Nonce
+=
1
self
.
obj
.
State
Manager
()
.
TransState
()
.
UpdateStateObject
(
acc
)
self
.
obj
.
Block
Manager
()
.
TransState
()
.
UpdateStateObject
(
acc
)
tx
.
Sign
(
keyPair
.
PrivateKey
)
tx
.
Sign
(
keyPair
.
PrivateKey
)
self
.
obj
.
TxPool
()
.
QueueTransaction
(
tx
)
self
.
obj
.
TxPool
()
.
QueueTransaction
(
tx
)
...
...
xeth/pipe.go
View file @
f59a3b67
...
@@ -24,7 +24,7 @@ type VmVars struct {
...
@@ -24,7 +24,7 @@ type VmVars struct {
type
XEth
struct
{
type
XEth
struct
{
obj
chain
.
EthManager
obj
chain
.
EthManager
stateManager
*
chain
.
State
Manager
blockManager
*
chain
.
Block
Manager
blockChain
*
chain
.
ChainManager
blockChain
*
chain
.
ChainManager
world
*
World
world
*
World
...
@@ -34,7 +34,7 @@ type XEth struct {
...
@@ -34,7 +34,7 @@ type XEth struct {
func
New
(
obj
chain
.
EthManager
)
*
XEth
{
func
New
(
obj
chain
.
EthManager
)
*
XEth
{
pipe
:=
&
XEth
{
pipe
:=
&
XEth
{
obj
:
obj
,
obj
:
obj
,
stateManager
:
obj
.
State
Manager
(),
blockManager
:
obj
.
Block
Manager
(),
blockChain
:
obj
.
ChainManager
(),
blockChain
:
obj
.
ChainManager
(),
}
}
pipe
.
world
=
NewWorld
(
pipe
)
pipe
.
world
=
NewWorld
(
pipe
)
...
@@ -137,10 +137,10 @@ func (self *XEth) Transact(key *crypto.KeyPair, rec []byte, value, gas, price *e
...
@@ -137,10 +137,10 @@ func (self *XEth) Transact(key *crypto.KeyPair, rec []byte, value, gas, price *e
tx
=
chain
.
NewTransactionMessage
(
hash
,
value
.
BigInt
(),
gas
.
BigInt
(),
price
.
BigInt
(),
data
)
tx
=
chain
.
NewTransactionMessage
(
hash
,
value
.
BigInt
(),
gas
.
BigInt
(),
price
.
BigInt
(),
data
)
}
}
acc
:=
self
.
state
Manager
.
TransState
()
.
GetOrNewStateObject
(
key
.
Address
())
acc
:=
self
.
block
Manager
.
TransState
()
.
GetOrNewStateObject
(
key
.
Address
())
tx
.
Nonce
=
acc
.
Nonce
tx
.
Nonce
=
acc
.
Nonce
acc
.
Nonce
+=
1
acc
.
Nonce
+=
1
self
.
state
Manager
.
TransState
()
.
UpdateStateObject
(
acc
)
self
.
block
Manager
.
TransState
()
.
UpdateStateObject
(
acc
)
tx
.
Sign
(
key
.
PrivateKey
)
tx
.
Sign
(
key
.
PrivateKey
)
self
.
obj
.
TxPool
()
.
QueueTransaction
(
tx
)
self
.
obj
.
TxPool
()
.
QueueTransaction
(
tx
)
...
...
xeth/world.go
View file @
f59a3b67
...
@@ -23,7 +23,7 @@ func (self *XEth) World() *World {
...
@@ -23,7 +23,7 @@ func (self *XEth) World() *World {
}
}
func
(
self
*
World
)
State
()
*
state
.
State
{
func
(
self
*
World
)
State
()
*
state
.
State
{
return
self
.
pipe
.
state
Manager
.
CurrentState
()
return
self
.
pipe
.
block
Manager
.
CurrentState
()
}
}
func
(
self
*
World
)
Get
(
addr
[]
byte
)
*
Object
{
func
(
self
*
World
)
Get
(
addr
[]
byte
)
*
Object
{
...
...
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