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
818cbcbd
Commit
818cbcbd
authored
May 27, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release/poc5-rc10'
parents
b1463b2d
a4285331
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
120 additions
and
28 deletions
+120
-28
closure.go
ethchain/closure.go
+1
-1
state.go
ethchain/state.go
+5
-0
vm.go
ethchain/vm.go
+3
-1
types.go
ethpub/types.go
+31
-8
config.go
ethutil/config.go
+1
-1
encoding.go
ethutil/encoding.go
+15
-0
trie.go
ethutil/trie.go
+46
-0
trie_test.go
ethutil/trie_test.go
+10
-12
peer.go
peer.go
+8
-5
No files found.
ethchain/closure.go
View file @
818cbcbd
...
...
@@ -72,7 +72,7 @@ func (c *Closure) Address() []byte {
return
c
.
object
.
Address
()
}
type
DebugHook
func
(
step
int
,
op
OpCode
,
mem
*
Memory
,
stack
*
Stack
)
type
DebugHook
func
(
step
int
,
op
OpCode
,
mem
*
Memory
,
stack
*
Stack
,
stateObject
*
StateObject
)
bool
func
(
c
*
Closure
)
Call
(
vm
*
Vm
,
args
[]
byte
,
hook
DebugHook
)
([]
byte
,
error
)
{
c
.
Args
=
args
...
...
ethchain/state.go
View file @
818cbcbd
...
...
@@ -49,6 +49,11 @@ func (s *State) Purge() int {
return
s
.
trie
.
NewIterator
()
.
Purge
()
}
func
(
s
*
State
)
EachStorage
(
cb
ethutil
.
EachCallback
)
{
it
:=
s
.
trie
.
NewIterator
()
it
.
Each
(
cb
)
}
func
(
s
*
State
)
GetStateObject
(
addr
[]
byte
)
*
StateObject
{
data
:=
s
.
trie
.
Get
(
string
(
addr
))
if
data
==
""
{
...
...
ethchain/vm.go
View file @
818cbcbd
...
...
@@ -543,7 +543,9 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
pc
.
Add
(
pc
,
ethutil
.
Big1
)
if
hook
!=
nil
{
hook
(
step
-
1
,
op
,
mem
,
stack
)
if
!
hook
(
step
-
1
,
op
,
mem
,
stack
,
closure
.
Object
())
{
return
nil
,
nil
}
}
}
}
ethpub/types.go
View file @
818cbcbd
...
...
@@ -2,16 +2,20 @@ package ethpub
import
(
"encoding/hex"
"encoding/json"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
_
"log"
"strings"
)
// Block interface exposed to QML
type
PBlock
struct
{
ref
*
ethchain
.
Block
Number
int
`json:"number"`
Hash
string
`json:"hash"`
ref
*
ethchain
.
Block
Number
int
`json:"number"`
Hash
string
`json:"hash"`
Transactions
string
`json:"transactions"`
Time
int64
`json:"time"`
}
// Creates a new QML Block from a chain block
...
...
@@ -20,7 +24,17 @@ func NewPBlock(block *ethchain.Block) *PBlock {
return
nil
}
return
&
PBlock
{
ref
:
block
,
Number
:
int
(
block
.
Number
.
Uint64
()),
Hash
:
ethutil
.
Hex
(
block
.
Hash
())}
var
ptxs
[]
PTx
for
_
,
tx
:=
range
block
.
Transactions
()
{
ptxs
=
append
(
ptxs
,
*
NewPTx
(
tx
))
}
txJson
,
err
:=
json
.
Marshal
(
ptxs
)
if
err
!=
nil
{
return
nil
}
return
&
PBlock
{
ref
:
block
,
Number
:
int
(
block
.
Number
.
Uint64
()),
Hash
:
ethutil
.
Hex
(
block
.
Hash
()),
Transactions
:
string
(
txJson
),
Time
:
block
.
Time
}
}
func
(
self
*
PBlock
)
ToString
()
string
{
...
...
@@ -43,16 +57,25 @@ func (self *PBlock) GetTransaction(hash string) *PTx {
type
PTx
struct
{
ref
*
ethchain
.
Transaction
Value
,
Hash
,
Address
string
Contract
bool
Value
string
`json:"value"`
Gas
string
`json:"gas"`
GasPrice
string
`json:"gasPrice"`
Hash
string
`json:"hash"`
Address
string
`json:"address"`
Sender
string
`json:"sender"`
Data
string
`json:"data"`
Contract
bool
`json:"isContract"`
}
func
NewPTx
(
tx
*
ethchain
.
Transaction
)
*
PTx
{
hash
:=
hex
.
EncodeToString
(
tx
.
Hash
())
sender
:=
hex
.
EncodeToString
(
tx
.
Recipient
)
receiver
:=
hex
.
EncodeToString
(
tx
.
Recipient
)
sender
:=
hex
.
EncodeToString
(
tx
.
Sender
())
data
:=
strings
.
Join
(
ethchain
.
Disassemble
(
tx
.
Data
),
"
\n
"
)
isContract
:=
len
(
tx
.
Data
)
>
0
return
&
PTx
{
ref
:
tx
,
Hash
:
hash
,
Value
:
ethutil
.
CurrencyToString
(
tx
.
Value
),
Address
:
sender
,
Contract
:
isContract
}
return
&
PTx
{
ref
:
tx
,
Hash
:
hash
,
Value
:
ethutil
.
CurrencyToString
(
tx
.
Value
),
Address
:
receiver
,
Contract
:
isContract
,
Gas
:
tx
.
Gas
.
String
(),
GasPrice
:
tx
.
GasPrice
.
String
(),
Data
:
data
,
Sender
:
sender
}
}
func
(
self
*
PTx
)
ToString
()
string
{
...
...
ethutil/config.go
View file @
818cbcbd
...
...
@@ -43,7 +43,7 @@ func ReadConfig(base string, logTypes LoggerType, id string) *config {
}
}
Config
=
&
config
{
ExecPath
:
path
,
Debug
:
true
,
Ver
:
"0.5.0 RC
9
"
}
Config
=
&
config
{
ExecPath
:
path
,
Debug
:
true
,
Ver
:
"0.5.0 RC
10
"
}
Config
.
Identifier
=
id
Config
.
Log
=
NewLogger
(
logTypes
,
LogLevelDebug
)
Config
.
SetClientString
(
"/Ethereum(G)"
)
...
...
ethutil/encoding.go
View file @
818cbcbd
...
...
@@ -59,3 +59,18 @@ func CompactHexDecode(str string) []int {
return
hexSlice
}
func
DecodeCompact
(
key
[]
int
)
string
{
base
:=
"0123456789abcdef"
var
str
string
for
_
,
v
:=
range
key
{
if
v
<
16
{
str
+=
string
(
base
[
v
])
}
}
res
,
_
:=
hex
.
DecodeString
(
str
)
return
string
(
res
)
}
ethutil/trie.go
View file @
818cbcbd
...
...
@@ -442,6 +442,8 @@ type TrieIterator struct {
shas
[][]
byte
values
[]
string
lastNode
[]
byte
}
func
(
t
*
Trie
)
NewIterator
()
*
TrieIterator
{
...
...
@@ -513,3 +515,47 @@ func (it *TrieIterator) Key() string {
func
(
it
*
TrieIterator
)
Value
()
string
{
return
""
}
type
EachCallback
func
(
key
string
,
node
*
Value
)
func
(
it
*
TrieIterator
)
Each
(
cb
EachCallback
)
{
it
.
fetchNode
(
nil
,
NewValue
(
it
.
trie
.
Root
)
.
Bytes
(),
cb
)
}
func
(
it
*
TrieIterator
)
fetchNode
(
key
[]
int
,
node
[]
byte
,
cb
EachCallback
)
{
it
.
iterateNode
(
key
,
it
.
trie
.
cache
.
Get
(
node
),
cb
)
}
func
(
it
*
TrieIterator
)
iterateNode
(
key
[]
int
,
currentNode
*
Value
,
cb
EachCallback
)
{
if
currentNode
.
Len
()
==
2
{
k
:=
CompactDecode
(
currentNode
.
Get
(
0
)
.
Str
())
if
currentNode
.
Get
(
1
)
.
Str
()
==
""
{
it
.
iterateNode
(
key
,
currentNode
.
Get
(
1
),
cb
)
}
else
{
pk
:=
append
(
key
,
k
...
)
if
k
[
len
(
k
)
-
1
]
==
16
{
cb
(
DecodeCompact
(
pk
),
currentNode
.
Get
(
1
))
}
else
{
it
.
fetchNode
(
pk
,
currentNode
.
Get
(
1
)
.
Bytes
(),
cb
)
}
}
}
else
{
for
i
:=
0
;
i
<
currentNode
.
Len
();
i
++
{
pk
:=
append
(
key
,
i
)
if
i
==
16
&&
currentNode
.
Get
(
i
)
.
Len
()
!=
0
{
cb
(
DecodeCompact
(
pk
),
currentNode
.
Get
(
i
))
}
else
{
if
currentNode
.
Get
(
i
)
.
Str
()
==
""
{
it
.
iterateNode
(
pk
,
currentNode
.
Get
(
i
),
cb
)
}
else
{
val
:=
currentNode
.
Get
(
i
)
.
Str
()
if
val
!=
""
{
it
.
fetchNode
(
pk
,
[]
byte
(
val
),
cb
)
}
}
}
}
}
}
ethutil/trie_test.go
View file @
818cbcbd
...
...
@@ -154,7 +154,7 @@ func TestTrieDeleteWithValue(t *testing.T) {
}
func
TestTrie
Iterator
(
t
*
testing
.
T
)
{
func
TestTrie
Purge
(
t
*
testing
.
T
)
{
_
,
trie
:=
New
()
trie
.
Update
(
"c"
,
LONG_WORD
)
trie
.
Update
(
"ca"
,
LONG_WORD
)
...
...
@@ -171,16 +171,14 @@ func TestTrieIterator(t *testing.T) {
}
}
func
Test
Hashes
(
t
*
testing
.
T
)
{
func
Test
TrieIt
(
t
*
testing
.
T
)
{
_
,
trie
:=
New
()
trie
.
Update
(
"cat"
,
"dog"
)
trie
.
Update
(
"ca"
,
"dude"
)
trie
.
Update
(
"doge"
,
"1234567890abcdefghijklmnopqrstuvwxxzABCEFGHIJKLMNOPQRSTUVWXYZ"
)
trie
.
Update
(
"dog"
,
"test"
)
trie
.
Update
(
"test"
,
"1234567890abcdefghijklmnopqrstuvwxxzABCEFGHIJKLMNOPQRSTUVWXYZ"
)
fmt
.
Printf
(
"%x
\n
"
,
trie
.
Root
)
trie
.
Delete
(
"dog"
)
fmt
.
Printf
(
"%x
\n
"
,
trie
.
Root
)
trie
.
Delete
(
"test"
)
fmt
.
Printf
(
"%x
\n
"
,
trie
.
Root
)
trie
.
Update
(
"c"
,
LONG_WORD
)
trie
.
Update
(
"ca"
,
LONG_WORD
)
trie
.
Update
(
"cat"
,
LONG_WORD
)
it
:=
trie
.
NewIterator
()
it
.
Each
(
func
(
key
string
,
node
*
Value
)
{
fmt
.
Println
(
key
,
":"
,
node
.
Str
())
})
}
peer.go
View file @
818cbcbd
...
...
@@ -531,13 +531,16 @@ func (p *Peer) Stop() {
}
func
(
p
*
Peer
)
pushHandshake
()
error
{
pubkey
:=
ethutil
.
GetKeyRing
()
.
Get
(
0
)
.
PublicKey
keyRing
:=
ethutil
.
GetKeyRing
()
.
Get
(
0
)
if
keyRing
!=
nil
{
pubkey
:=
keyRing
.
PublicKey
msg
:=
ethwire
.
NewMessage
(
ethwire
.
MsgHandshakeTy
,
[]
interface
{}{
uint32
(
ProtocolVersion
),
uint32
(
0
),
p
.
Version
,
byte
(
p
.
caps
),
p
.
port
,
pubkey
[
1
:
],
})
msg
:=
ethwire
.
NewMessage
(
ethwire
.
MsgHandshakeTy
,
[]
interface
{}{
uint32
(
ProtocolVersion
),
uint32
(
0
),
p
.
Version
,
byte
(
p
.
caps
),
p
.
port
,
pubkey
[
1
:
],
})
p
.
QueueMessage
(
msg
)
p
.
QueueMessage
(
msg
)
}
return
nil
}
...
...
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