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
bb8afba2
Commit
bb8afba2
authored
Dec 28, 2013
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated tests
parent
5a7eae70
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
15 deletions
+27
-15
block.go
block.go
+17
-10
ethereum.go
ethereum.go
+10
-5
No files found.
block.go
View file @
bb8afba2
package
main
package
main
import
(
import
(
_
"fmt"
"fmt"
"time"
"time"
)
)
...
@@ -44,21 +44,28 @@ func (block *Block) MarshalRlp() []byte {
...
@@ -44,21 +44,28 @@ func (block *Block) MarshalRlp() []byte {
encTx
[
i
]
=
string
(
tx
.
MarshalRlp
())
encTx
[
i
]
=
string
(
tx
.
MarshalRlp
())
}
}
enc
:=
RlpEncode
(
[]
interface
{}{
header
:=
[]
interface
{}{
block
.
number
,
block
.
number
,
block
.
prevHash
,
//
block.prevHash,
// Sha of uncles
// Sha of uncles
block
.
coinbase
,
//
block.coinbase,
// root state
// root state
Sha256Bin
([]
byte
(
RlpEncode
(
encTx
))),
//
Sha256Bin([]byte(RlpEncode(encTx))),
block
.
difficulty
,
//
block.difficulty,
block
.
time
,
//
block.time,
block
.
nonce
,
//
block.nonce,
// extra?
// extra?
}
)
}
return
[]
byte
(
enc
)
return
Encode
([]
interface
{}{
header
,
encTx
}
)
}
}
func
(
block
*
Block
)
UnmarshalRlp
(
data
[]
byte
)
{
func
(
block
*
Block
)
UnmarshalRlp
(
data
[]
byte
)
{
fmt
.
Printf
(
"%q
\n
"
,
data
)
t
,
_
:=
Decode
(
data
,
0
)
if
slice
,
ok
:=
t
.
([]
interface
{});
ok
{
if
txes
,
ok
:=
slice
[
1
]
.
([]
interface
{});
ok
{
fmt
.
Println
(
txes
[
0
])
}
}
}
}
ethereum.go
View file @
bb8afba2
...
@@ -9,7 +9,7 @@ func main() {
...
@@ -9,7 +9,7 @@ func main() {
bm
:=
NewBlockManager
()
bm
:=
NewBlockManager
()
tx
:=
NewTransaction
(
0x0
,
20
,
[]
string
{
tx
:=
NewTransaction
(
"
\x00
"
,
20
,
[]
string
{
"SET 10 6"
,
"SET 10 6"
,
"LD 10 10"
,
"LD 10 10"
,
"LT 10 1 20"
,
"LT 10 1 20"
,
...
@@ -23,13 +23,18 @@ func main() {
...
@@ -23,13 +23,18 @@ func main() {
"SET 255 15"
,
"SET 255 15"
,
"JMP 255"
,
"JMP 255"
,
})
})
tx2
:=
NewTransaction
(
0x0
,
20
,
[]
string
{
"SET 10 6"
,
"LD 10 10"
})
txData
:=
tx
.
MarshalRlp
()
copyTx
:=
&
Transaction
{}
copyTx
.
UnmarshalRlp
(
txData
)
tx2
:=
NewTransaction
(
"
\x00
"
,
20
,
[]
string
{
"SET 10 6"
,
"LD 10 10"
})
blck
:=
NewBlock
([]
*
Transaction
{
tx2
,
tx
})
blck
:=
NewBlock
([]
*
Transaction
{
tx2
,
tx
})
bm
.
ProcessBlock
(
blck
)
bm
.
ProcessBlock
(
blck
)
//fmt.Printf("rlp encoded Tx %q\n", tx.MarshalRlp())
//t := blck.MarshalRlp()
fmt
.
Printf
(
"block enc %q
\n
"
,
blck
.
MarshalRlp
())
//blck.UnmarshalRlp(t)
fmt
.
Printf
(
"block hash %q
\n
"
,
blck
.
Hash
())
}
}
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