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
20671758
Commit
20671758
authored
Feb 01, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RLP Updates
parent
e28632b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
25 deletions
+21
-25
dev_console.go
dev_console.go
+5
-22
ethereum.go
ethereum.go
+16
-3
No files found.
dev_console.go
View file @
20671758
...
...
@@ -124,13 +124,13 @@ func (i *Console) ParseInput(input string) bool {
ethutil
.
BigPow
(
2
,
36
),
// diff
ethutil
.
Big
(
tokens
[
2
])))
// nonce
case
"decode"
:
value
:=
ethutil
.
NewRlp
Decoder
([]
byte
(
tokens
[
1
]))
value
:=
ethutil
.
NewRlp
ValueFromBytes
([]
byte
(
tokens
[
1
]))
fmt
.
Println
(
value
)
case
"getaddr"
:
encoded
,
_
:=
hex
.
DecodeString
(
tokens
[
1
])
d
:=
i
.
ethereum
.
BlockManager
.
BlockChain
()
.
CurrentBlock
.
State
()
.
Get
(
string
(
encoded
))
if
d
!=
""
{
decoder
:=
ethutil
.
NewRlp
Decoder
([]
byte
(
d
))
decoder
:=
ethutil
.
NewRlp
ValueFromBytes
([]
byte
(
d
))
fmt
.
Println
(
decoder
)
}
else
{
fmt
.
Println
(
"getaddr: address unknown"
)
...
...
@@ -139,27 +139,10 @@ func (i *Console) ParseInput(input string) bool {
i
.
ethereum
.
Broadcast
(
ethwire
.
MsgTalkTy
,
tokens
[
1
])
case
"addp"
:
i
.
ethereum
.
ConnectToPeer
(
tokens
[
1
])
case
"pcount"
:
fmt
.
Println
(
"peers:"
,
i
.
ethereum
.
Peers
()
.
Len
())
case
"encode"
:
fmt
.
Printf
(
"%q
\n
"
,
ethutil
.
Encode
(
tokens
[
1
]))
/*
case "newblk":
block := ethchain.CreateBlock(
i.ethereum.BlockManager.BlockChain().LastBlock.State().Root,
i.ethereum.BlockManager.LastBlockHash,
"123",
big.NewInt(1),
big.NewInt(1),
"",
i.ethereum.TxPool.Flush(),
)
err := i.ethereum.BlockManager.ProcessBlock(block)
if err != nil {
fmt.Println(err)
} else {
i.ethereum.Broadcast(ethwire.MsgBlockTy, block.RlpData())
}
//fmt.Println(ethutil.NewRlpValue(block.RlpData()).Get(0))
*/
case
"tx"
:
tx
:=
ethchain
.
NewTransaction
(
tokens
[
1
],
ethutil
.
Big
(
tokens
[
2
]),
[]
string
{
""
})
fmt
.
Printf
(
"%x
\n
"
,
tx
.
Hash
())
...
...
@@ -169,7 +152,7 @@ func (i *Console) ParseInput(input string) bool {
addr
,
_
:=
hex
.
DecodeString
(
tokens
[
1
])
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
(
addr
)
if
len
(
data
)
!=
0
{
decoder
:=
ethutil
.
NewRlp
Decoder
(
data
)
decoder
:=
ethutil
.
NewRlp
ValueFromBytes
(
data
)
fmt
.
Println
(
decoder
)
}
else
{
fmt
.
Println
(
"gettx: tx not found"
)
...
...
ethereum.go
View file @
20671758
package
main
import
(
"encoding/hex"
"flag"
"fmt"
"github.com/ethereum/eth-go"
...
...
@@ -46,6 +47,8 @@ func main() {
runtime
.
GOMAXPROCS
(
runtime
.
NumCPU
())
Init
()
//fmt.Printf("%x\n", ethutil.Encode([]interface{}{ethutil.BigPow(2, 36).Bytes()}))
ethchain
.
InitFees
()
ethutil
.
ReadConfig
()
...
...
@@ -89,17 +92,27 @@ func main() {
// Fake block mining. It broadcasts a new block every 5 seconds
go
func
()
{
pow
:=
&
ethchain
.
EasyPow
{}
addr
,
_
:=
hex
.
DecodeString
(
"82c3b0b72cf62f1a9ce97c64da8072efa28225d8"
)
for
{
time
.
Sleep
(
blockTime
*
time
.
Second
)
txs
:=
ethereum
.
TxPool
.
Flush
()
block
:=
ethereum
.
BlockManager
.
BlockChain
()
.
NewBlock
(
"82c3b0b72cf62f1a9ce97c64da8072efa28225d8"
,
txs
)
block
:=
ethereum
.
BlockManager
.
BlockChain
()
.
NewBlock
(
addr
,
txs
)
nonce
:=
pow
.
Search
(
block
)
block
.
Nonce
=
nonce
log
.
Println
(
"nonce found:"
,
nonce
)
err
:=
ethereum
.
BlockManager
.
ProcessBlockWithState
(
block
,
block
.
State
())
if
err
!=
nil
{
log
.
Println
(
err
)
}
else
{
//log.Println("nonce found:", nonce)
log
.
Println
(
"
\n
+++++++ MINED BLK +++++++
\n
"
,
block
.
String
())
}
//os.Exit(1)
/*
time.Sleep(blockTime * time.Second)
block := ethchain.CreateBlock(
...
...
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