aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-15 18:37:23 +0800
committerobscuren <geffobscura@gmail.com>2014-12-15 18:38:09 +0800
commitf111fc060884d69fbe46066b9ccae4c9aa5da890 (patch)
tree8b64b989135084d21221df79f21909e1f38db08f /eth
parent1d959cb0ca38079f5d50ece7eb0a8405f423ad6e (diff)
downloaddexon-f111fc060884d69fbe46066b9ccae4c9aa5da890.tar
dexon-f111fc060884d69fbe46066b9ccae4c9aa5da890.tar.gz
dexon-f111fc060884d69fbe46066b9ccae4c9aa5da890.tar.bz2
dexon-f111fc060884d69fbe46066b9ccae4c9aa5da890.tar.lz
dexon-f111fc060884d69fbe46066b9ccae4c9aa5da890.tar.xz
dexon-f111fc060884d69fbe46066b9ccae4c9aa5da890.tar.zst
dexon-f111fc060884d69fbe46066b9ccae4c9aa5da890.zip
WIP
Diffstat (limited to 'eth')
-rw-r--r--eth/backend.go53
1 files changed, 10 insertions, 43 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