Skip to content

Commit 6657d54

Browse files
committed
Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop
2 parents 0be6d34 + dbb2af6 commit 6657d54

7 files changed

Lines changed: 94 additions & 94 deletions

File tree

‎cmd/mist/bindings.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (self *Gui) DumpState(hash, path string) {
6767
i, _ := strconv.Atoi(hash[1:])
6868
block = self.eth.ChainManager().GetBlockByNumber(uint64(i))
6969
} else {
70-
block = self.eth.ChainManager().GetBlock(common.Hex2Bytes(hash))
70+
block = self.eth.ChainManager().GetBlock(common.HexToHash(hash))
7171
}
7272

7373
if block == nil {

‎cmd/mist/gui.go‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ import (
3131
"sort"
3232
"time"
3333

34+
"github.com/ethereum/go-ethereum/common"
3435
"github.com/ethereum/go-ethereum/core"
3536
"github.com/ethereum/go-ethereum/core/types"
3637
"github.com/ethereum/go-ethereum/eth"
3738
"github.com/ethereum/go-ethereum/ethdb"
38-
"github.com/ethereum/go-ethereum/common"
3939
"github.com/ethereum/go-ethereum/logger"
4040
"github.com/ethereum/go-ethereum/ui/qt/qwhisper"
4141
"github.com/ethereum/go-ethereum/xeth"
@@ -230,16 +230,17 @@ func (self *Gui) loadMergedMiningOptions() {
230230

231231
func (gui *Gui) insertTransaction(window string, tx *types.Transaction) {
232232
var inout string
233-
if gui.eth.AccountManager().HasAccount(tx.From()) {
233+
from, _ := tx.From()
234+
if gui.eth.AccountManager().HasAccount(common.Hex2Bytes(from.Hex())) {
234235
inout = "send"
235236
} else {
236237
inout = "recv"
237238
}
238239

239240
var (
240241
ptx = xeth.NewTx(tx)
241-
send = common.Bytes2Hex(tx.From())
242-
rec = common.Bytes2Hex(tx.To())
242+
send = from.Hex()
243+
rec = tx.To().Hex()
243244
)
244245
ptx.Sender = send
245246
ptx.Address = rec
@@ -263,7 +264,7 @@ func (gui *Gui) readPreviousTransactions() {
263264
}
264265

265266
func (gui *Gui) processBlock(block *types.Block, initial bool) {
266-
name := common.Bytes2Hex(block.Coinbase())
267+
name := block.Coinbase().Hex()
267268
b := xeth.NewBlock(block)
268269
b.Name = name
269270

‎cmd/mist/html_container.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import (
2929
"path"
3030
"path/filepath"
3131

32-
"github.com/ethereum/go-ethereum/core/types"
3332
"github.com/ethereum/go-ethereum/common"
33+
"github.com/ethereum/go-ethereum/core/types"
3434
"github.com/ethereum/go-ethereum/xeth"
3535
"github.com/howeyc/fsnotify"
3636
"github.com/obscuren/qml"
@@ -139,7 +139,7 @@ func (app *HtmlApplication) Window() *qml.Window {
139139
}
140140

141141
func (app *HtmlApplication) NewBlock(block *types.Block) {
142-
b := &xeth.Block{Number: int(block.NumberU64()), Hash: common.Bytes2Hex(block.Hash())}
142+
b := &xeth.Block{Number: int(block.NumberU64()), Hash: block.Hash().Hex()}
143143
app.webView.Call("onNewBlockCb", b)
144144
}
145145

‎cmd/mist/qml_container.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"runtime"
2626

2727
"github.com/ethereum/go-ethereum/core/types"
28-
"github.com/ethereum/go-ethereum/common"
2928
"github.com/ethereum/go-ethereum/xeth"
3029
"github.com/obscuren/qml"
3130
)
@@ -68,7 +67,7 @@ func (app *QmlApplication) NewWatcher(quitChan chan bool) {
6867

6968
// Events
7069
func (app *QmlApplication) NewBlock(block *types.Block) {
71-
pblock := &xeth.Block{Number: int(block.NumberU64()), Hash: common.Bytes2Hex(block.Hash())}
70+
pblock := &xeth.Block{Number: int(block.NumberU64()), Hash: block.Hash().Hex()}
7271
app.win.Call("onNewBlockCb", pblock)
7372
}
7473

‎miner/remote_agent.go‎

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package miner
2+
3+
import (
4+
"github.com/ethereum/ethash"
5+
"github.com/ethereum/go-ethereum/common"
6+
"github.com/ethereum/go-ethereum/core/types"
7+
)
8+
9+
type RemoteAgent struct {
10+
work *types.Block
11+
currentWork *types.Block
12+
13+
quit chan struct{}
14+
workCh chan *types.Block
15+
returnCh chan<- Work
16+
}
17+
18+
func NewRemoteAgent() *RemoteAgent {
19+
agent := &RemoteAgent{}
20+
go agent.run()
21+
22+
return agent
23+
}
24+
25+
func (a *RemoteAgent) Work() chan<- *types.Block {
26+
return a.workCh
27+
}
28+
29+
func (a *RemoteAgent) SetWorkCh(returnCh chan<- Work) {
30+
a.returnCh = returnCh
31+
}
32+
33+
func (a *RemoteAgent) Start() {
34+
a.quit = make(chan struct{})
35+
a.workCh = make(chan *types.Block, 1)
36+
}
37+
38+
func (a *RemoteAgent) Stop() {
39+
close(a.quit)
40+
close(a.workCh)
41+
}
42+
43+
func (a *RemoteAgent) GetHashRate() int64 { return 0 }
44+
45+
func (a *RemoteAgent) run() {
46+
out:
47+
for {
48+
select {
49+
case <-a.quit:
50+
break out
51+
case work := <-a.workCh:
52+
a.work = work
53+
}
54+
}
55+
}
56+
57+
func (a *RemoteAgent) GetWork() [3]string {
58+
var res [3]string
59+
60+
// XXX Wait here until work != nil ?
61+
if a.work != nil {
62+
res[0] = a.work.HashNoNonce().Hex()
63+
seedHash, _ := ethash.GetSeedHash(a.currentWork.NumberU64())
64+
res[1] = common.Bytes2Hex(seedHash)
65+
res[2] = common.Bytes2Hex(a.work.Difficulty().Bytes())
66+
}
67+
68+
return res
69+
}
70+
71+
func (a *RemoteAgent) SubmitWork(nonce uint64, mixDigest, seedHash common.Hash) bool {
72+
// Return true or false, but does not indicate if the PoW was correct
73+
74+
// Make sure the external miner was working on the right hash
75+
if a.currentWork != nil && a.work != nil && a.currentWork.Hash() == a.work.Hash() {
76+
a.returnCh <- Work{a.currentWork.Number().Uint64(), nonce, mixDigest.Bytes(), seedHash.Bytes()}
77+
return true
78+
}
79+
80+
return false
81+
}

‎xeth/miner_agent.go‎

Lines changed: 0 additions & 81 deletions
This file was deleted.

‎xeth/xeth.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ type XEth struct {
102102
// register map[string][]*interface{} // TODO improve return type
103103

104104
// Miner agent
105-
agent *Agent
105+
agent *miner.RemoteAgent
106106
}
107107

108108
// New creates an XEth that uses the given frontend.
@@ -120,7 +120,7 @@ func New(eth Backend, frontend Frontend) *XEth {
120120
frontend: frontend,
121121
logs: make(map[int]*logFilter),
122122
messages: make(map[int]*whisperFilter),
123-
agent: NewAgent(),
123+
agent: miner.NewRemoteAgent(),
124124
}
125125
eth.Miner().Register(xeth.agent)
126126

@@ -170,7 +170,7 @@ func (self *XEth) stop() {
170170
func (self *XEth) DefaultGas() *big.Int { return defaultGas }
171171
func (self *XEth) DefaultGasPrice() *big.Int { return defaultGasPrice }
172172

173-
func (self *XEth) RemoteMining() *Agent { return self.agent }
173+
func (self *XEth) RemoteMining() *miner.RemoteAgent { return self.agent }
174174

175175
func (self *XEth) AtStateNum(num int64) *XEth {
176176
chain := self.Backend().ChainManager()

0 commit comments

Comments
 (0)