Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
313fe386
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
313fe386
编写于
3月 03, 2015
作者:
O
obscuren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed pow stuff
上级
22b132e2
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
28 addition
and
58 deletion
+28
-58
cmd/ethereum/main.go
cmd/ethereum/main.go
+1
-1
cmd/utils/cmd.go
cmd/utils/cmd.go
+0
-39
core/block_processor.go
core/block_processor.go
+2
-3
core/chain_makers.go
core/chain_makers.go
+3
-3
core/types/block.go
core/types/block.go
+4
-1
eth/backend.go
eth/backend.go
+5
-2
eth/protocol.go
eth/protocol.go
+1
-1
javascript/javascript_runtime.go
javascript/javascript_runtime.go
+5
-5
miner/miner.go
miner/miner.go
+6
-3
miner/worker.go
miner/worker.go
+1
-0
未找到文件。
cmd/ethereum/main.go
浏览文件 @
313fe386
...
...
@@ -114,7 +114,7 @@ func main() {
}
if
StartMining
{
utils
.
StartMining
(
ethereum
)
ethereum
.
Miner
()
.
Start
(
)
}
if
len
(
ImportChain
)
>
0
{
...
...
cmd/utils/cmd.go
浏览文件 @
313fe386
...
...
@@ -32,7 +32,6 @@ import (
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/rlp"
rpchttp
"github.com/ethereum/go-ethereum/rpc/http"
rpcws
"github.com/ethereum/go-ethereum/rpc/ws"
...
...
@@ -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
{
d
:=
ethutil
.
StringToByteFunc
(
data
,
func
(
s
string
)
(
ret
[]
byte
)
{
slice
:=
regexp
.
MustCompile
(
"
\\
n|
\\
s"
)
.
Split
(
s
,
1000000000
)
...
...
@@ -221,18 +194,6 @@ func FormatTransactionData(data string) []byte {
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
func
BlockDo
(
ethereum
*
eth
.
Ethereum
,
hash
[]
byte
)
error
{
block
:=
ethereum
.
ChainManager
()
.
GetBlock
(
hash
)
...
...
core/block_processor.go
浏览文件 @
313fe386
...
...
@@ -7,7 +7,6 @@ import (
"sync"
"time"
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event"
...
...
@@ -46,11 +45,11 @@ type BlockProcessor struct {
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
{
db
:
db
,
mem
:
make
(
map
[
string
]
*
big
.
Int
),
Pow
:
ethash
.
New
(
chainManager
)
,
Pow
:
pow
,
bc
:
chainManager
,
eventMux
:
eventMux
,
txpool
:
txpool
,
...
...
core/chain_makers.go
浏览文件 @
313fe386
...
...
@@ -2,12 +2,13 @@ package core
import
(
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/state"
"math/big"
)
// So we can generate blocks easily
...
...
@@ -119,8 +120,7 @@ func newChainManager(block *types.Block, eventMux *event.TypeMux, db ethutil.Dat
// block processor with fake pow
func
newBlockProcessor
(
db
ethutil
.
Database
,
txpool
*
TxPool
,
cman
*
ChainManager
,
eventMux
*
event
.
TypeMux
)
*
BlockProcessor
{
bman
:=
NewBlockProcessor
(
db
,
txpool
,
newChainManager
(
nil
,
eventMux
,
db
),
eventMux
)
bman
.
Pow
=
FakePow
{}
bman
:=
NewBlockProcessor
(
db
,
FakePow
{},
txpool
,
newChainManager
(
nil
,
eventMux
,
db
),
eventMux
)
return
bman
}
...
...
core/types/block.go
浏览文件 @
313fe386
...
...
@@ -268,7 +268,10 @@ func (self *Header) String() string {
Time: %v
Extra: %v
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
...
...
eth/backend.go
浏览文件 @
313fe386
...
...
@@ -7,6 +7,7 @@ import (
"path"
"strings"
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/blockpool"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
...
...
@@ -179,11 +180,13 @@ func New(config *Config) (*Ethereum, error) {
}
eth
.
chainManager
=
core
.
NewChainManager
(
db
,
eth
.
EventMux
())
pow
:=
ethash
.
New
(
eth
.
chainManager
)
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
.
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
insertChain
:=
eth
.
chainManager
.
InsertChain
...
...
eth/protocol.go
浏览文件 @
313fe386
...
...
@@ -14,7 +14,7 @@ import (
)
const
(
ProtocolVersion
=
5
4
ProtocolVersion
=
5
5
NetworkId
=
0
ProtocolLength
=
uint64
(
8
)
ProtocolMaxMsgSize
=
10
*
1024
*
1024
...
...
javascript/javascript_runtime.go
浏览文件 @
313fe386
...
...
@@ -7,7 +7,6 @@ import (
"path"
"path/filepath"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth"
...
...
@@ -157,13 +156,14 @@ func (self *JSRE) dump(call otto.FunctionCall) otto.Value {
}
func
(
self
*
JSRE
)
stopMining
(
call
otto
.
FunctionCall
)
otto
.
Value
{
v
,
_
:=
self
.
Vm
.
ToValue
(
utils
.
StopMining
(
self
.
ethereum
))
return
v
self
.
xeth
.
Miner
()
.
Stop
()
return
otto
.
TrueValue
()
}
func
(
self
*
JSRE
)
startMining
(
call
otto
.
FunctionCall
)
otto
.
Value
{
v
,
_
:=
self
.
Vm
.
ToValue
(
utils
.
StartMining
(
self
.
ethereum
)
)
return
v
self
.
xeth
.
Miner
()
.
Start
(
)
return
otto
.
TrueValue
()
}
func
(
self
*
JSRE
)
connect
(
call
otto
.
FunctionCall
)
otto
.
Value
{
...
...
miner/miner.go
浏览文件 @
313fe386
...
...
@@ -5,7 +5,7 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/pow
/ezp
"
"github.com/ethereum/go-ethereum/pow"
)
var
minerlogger
=
logger
.
NewLogger
(
"MINER"
)
...
...
@@ -18,16 +18,19 @@ type Miner struct {
Coinbase
[]
byte
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
{
Coinbase
:
coinbase
,
worker
:
newWorker
(
coinbase
,
eth
),
pow
:
pow
,
}
for
i
:=
0
;
i
<
minerThreads
;
i
++
{
miner
.
worker
.
register
(
NewCpuMiner
(
i
,
ezp
.
New
()
))
miner
.
worker
.
register
(
NewCpuMiner
(
i
,
miner
.
pow
))
}
return
miner
...
...
miner/worker.go
浏览文件 @
313fe386
...
...
@@ -146,6 +146,7 @@ func (self *worker) wait() {
self
.
current
.
block
.
Header
()
.
Nonce
=
work
.
Nonce
self
.
current
.
block
.
Header
()
.
MixDigest
=
work
.
MixDigest
self
.
current
.
block
.
Header
()
.
SeedHash
=
work
.
SeedHash
fmt
.
Println
(
self
.
current
.
block
)
if
err
:=
self
.
chain
.
InsertChain
(
types
.
Blocks
{
self
.
current
.
block
});
err
==
nil
{
self
.
mux
.
Post
(
core
.
NewMinedBlockEvent
{
self
.
current
.
block
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录