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
006ac772
Commit
006ac772
authored
Jun 09, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release/poc5-rc12'
parents
fb6ff617
a51dfe89
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
62 additions
and
16 deletions
+62
-16
README.md
README.md
+1
-1
state_manager.go
ethchain/state_manager.go
+2
-1
vm.go
ethchain/vm.go
+1
-1
pub.go
ethpub/pub.go
+1
-0
types.go
ethpub/types.go
+27
-1
common.go
ethutil/common.go
+13
-7
config.go
ethutil/config.go
+1
-1
peer.go
peer.go
+16
-4
No files found.
README.md
View file @
006ac772
...
@@ -6,7 +6,7 @@ Ethereum
...
@@ -6,7 +6,7 @@ Ethereum
Ethereum Go Development package (C) Jeffrey Wilcke
Ethereum Go Development package (C) Jeffrey Wilcke
Ethereum is currently in its testing phase. The current state is "Proof
Ethereum is currently in its testing phase. The current state is "Proof
of Concept 5.0 RC1
1
". For build instructions see the
[
Wiki
](
https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum(Go
)
).
of Concept 5.0 RC1
2
". For build instructions see the
[
Wiki
](
https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum(Go
)
).
Ethereum Go is split up in several sub packages Please refer to each
Ethereum Go is split up in several sub packages Please refer to each
individual package for more information.
individual package for more information.
...
...
ethchain/state_manager.go
View file @
006ac772
...
@@ -22,6 +22,7 @@ type Peer interface {
...
@@ -22,6 +22,7 @@ type Peer interface {
Host
()
[]
byte
Host
()
[]
byte
Port
()
uint16
Port
()
uint16
Version
()
string
Version
()
string
PingTime
()
string
Connected
()
*
int32
Connected
()
*
int32
}
}
...
@@ -177,7 +178,7 @@ func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transac
...
@@ -177,7 +178,7 @@ func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transac
err
=
fmt
.
Errorf
(
"[STATE] Unable to create contract"
)
err
=
fmt
.
Errorf
(
"[STATE] Unable to create contract"
)
}
}
}
else
{
}
else
{
err
=
fmt
.
Errorf
(
"[STATE] contract creation tx: %v
"
,
err
)
err
=
fmt
.
Errorf
(
"[STATE] contract creation tx: %v
for sender %x"
,
err
,
tx
.
Sender
()
)
}
}
}
else
{
}
else
{
// Find the state object at the "recipient" address. If
// Find the state object at the "recipient" address. If
...
...
ethchain/vm.go
View file @
006ac772
...
@@ -309,7 +309,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
...
@@ -309,7 +309,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
case
SHA3
:
case
SHA3
:
require
(
2
)
require
(
2
)
size
,
offset
:=
stack
.
Popn
()
size
,
offset
:=
stack
.
Popn
()
data
:=
mem
.
Get
(
offset
.
Int64
(),
size
.
Int64
(
))
data
:=
ethutil
.
Sha3Bin
(
mem
.
Get
(
offset
.
Int64
(),
size
.
Int64
()
))
stack
.
Push
(
ethutil
.
BigD
(
data
))
stack
.
Push
(
ethutil
.
BigD
(
data
))
// 0x30 range
// 0x30 range
...
...
ethpub/pub.go
View file @
006ac772
...
@@ -56,6 +56,7 @@ func (lib *PEthereum) GetPeers() []PPeer {
...
@@ -56,6 +56,7 @@ func (lib *PEthereum) GetPeers() []PPeer {
var
peers
[]
PPeer
var
peers
[]
PPeer
for
peer
:=
lib
.
manager
.
Peers
()
.
Front
();
peer
!=
nil
;
peer
=
peer
.
Next
()
{
for
peer
:=
lib
.
manager
.
Peers
()
.
Front
();
peer
!=
nil
;
peer
=
peer
.
Next
()
{
p
:=
peer
.
Value
.
(
ethchain
.
Peer
)
p
:=
peer
.
Value
.
(
ethchain
.
Peer
)
// we only want connected peers
if
atomic
.
LoadInt32
(
p
.
Connected
())
!=
0
{
if
atomic
.
LoadInt32
(
p
.
Connected
())
!=
0
{
peers
=
append
(
peers
,
*
NewPPeer
(
p
))
peers
=
append
(
peers
,
*
NewPPeer
(
p
))
}
}
...
...
ethpub/types.go
View file @
006ac772
...
@@ -20,6 +20,7 @@ type PPeer struct {
...
@@ -20,6 +20,7 @@ type PPeer struct {
Port
int
`json:"port"`
Port
int
`json:"port"`
Version
string
`json:"version"`
Version
string
`json:"version"`
LastResponse
string
`json:"lastResponse"`
LastResponse
string
`json:"lastResponse"`
Latency
string
`json:"latency"`
}
}
func
NewPPeer
(
peer
ethchain
.
Peer
)
*
PPeer
{
func
NewPPeer
(
peer
ethchain
.
Peer
)
*
PPeer
{
...
@@ -34,7 +35,7 @@ func NewPPeer(peer ethchain.Peer) *PPeer {
...
@@ -34,7 +35,7 @@ func NewPPeer(peer ethchain.Peer) *PPeer {
}
}
ipAddress
:=
strings
.
Join
(
ip
,
"."
)
ipAddress
:=
strings
.
Join
(
ip
,
"."
)
return
&
PPeer
{
ref
:
&
peer
,
Inbound
:
peer
.
Inbound
(),
LastSend
:
peer
.
LastSend
()
.
Unix
(),
LastPong
:
peer
.
LastPong
(),
Version
:
peer
.
Version
(),
Ip
:
ipAddress
,
Port
:
int
(
peer
.
Port
())}
return
&
PPeer
{
ref
:
&
peer
,
Inbound
:
peer
.
Inbound
(),
LastSend
:
peer
.
LastSend
()
.
Unix
(),
LastPong
:
peer
.
LastPong
(),
Version
:
peer
.
Version
(),
Ip
:
ipAddress
,
Port
:
int
(
peer
.
Port
())
,
Latency
:
peer
.
PingTime
()
}
}
}
// Block interface exposed to QML
// Block interface exposed to QML
...
@@ -206,6 +207,31 @@ func (c *PStateObject) IsContract() bool {
...
@@ -206,6 +207,31 @@ func (c *PStateObject) IsContract() bool {
return
false
return
false
}
}
type
KeyVal
struct
{
Key
string
Value
string
}
func
(
c
*
PStateObject
)
StateKeyVal
(
asJson
bool
)
interface
{}
{
var
values
[]
KeyVal
if
c
.
object
!=
nil
{
c
.
object
.
State
()
.
EachStorage
(
func
(
name
string
,
value
*
ethutil
.
Value
)
{
values
=
append
(
values
,
KeyVal
{
name
,
ethutil
.
Hex
(
value
.
Bytes
())})
})
}
if
asJson
{
valuesJson
,
err
:=
json
.
Marshal
(
values
)
if
err
!=
nil
{
return
nil
}
fmt
.
Println
(
string
(
valuesJson
))
return
string
(
valuesJson
)
}
return
values
}
func
(
c
*
PStateObject
)
Script
()
string
{
func
(
c
*
PStateObject
)
Script
()
string
{
if
c
.
object
!=
nil
{
if
c
.
object
!=
nil
{
return
strings
.
Join
(
ethchain
.
Disassemble
(
c
.
object
.
Script
()),
" "
)
return
strings
.
Join
(
ethchain
.
Disassemble
(
c
.
object
.
Script
()),
" "
)
...
...
ethutil/common.go
View file @
006ac772
...
@@ -7,6 +7,8 @@ import (
...
@@ -7,6 +7,8 @@ import (
// The different number of units
// The different number of units
var
(
var
(
Douglas
=
BigPow
(
10
,
42
)
Einstein
=
BigPow
(
10
,
21
)
Ether
=
BigPow
(
10
,
18
)
Ether
=
BigPow
(
10
,
18
)
Finney
=
BigPow
(
10
,
15
)
Finney
=
BigPow
(
10
,
15
)
Szabo
=
BigPow
(
10
,
12
)
Szabo
=
BigPow
(
10
,
12
)
...
@@ -21,6 +23,10 @@ var (
...
@@ -21,6 +23,10 @@ var (
// Returns a string representing a human readable format
// Returns a string representing a human readable format
func
CurrencyToString
(
num
*
big
.
Int
)
string
{
func
CurrencyToString
(
num
*
big
.
Int
)
string
{
switch
{
switch
{
case
num
.
Cmp
(
Douglas
)
>=
0
:
return
fmt
.
Sprintf
(
"%v Douglas"
,
new
(
big
.
Int
)
.
Div
(
num
,
Douglas
))
case
num
.
Cmp
(
Einstein
)
>=
0
:
return
fmt
.
Sprintf
(
"%v Einstein"
,
new
(
big
.
Int
)
.
Div
(
num
,
Einstein
))
case
num
.
Cmp
(
Ether
)
>=
0
:
case
num
.
Cmp
(
Ether
)
>=
0
:
return
fmt
.
Sprintf
(
"%v Ether"
,
new
(
big
.
Int
)
.
Div
(
num
,
Ether
))
return
fmt
.
Sprintf
(
"%v Ether"
,
new
(
big
.
Int
)
.
Div
(
num
,
Ether
))
case
num
.
Cmp
(
Finney
)
>=
0
:
case
num
.
Cmp
(
Finney
)
>=
0
:
...
...
ethutil/config.go
View file @
006ac772
...
@@ -75,7 +75,7 @@ func ReadConfig(base string, logTypes LoggerType, g *globalconf.GlobalConf, id s
...
@@ -75,7 +75,7 @@ func ReadConfig(base string, logTypes LoggerType, g *globalconf.GlobalConf, id s
if
Config
==
nil
{
if
Config
==
nil
{
path
:=
ApplicationFolder
(
base
)
path
:=
ApplicationFolder
(
base
)
Config
=
&
config
{
ExecPath
:
path
,
Debug
:
true
,
Ver
:
"0.5.0 RC1
1
"
}
Config
=
&
config
{
ExecPath
:
path
,
Debug
:
true
,
Ver
:
"0.5.0 RC1
2
"
}
Config
.
conf
=
g
Config
.
conf
=
g
Config
.
Identifier
=
id
Config
.
Identifier
=
id
Config
.
Log
=
NewLogger
(
logTypes
,
LogLevelDebug
)
Config
.
Log
=
NewLogger
(
logTypes
,
LogLevelDebug
)
...
...
peer.go
View file @
006ac772
...
@@ -130,6 +130,10 @@ type Peer struct {
...
@@ -130,6 +130,10 @@ type Peer struct {
blocksRequested
int
blocksRequested
int
version
string
version
string
// We use this to give some kind of pingtime to a node, not very accurate, could be improved.
pingTime
time
.
Duration
pingStartTime
time
.
Time
}
}
func
NewPeer
(
conn
net
.
Conn
,
ethereum
*
Ethereum
,
inbound
bool
)
*
Peer
{
func
NewPeer
(
conn
net
.
Conn
,
ethereum
*
Ethereum
,
inbound
bool
)
*
Peer
{
...
@@ -185,6 +189,9 @@ func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer {
...
@@ -185,6 +189,9 @@ func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer {
}
}
// Getters
// Getters
func
(
p
*
Peer
)
PingTime
()
string
{
return
p
.
pingTime
.
String
()
}
func
(
p
*
Peer
)
Inbound
()
bool
{
func
(
p
*
Peer
)
Inbound
()
bool
{
return
p
.
inbound
return
p
.
inbound
}
}
...
@@ -246,7 +253,7 @@ func (p *Peer) writeMessage(msg *ethwire.Msg) {
...
@@ -246,7 +253,7 @@ func (p *Peer) writeMessage(msg *ethwire.Msg) {
// Outbound message handler. Outbound messages are handled here
// Outbound message handler. Outbound messages are handled here
func
(
p
*
Peer
)
HandleOutbound
()
{
func
(
p
*
Peer
)
HandleOutbound
()
{
// The ping timer. Makes sure that every 2 minutes a ping is send to the peer
// The ping timer. Makes sure that every 2 minutes a ping is send to the peer
pingTimer
:=
time
.
NewTicker
(
2
*
time
.
Minute
)
pingTimer
:=
time
.
NewTicker
(
30
*
time
.
Second
)
serviceTimer
:=
time
.
NewTicker
(
5
*
time
.
Minute
)
serviceTimer
:=
time
.
NewTicker
(
5
*
time
.
Minute
)
out
:
out
:
...
@@ -255,12 +262,12 @@ out:
...
@@ -255,12 +262,12 @@ out:
// Main message queue. All outbound messages are processed through here
// Main message queue. All outbound messages are processed through here
case
msg
:=
<-
p
.
outputQueue
:
case
msg
:=
<-
p
.
outputQueue
:
p
.
writeMessage
(
msg
)
p
.
writeMessage
(
msg
)
p
.
lastSend
=
time
.
Now
()
p
.
lastSend
=
time
.
Now
()
// Ping timer sends a ping to the peer each 2 minutes
// Ping timer sends a ping to the peer each 2 minutes
case
<-
pingTimer
.
C
:
case
<-
pingTimer
.
C
:
p
.
writeMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgPingTy
,
""
))
p
.
writeMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgPingTy
,
""
))
p
.
pingStartTime
=
time
.
Now
()
// Service timer takes care of peer broadcasting, transaction
// Service timer takes care of peer broadcasting, transaction
// posting or block posting
// posting or block posting
...
@@ -290,8 +297,8 @@ clean:
...
@@ -290,8 +297,8 @@ clean:
// Inbound handler. Inbound messages are received here and passed to the appropriate methods
// Inbound handler. Inbound messages are received here and passed to the appropriate methods
func
(
p
*
Peer
)
HandleInbound
()
{
func
(
p
*
Peer
)
HandleInbound
()
{
for
atomic
.
LoadInt32
(
&
p
.
disconnect
)
==
0
{
for
atomic
.
LoadInt32
(
&
p
.
disconnect
)
==
0
{
// HMM?
// HMM?
time
.
Sleep
(
500
*
time
.
Millisecond
)
time
.
Sleep
(
500
*
time
.
Millisecond
)
// Wait for a message from the peer
// Wait for a message from the peer
...
@@ -319,6 +326,7 @@ func (p *Peer) HandleInbound() {
...
@@ -319,6 +326,7 @@ func (p *Peer) HandleInbound() {
// last pong so the peer handler knows this peer is still
// last pong so the peer handler knows this peer is still
// active.
// active.
p
.
lastPong
=
time
.
Now
()
.
Unix
()
p
.
lastPong
=
time
.
Now
()
.
Unix
()
p
.
pingTime
=
time
.
Now
()
.
Sub
(
p
.
pingStartTime
)
case
ethwire
.
MsgBlockTy
:
case
ethwire
.
MsgBlockTy
:
// Get all blocks and process them
// Get all blocks and process them
var
block
,
lastBlock
*
ethchain
.
Block
var
block
,
lastBlock
*
ethchain
.
Block
...
@@ -531,11 +539,15 @@ func (p *Peer) Start() {
...
@@ -531,11 +539,15 @@ func (p *Peer) Start() {
return
return
}
}
// Run the outbound handler in a new goroutine
go
p
.
HandleOutbound
()
go
p
.
HandleOutbound
()
// Run the inbound handler in a new goroutine
// Run the inbound handler in a new goroutine
go
p
.
HandleInbound
()
go
p
.
HandleInbound
()
// Wait a few seconds for startup and then ask for an initial ping
time
.
Sleep
(
2
*
time
.
Second
)
p
.
writeMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgPingTy
,
""
))
p
.
pingStartTime
=
time
.
Now
()
}
}
func
(
p
*
Peer
)
Stop
()
{
func
(
p
*
Peer
)
Stop
()
{
...
...
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