good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
9581faf5
Commit
9581faf5
authored
Jan 3, 2014
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Parsing for block and tx
parent
055407c8
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
block.go
+1
-1
1 addition, 1 deletion
block.go
parsing.go
+6
-3
6 additions, 3 deletions
parsing.go
transaction.go
+1
-1
1 addition, 1 deletion
transaction.go
with
8 additions
and
5 deletions
block.go
+
1
−
1
View file @
9581faf5
...
@@ -73,7 +73,7 @@ func CreateBlock(root string, num int, prevHash string, base string, difficulty
...
@@ -73,7 +73,7 @@ func CreateBlock(root string, num int, prevHash string, base string, difficulty
contract
:=
NewContract
(
tx
.
value
,
[]
byte
(
""
))
contract
:=
NewContract
(
tx
.
value
,
[]
byte
(
""
))
block
.
state
.
Update
(
string
(
addr
),
string
(
contract
.
MarshalRlp
()))
block
.
state
.
Update
(
string
(
addr
),
string
(
contract
.
MarshalRlp
()))
for
i
,
val
:=
range
tx
.
data
{
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
)
block
.
UpdateContract
(
addr
,
contract
)
}
}
...
...
This diff is collapsed.
Click to expand it.
parsing.go
+
6
−
3
View file @
9581faf5
...
@@ -11,8 +11,11 @@ import (
...
@@ -11,8 +11,11 @@ import (
// Op codes
// Op codes
var
OpCodes
=
map
[
string
]
string
{
var
OpCodes
=
map
[
string
]
string
{
"STOP"
:
"0"
,
"STOP"
:
"0"
,
"PSH"
:
"30"
,
// 0x30
"PUSH"
:
"48"
,
// 0x30
/*
"POP"
:
"49"
,
// 0x31
"LOAD"
:
"54"
,
// 0x36
/* OLD VM OPCODES
"ADD": "16", // 0x10
"ADD": "16", // 0x10
"SUB": "17", // 0x11
"SUB": "17", // 0x11
"MUL": "18", // 0x12
"MUL": "18", // 0x12
...
@@ -57,7 +60,7 @@ var OpCodes = map[string]string{
...
@@ -57,7 +60,7 @@ var OpCodes = map[string]string{
func
CompileInstr
(
s
string
)
(
string
,
error
)
{
func
CompileInstr
(
s
string
)
(
string
,
error
)
{
tokens
:=
strings
.
Split
(
s
,
" "
)
tokens
:=
strings
.
Split
(
s
,
" "
)
if
OpCodes
[
tokens
[
0
]]
==
""
{
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
code
:=
OpCodes
[
tokens
[
0
]]
// Replace op codes with the proper numerical equivalent
...
...
This diff is collapsed.
Click to expand it.
transaction.go
+
1
−
1
View file @
9581faf5
...
@@ -57,7 +57,7 @@ func NewTransaction(to string, value uint32, data []string) *Transaction {
...
@@ -57,7 +57,7 @@ func NewTransaction(to string, value uint32, data []string) *Transaction {
for
i
,
val
:=
range
data
{
for
i
,
val
:=
range
data
{
instr
,
err
:=
CompileInstr
(
val
)
instr
,
err
:=
CompileInstr
(
val
)
if
err
!=
nil
{
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
tx
.
data
[
i
]
=
instr
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment