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
313fe386
Commit
313fe386
authored
Mar 03, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed pow stuff
parent
22b132e2
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
28 additions
and
58 deletions
+28
-58
main.go
cmd/ethereum/main.go
+1
-1
cmd.go
cmd/utils/cmd.go
+0
-39
block_processor.go
core/block_processor.go
+2
-3
chain_makers.go
core/chain_makers.go
+3
-3
block.go
core/types/block.go
+4
-1
backend.go
eth/backend.go
+5
-2
protocol.go
eth/protocol.go
+1
-1
javascript_runtime.go
javascript/javascript_runtime.go
+5
-5
miner.go
miner/miner.go
+6
-3
worker.go
miner/worker.go
+1
-0
No files found.
cmd/ethereum/main.go
View file @
313fe386
...
@@ -114,7 +114,7 @@ func main() {
...
@@ -114,7 +114,7 @@ func main() {
}
}
if
StartMining
{
if
StartMining
{
utils
.
StartMining
(
ethereum
)
ethereum
.
Miner
()
.
Start
(
)
}
}
if
len
(
ImportChain
)
>
0
{
if
len
(
ImportChain
)
>
0
{
...
...
cmd/utils/cmd.go
View file @
313fe386
...
@@ -32,7 +32,6 @@ import (
...
@@ -32,7 +32,6 @@ import (
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rlp"
rpchttp
"github.com/ethereum/go-ethereum/rpc/http"
rpchttp
"github.com/ethereum/go-ethereum/rpc/http"
rpcws
"github.com/ethereum/go-ethereum/rpc/ws"
rpcws
"github.com/ethereum/go-ethereum/rpc/ws"
...
@@ -182,32 +181,6 @@ func StartWebSockets(eth *eth.Ethereum, wsPort int) {
...
@@ -182,32 +181,6 @@ func StartWebSockets(eth *eth.Ethereum, wsPort int) {
}
}
}
}
var
gminer
*
miner
.
Miner
func
GetMiner
()
*
miner
.
Miner
{
return
gminer
}
func
StartMining
(
ethereum
*
eth
.
Ethereum
)
bool
{
if
!
ethereum
.
Mining
{
ethereum
.
Mining
=
true
addr
:=
ethereum
.
KeyManager
()
.
Address
()
go
func
()
{
clilogger
.
Infoln
(
"Start mining"
)
if
gminer
==
nil
{
gminer
=
miner
.
New
(
addr
,
ethereum
,
4
)
}
gminer
.
Start
()
}()
RegisterInterrupt
(
func
(
os
.
Signal
)
{
StopMining
(
ethereum
)
})
return
true
}
return
false
}
func
FormatTransactionData
(
data
string
)
[]
byte
{
func
FormatTransactionData
(
data
string
)
[]
byte
{
d
:=
ethutil
.
StringToByteFunc
(
data
,
func
(
s
string
)
(
ret
[]
byte
)
{
d
:=
ethutil
.
StringToByteFunc
(
data
,
func
(
s
string
)
(
ret
[]
byte
)
{
slice
:=
regexp
.
MustCompile
(
"
\\
n|
\\
s"
)
.
Split
(
s
,
1000000000
)
slice
:=
regexp
.
MustCompile
(
"
\\
n|
\\
s"
)
.
Split
(
s
,
1000000000
)
...
@@ -221,18 +194,6 @@ func FormatTransactionData(data string) []byte {
...
@@ -221,18 +194,6 @@ func FormatTransactionData(data string) []byte {
return
d
return
d
}
}
func
StopMining
(
ethereum
*
eth
.
Ethereum
)
bool
{
if
ethereum
.
Mining
&&
gminer
!=
nil
{
gminer
.
Stop
()
clilogger
.
Infoln
(
"Stopped mining"
)
ethereum
.
Mining
=
false
return
true
}
return
false
}
// Replay block
// Replay block
func
BlockDo
(
ethereum
*
eth
.
Ethereum
,
hash
[]
byte
)
error
{
func
BlockDo
(
ethereum
*
eth
.
Ethereum
,
hash
[]
byte
)
error
{
block
:=
ethereum
.
ChainManager
()
.
GetBlock
(
hash
)
block
:=
ethereum
.
ChainManager
()
.
GetBlock
(
hash
)
...
...
core/block_processor.go
View file @
313fe386
...
@@ -7,7 +7,6 @@ import (
...
@@ -7,7 +7,6 @@ import (
"sync"
"sync"
"time"
"time"
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/event"
...
@@ -46,11 +45,11 @@ type BlockProcessor struct {
...
@@ -46,11 +45,11 @@ type BlockProcessor struct {
eventMux
*
event
.
TypeMux
eventMux
*
event
.
TypeMux
}
}
func
NewBlockProcessor
(
db
ethutil
.
Database
,
txpool
*
TxPool
,
chainManager
*
ChainManager
,
eventMux
*
event
.
TypeMux
)
*
BlockProcessor
{
func
NewBlockProcessor
(
db
ethutil
.
Database
,
pow
pow
.
PoW
,
txpool
*
TxPool
,
chainManager
*
ChainManager
,
eventMux
*
event
.
TypeMux
)
*
BlockProcessor
{
sm
:=
&
BlockProcessor
{
sm
:=
&
BlockProcessor
{
db
:
db
,
db
:
db
,
mem
:
make
(
map
[
string
]
*
big
.
Int
),
mem
:
make
(
map
[
string
]
*
big
.
Int
),
Pow
:
ethash
.
New
(
chainManager
)
,
Pow
:
pow
,
bc
:
chainManager
,
bc
:
chainManager
,
eventMux
:
eventMux
,
eventMux
:
eventMux
,
txpool
:
txpool
,
txpool
:
txpool
,
...
...
core/chain_makers.go
View file @
313fe386
...
@@ -2,12 +2,13 @@ package core
...
@@ -2,12 +2,13 @@ package core
import
(
import
(
"fmt"
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/state"
"math/big"
)
)
// So we can generate blocks easily
// So we can generate blocks easily
...
@@ -119,8 +120,7 @@ func newChainManager(block *types.Block, eventMux *event.TypeMux, db ethutil.Dat
...
@@ -119,8 +120,7 @@ func newChainManager(block *types.Block, eventMux *event.TypeMux, db ethutil.Dat
// block processor with fake pow
// block processor with fake pow
func
newBlockProcessor
(
db
ethutil
.
Database
,
txpool
*
TxPool
,
cman
*
ChainManager
,
eventMux
*
event
.
TypeMux
)
*
BlockProcessor
{
func
newBlockProcessor
(
db
ethutil
.
Database
,
txpool
*
TxPool
,
cman
*
ChainManager
,
eventMux
*
event
.
TypeMux
)
*
BlockProcessor
{
bman
:=
NewBlockProcessor
(
db
,
txpool
,
newChainManager
(
nil
,
eventMux
,
db
),
eventMux
)
bman
:=
NewBlockProcessor
(
db
,
FakePow
{},
txpool
,
newChainManager
(
nil
,
eventMux
,
db
),
eventMux
)
bman
.
Pow
=
FakePow
{}
return
bman
return
bman
}
}
...
...
core/types/block.go
View file @
313fe386
...
@@ -268,7 +268,10 @@ func (self *Header) String() string {
...
@@ -268,7 +268,10 @@ func (self *Header) String() string {
Time: %v
Time: %v
Extra: %v
Extra: %v
Nonce: %x
Nonce: %x
`
,
self
.
ParentHash
,
self
.
UncleHash
,
self
.
Coinbase
,
self
.
Root
,
self
.
TxHash
,
self
.
ReceiptHash
,
self
.
Bloom
,
self
.
Difficulty
,
self
.
Number
,
self
.
GasLimit
,
self
.
GasUsed
,
self
.
Time
,
self
.
Extra
,
self
.
Nonce
)
MixDigest: %x
SeedHash: %x
`
,
self
.
ParentHash
,
self
.
UncleHash
,
self
.
Coinbase
,
self
.
Root
,
self
.
TxHash
,
self
.
ReceiptHash
,
self
.
Bloom
,
self
.
Difficulty
,
self
.
Number
,
self
.
GasLimit
,
self
.
GasUsed
,
self
.
Time
,
self
.
Extra
,
self
.
Nonce
,
self
.
MixDigest
,
self
.
SeedHash
)
}
}
type
Blocks
[]
*
Block
type
Blocks
[]
*
Block
...
...
eth/backend.go
View file @
313fe386
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"path"
"path"
"strings"
"strings"
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/blockpool"
"github.com/ethereum/go-ethereum/blockpool"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
...
@@ -179,11 +180,13 @@ func New(config *Config) (*Ethereum, error) {
...
@@ -179,11 +180,13 @@ func New(config *Config) (*Ethereum, error) {
}
}
eth
.
chainManager
=
core
.
NewChainManager
(
db
,
eth
.
EventMux
())
eth
.
chainManager
=
core
.
NewChainManager
(
db
,
eth
.
EventMux
())
pow
:=
ethash
.
New
(
eth
.
chainManager
)
eth
.
txPool
=
core
.
NewTxPool
(
eth
.
EventMux
())
eth
.
txPool
=
core
.
NewTxPool
(
eth
.
EventMux
())
eth
.
blockProcessor
=
core
.
NewBlockProcessor
(
db
,
eth
.
txPool
,
eth
.
chainManager
,
eth
.
EventMux
())
eth
.
blockProcessor
=
core
.
NewBlockProcessor
(
db
,
pow
,
eth
.
txPool
,
eth
.
chainManager
,
eth
.
EventMux
())
eth
.
chainManager
.
SetProcessor
(
eth
.
blockProcessor
)
eth
.
chainManager
.
SetProcessor
(
eth
.
blockProcessor
)
eth
.
whisper
=
whisper
.
New
()
eth
.
whisper
=
whisper
.
New
()
eth
.
miner
=
miner
.
New
(
keyManager
.
Address
(),
eth
,
config
.
MinerThreads
)
eth
.
miner
=
miner
.
New
(
keyManager
.
Address
(),
eth
,
pow
,
config
.
MinerThreads
)
hasBlock
:=
eth
.
chainManager
.
HasBlock
hasBlock
:=
eth
.
chainManager
.
HasBlock
insertChain
:=
eth
.
chainManager
.
InsertChain
insertChain
:=
eth
.
chainManager
.
InsertChain
...
...
eth/protocol.go
View file @
313fe386
...
@@ -14,7 +14,7 @@ import (
...
@@ -14,7 +14,7 @@ import (
)
)
const
(
const
(
ProtocolVersion
=
5
4
ProtocolVersion
=
5
5
NetworkId
=
0
NetworkId
=
0
ProtocolLength
=
uint64
(
8
)
ProtocolLength
=
uint64
(
8
)
ProtocolMaxMsgSize
=
10
*
1024
*
1024
ProtocolMaxMsgSize
=
10
*
1024
*
1024
...
...
javascript/javascript_runtime.go
View file @
313fe386
...
@@ -7,7 +7,6 @@ import (
...
@@ -7,7 +7,6 @@ import (
"path"
"path"
"path/filepath"
"path/filepath"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/eth"
...
@@ -157,13 +156,14 @@ func (self *JSRE) dump(call otto.FunctionCall) otto.Value {
...
@@ -157,13 +156,14 @@ func (self *JSRE) dump(call otto.FunctionCall) otto.Value {
}
}
func
(
self
*
JSRE
)
stopMining
(
call
otto
.
FunctionCall
)
otto
.
Value
{
func
(
self
*
JSRE
)
stopMining
(
call
otto
.
FunctionCall
)
otto
.
Value
{
v
,
_
:=
self
.
Vm
.
ToValue
(
utils
.
StopMining
(
self
.
ethereum
))
self
.
xeth
.
Miner
()
.
Stop
()
return
v
return
otto
.
TrueValue
()
}
}
func
(
self
*
JSRE
)
startMining
(
call
otto
.
FunctionCall
)
otto
.
Value
{
func
(
self
*
JSRE
)
startMining
(
call
otto
.
FunctionCall
)
otto
.
Value
{
v
,
_
:=
self
.
Vm
.
ToValue
(
utils
.
StartMining
(
self
.
ethereum
)
)
self
.
xeth
.
Miner
()
.
Start
(
)
return
v
return
otto
.
TrueValue
()
}
}
func
(
self
*
JSRE
)
connect
(
call
otto
.
FunctionCall
)
otto
.
Value
{
func
(
self
*
JSRE
)
connect
(
call
otto
.
FunctionCall
)
otto
.
Value
{
...
...
miner/miner.go
View file @
313fe386
...
@@ -5,7 +5,7 @@ import (
...
@@ -5,7 +5,7 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/pow
/ezp
"
"github.com/ethereum/go-ethereum/pow"
)
)
var
minerlogger
=
logger
.
NewLogger
(
"MINER"
)
var
minerlogger
=
logger
.
NewLogger
(
"MINER"
)
...
@@ -18,16 +18,19 @@ type Miner struct {
...
@@ -18,16 +18,19 @@ type Miner struct {
Coinbase
[]
byte
Coinbase
[]
byte
mining
bool
mining
bool
pow
pow
.
PoW
}
}
func
New
(
coinbase
[]
byte
,
eth
core
.
Backend
,
minerThreads
int
)
*
Miner
{
func
New
(
coinbase
[]
byte
,
eth
core
.
Backend
,
pow
pow
.
PoW
,
minerThreads
int
)
*
Miner
{
miner
:=
&
Miner
{
miner
:=
&
Miner
{
Coinbase
:
coinbase
,
Coinbase
:
coinbase
,
worker
:
newWorker
(
coinbase
,
eth
),
worker
:
newWorker
(
coinbase
,
eth
),
pow
:
pow
,
}
}
for
i
:=
0
;
i
<
minerThreads
;
i
++
{
for
i
:=
0
;
i
<
minerThreads
;
i
++
{
miner
.
worker
.
register
(
NewCpuMiner
(
i
,
ezp
.
New
()
))
miner
.
worker
.
register
(
NewCpuMiner
(
i
,
miner
.
pow
))
}
}
return
miner
return
miner
...
...
miner/worker.go
View file @
313fe386
...
@@ -146,6 +146,7 @@ func (self *worker) wait() {
...
@@ -146,6 +146,7 @@ func (self *worker) wait() {
self
.
current
.
block
.
Header
()
.
Nonce
=
work
.
Nonce
self
.
current
.
block
.
Header
()
.
Nonce
=
work
.
Nonce
self
.
current
.
block
.
Header
()
.
MixDigest
=
work
.
MixDigest
self
.
current
.
block
.
Header
()
.
MixDigest
=
work
.
MixDigest
self
.
current
.
block
.
Header
()
.
SeedHash
=
work
.
SeedHash
self
.
current
.
block
.
Header
()
.
SeedHash
=
work
.
SeedHash
fmt
.
Println
(
self
.
current
.
block
)
if
err
:=
self
.
chain
.
InsertChain
(
types
.
Blocks
{
self
.
current
.
block
});
err
==
nil
{
if
err
:=
self
.
chain
.
InsertChain
(
types
.
Blocks
{
self
.
current
.
block
});
err
==
nil
{
self
.
mux
.
Post
(
core
.
NewMinedBlockEvent
{
self
.
current
.
block
})
self
.
mux
.
Post
(
core
.
NewMinedBlockEvent
{
self
.
current
.
block
})
...
...
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