aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eth/backend.go53
-rw-r--r--pow/ezp/pow.go12
2 files changed, 18 insertions, 47 deletions
diff --git a/eth/backend.go b/eth/backend.go
index 6235fc824..bdd5956a3 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -3,7 +3,6 @@ package eth
import (
"encoding/json"
"net"
- "path"
"sync"
"github.com/ethereum/go-ethereum/core"
@@ -32,7 +31,6 @@ type Ethereum struct {
db ethutil.Database
// State manager for processing new blocks and managing the over all states
blockManager *core.BlockManager
-
// The transaction pool. Transaction can be pushed on this pool
// for later including in the blocks
txPool *core.TxPool
@@ -43,22 +41,11 @@ type Ethereum struct {
// Event
eventMux *event.TypeMux
- // Nonce
- Nonce uint64
-
- ListenAddr string
-
blacklist p2p.Blacklist
server *p2p.Server
txSub event.Subscription
blockSub event.Subscription
- // Capabilities for outgoing peers
- // serverCaps Caps
- peersFile string
-
- Mining bool
-
RpcServer *rpc.JsonRpcServer
keyManager *crypto.KeyManager
@@ -71,6 +58,8 @@ type Ethereum struct {
filterMu sync.RWMutex
filterId int
filters map[int]*core.Filter
+
+ Mining bool
}
func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.KeyManager, nat p2p.NAT, port string, maxPeers int) (*Ethereum, error) {
@@ -78,28 +67,13 @@ func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.Ke
saveProtocolVersion(db)
ethutil.Config.Db = db
- // FIXME:
- blacklist := p2p.NewBlacklist()
- // Sorry Py person. I must blacklist. you perform badly
- blacklist.Put(ethutil.Hex2Bytes("64656330303561383532336435376331616537643864663236623336313863373537353163636634333530626263396330346237336262623931383064393031"))
-
- peersFile := path.Join(ethutil.Config.ExecPath, "known_peers.json")
-
- nonce, _ := ethutil.RandomUint64()
-
- listenAddr := ":" + port
-
eth := &Ethereum{
- shutdownChan: make(chan bool),
- quit: make(chan bool),
- db: db,
- Nonce: nonce,
- // serverCaps: caps,
- peersFile: peersFile,
- ListenAddr: listenAddr,
+ shutdownChan: make(chan bool),
+ quit: make(chan bool),
+ db: db,
keyManager: keyManager,
clientIdentity: identity,
- blacklist: blacklist,
+ blacklist: p2p.NewBlocklist(),
eventMux: &event.TypeMux{},
filters: make(map[int]*core.Filter),
}
@@ -111,9 +85,7 @@ func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.Ke
hasBlock := eth.chainManager.HasBlock
insertChain := eth.chainManager.InsertChain
- pow := ezp.New()
- verifyPoW := pow.Verify
- eth.blockPool = NewBlockPool(hasBlock, insertChain, verifyPoW)
+ eth.blockPool = NewBlockPool(hasBlock, insertChain, ezp.Verify)
// Start the tx pool
eth.txPool.Start()
@@ -125,7 +97,7 @@ func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.Ke
Identity: identity,
MaxPeers: maxPeers,
Protocols: protocols,
- ListenAddr: listenAddr,
+ ListenAddr: ":" + port,
Blacklist: blacklist,
NAT: nat,
}
@@ -171,11 +143,8 @@ func (s *Ethereum) IsMining() bool {
}
func (s *Ethereum) IsListening() bool {
- if s.ListenAddr == "" {
- return false
- } else {
- return true
- }
+ // XXX TODO
+ return false
}
func (s *Ethereum) PeerCount() int {
@@ -231,8 +200,6 @@ func (s *Ethereum) Stop() {
// Close the database
defer s.db.Close()
- //
- // WritePeers(s.peersFile, s.server.PeerAddresses())
close(s.quit)
s.txSub.Unsubscribe() // quits txBroadcastLoop
diff --git a/pow/ezp/pow.go b/pow/ezp/pow.go
index cdf89950f..b4f863cb6 100644
--- a/pow/ezp/pow.go
+++ b/pow/ezp/pow.go
@@ -59,7 +59,7 @@ func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) []byte {
}
sha := crypto.Sha3(big.NewInt(r.Int63()).Bytes())
- if pow.verify(hash, diff, sha) {
+ if verify(hash, diff, sha) {
return sha
}
}
@@ -72,7 +72,11 @@ func (pow *EasyPow) Search(block pow.Block, stop <-chan struct{}) []byte {
return nil
}
-func (pow *EasyPow) verify(hash []byte, diff *big.Int, nonce []byte) bool {
+func (pow *EasyPow) Verify(block pow.Block) bool {
+ return Verify(block)
+}
+
+func verify(hash []byte, diff *big.Int, nonce []byte) bool {
sha := sha3.NewKeccak256()
d := append(hash, nonce...)
@@ -84,6 +88,6 @@ func (pow *EasyPow) verify(hash []byte, diff *big.Int, nonce []byte) bool {
return res.Cmp(verification) <= 0
}
-func (pow *EasyPow) Verify(block pow.Block) bool {
- return pow.verify(block.HashNoNonce(), block.Diff(), block.N())
+func Verify(block pow.Block) bool {
+ return verify(block.HashNoNonce(), block.Diff(), block.N())
}