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
80261c80
Commit
80261c80
authored
Sep 19, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed deref ptr
parent
863785a5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
3 deletions
+26
-3
block_chain.go
ethchain/block_chain.go
+6
-2
rlp.go
ethutil/rlp.go
+4
-0
vm.go
ethvm/vm.go
+16
-1
No files found.
ethchain/block_chain.go
View file @
80261c80
...
...
@@ -164,6 +164,7 @@ func (bc *BlockChain) setLastBlock() {
bc
.
Add
(
bc
.
genesisBlock
)
fk
:=
append
([]
byte
(
"bloom"
),
bc
.
genesisBlock
.
Hash
()
...
)
bc
.
Ethereum
.
Db
()
.
Put
(
fk
,
make
([]
byte
,
255
))
bc
.
CurrentBlock
=
bc
.
genesisBlock
}
// Set the last know difficulty (might be 0x0 as initial value, Genesis)
...
...
@@ -201,10 +202,13 @@ func (bc *BlockChain) GetBlock(hash []byte) *Block {
func
(
self
*
BlockChain
)
GetBlockByNumber
(
num
uint64
)
*
Block
{
block
:=
self
.
CurrentBlock
for
;
block
.
Number
.
Uint64
()
!=
num
;
block
=
self
.
GetBlock
(
block
.
PrevHash
)
{
for
;
block
!=
nil
;
block
=
self
.
GetBlock
(
block
.
PrevHash
)
{
if
block
.
Number
.
Uint64
()
==
num
{
break
}
}
if
block
.
Number
.
Uint64
()
==
0
&&
num
!=
0
{
if
block
!=
nil
&&
block
.
Number
.
Uint64
()
==
0
&&
num
!=
0
{
return
nil
}
...
...
ethutil/rlp.go
View file @
80261c80
...
...
@@ -15,6 +15,10 @@ type RlpEncodeDecode interface {
RlpValue
()
[]
interface
{}
}
func
Rlp
(
encoder
RlpEncode
)
[]
byte
{
return
encoder
.
RlpEncode
()
}
type
RlpEncoder
struct
{
rlpData
[]
byte
}
...
...
ethvm/vm.go
View file @
80261c80
...
...
@@ -670,9 +670,13 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
stack
.
Pop
()
case
DUP1
,
DUP2
,
DUP3
,
DUP4
,
DUP5
,
DUP6
,
DUP7
,
DUP8
,
DUP9
,
DUP10
,
DUP11
,
DUP12
,
DUP13
,
DUP14
,
DUP15
,
DUP16
:
n
:=
int
(
op
-
DUP1
+
1
)
stack
.
Dupn
(
n
)
v
:=
stack
.
Dupn
(
n
)
self
.
Printf
(
" => [%d] 0x%x"
,
n
,
stack
.
Peek
()
.
Bytes
())
if
OpCode
(
closure
.
Get
(
new
(
big
.
Int
)
.
Add
(
pc
,
ethutil
.
Big1
))
.
Uint
())
==
POP
&&
OpCode
(
closure
.
Get
(
new
(
big
.
Int
)
.
Add
(
pc
,
big
.
NewInt
(
2
)))
.
Uint
())
==
POP
{
fmt
.
Println
(
toValue
(
v
))
}
case
SWAP1
,
SWAP2
,
SWAP3
,
SWAP4
,
SWAP5
,
SWAP6
,
SWAP7
,
SWAP8
,
SWAP9
,
SWAP10
,
SWAP11
,
SWAP12
,
SWAP13
,
SWAP14
,
SWAP15
,
SWAP16
:
n
:=
int
(
op
-
SWAP1
+
2
)
x
,
y
:=
stack
.
Swapn
(
n
)
...
...
@@ -1004,3 +1008,14 @@ func (self *Message) Exec(codeAddr []byte, caller ClosureRef) (ret []byte, err e
return
}
// Mainly used for print variables and passing to Print*
func
toValue
(
val
*
big
.
Int
)
interface
{}
{
// Let's assume a string on right padded zero's
b
:=
val
.
Bytes
()
if
b
[
0
]
!=
0
&&
b
[
len
(
b
)
-
1
]
==
0x0
&&
b
[
len
(
b
)
-
2
]
==
0x0
{
return
string
(
b
)
}
return
val
}
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