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
9581faf5
Commit
9581faf5
authored
Jan 03, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parsing for block and tx
parent
055407c8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
5 deletions
+8
-5
block.go
block.go
+1
-1
parsing.go
parsing.go
+6
-3
transaction.go
transaction.go
+1
-1
No files found.
block.go
View file @
9581faf5
...
...
@@ -73,7 +73,7 @@ func CreateBlock(root string, num int, prevHash string, base string, difficulty
contract
:=
NewContract
(
tx
.
value
,
[]
byte
(
""
))
block
.
state
.
Update
(
string
(
addr
),
string
(
contract
.
MarshalRlp
()))
for
i
,
val
:=
range
tx
.
data
{
contract
.
state
.
Update
(
string
(
Encode
(
i
)),
val
)
contract
.
state
.
Update
(
string
(
Encode
(
uint32
(
i
)
)),
val
)
}
block
.
UpdateContract
(
addr
,
contract
)
}
...
...
parsing.go
View file @
9581faf5
...
...
@@ -11,8 +11,11 @@ import (
// Op codes
var
OpCodes
=
map
[
string
]
string
{
"STOP"
:
"0"
,
"PSH"
:
"30"
,
// 0x30
/*
"PUSH"
:
"48"
,
// 0x30
"POP"
:
"49"
,
// 0x31
"LOAD"
:
"54"
,
// 0x36
/* OLD VM OPCODES
"ADD": "16", // 0x10
"SUB": "17", // 0x11
"MUL": "18", // 0x12
...
...
@@ -57,7 +60,7 @@ var OpCodes = map[string]string{
func
CompileInstr
(
s
string
)
(
string
,
error
)
{
tokens
:=
strings
.
Split
(
s
,
" "
)
if
OpCodes
[
tokens
[
0
]]
==
""
{
return
""
,
errors
.
New
(
fmt
.
Sprintf
(
"OP not found: %s"
,
tokens
[
0
]))
return
s
,
errors
.
New
(
fmt
.
Sprintf
(
"OP not found: %s"
,
tokens
[
0
]))
}
code
:=
OpCodes
[
tokens
[
0
]]
// Replace op codes with the proper numerical equivalent
...
...
transaction.go
View file @
9581faf5
...
...
@@ -57,7 +57,7 @@ func NewTransaction(to string, value uint32, data []string) *Transaction {
for
i
,
val
:=
range
data
{
instr
,
err
:=
CompileInstr
(
val
)
if
err
!=
nil
{
fmt
.
Printf
(
"compile error:%d %v"
,
i
+
1
,
err
)
fmt
.
Printf
(
"compile error:%d %v
\n
"
,
i
+
1
,
err
)
}
tx
.
data
[
i
]
=
instr
...
...
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