From 1735ec0362e84455126d8c1bd380ecae436d1167 Mon Sep 17 00:00:00 2001 From: zelig Date: Tue, 15 Jul 2014 01:11:06 +0100 Subject: use ethreact.Event and ethreact.ReactorEngine --- ethereum.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'ethereum.go') diff --git a/ethereum.go b/ethereum.go index 2806dfd9d..c2d2f5241 100644 --- a/ethereum.go +++ b/ethereum.go @@ -6,6 +6,7 @@ import ( "github.com/ethereum/eth-go/ethchain" "github.com/ethereum/eth-go/ethcrypto" "github.com/ethereum/eth-go/ethlog" + "github.com/ethereum/eth-go/ethreact" "github.com/ethereum/eth-go/ethrpc" "github.com/ethereum/eth-go/ethutil" "github.com/ethereum/eth-go/ethwire" @@ -73,7 +74,7 @@ type Ethereum struct { listening bool - reactor *ethutil.ReactorEngine + reactor *ethreact.ReactorEngine RpcServer *ethrpc.JsonRpcServer @@ -108,7 +109,7 @@ func New(db ethutil.Database, clientIdentity ethwire.ClientIdentity, keyManager keyManager: keyManager, clientIdentity: clientIdentity, } - ethereum.reactor = ethutil.NewReactorEngine() + ethereum.reactor = ethreact.New() ethereum.txPool = ethchain.NewTxPool(ethereum) ethereum.blockChain = ethchain.NewBlockChain(ethereum) @@ -120,7 +121,7 @@ func New(db ethutil.Database, clientIdentity ethwire.ClientIdentity, keyManager return ethereum, nil } -func (s *Ethereum) Reactor() *ethutil.ReactorEngine { +func (s *Ethereum) Reactor() *ethreact.ReactorEngine { return s.reactor } @@ -352,6 +353,7 @@ func (s *Ethereum) ReapDeadPeerHandler() { // Start the ethereum func (s *Ethereum) Start(seed bool) { + s.reactor.Start() // Bind to addr and port ln, err := net.Listen("tcp", ":"+s.Port) if err != nil { @@ -462,6 +464,8 @@ func (s *Ethereum) Stop() { } s.txPool.Stop() s.stateManager.Stop() + s.reactor.Flush() + s.reactor.Stop() ethlogger.Infoln("Server stopped") close(s.shutdownChan) -- cgit v1.2.3 From 41bd38147c2e5968283facf641b2444c09f53d14 Mon Sep 17 00:00:00 2001 From: obscuren Date: Sat, 26 Jul 2014 11:24:44 +0200 Subject: Clean up and util methods --- ethereum.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'ethereum.go') diff --git a/ethereum.go b/ethereum.go index 18c1f8a23..799e9cb39 100644 --- a/ethereum.go +++ b/ethereum.go @@ -3,12 +3,6 @@ package eth import ( "container/list" "fmt" - "github.com/ethereum/eth-go/ethchain" - "github.com/ethereum/eth-go/ethcrypto" - "github.com/ethereum/eth-go/ethlog" - "github.com/ethereum/eth-go/ethrpc" - "github.com/ethereum/eth-go/ethutil" - "github.com/ethereum/eth-go/ethwire" "io/ioutil" "math/rand" "net" @@ -18,6 +12,13 @@ import ( "sync" "sync/atomic" "time" + + "github.com/ethereum/eth-go/ethchain" + "github.com/ethereum/eth-go/ethcrypto" + "github.com/ethereum/eth-go/ethlog" + "github.com/ethereum/eth-go/ethrpc" + "github.com/ethereum/eth-go/ethutil" + "github.com/ethereum/eth-go/ethwire" ) const seedTextFileUri string = "http://www.ethereum.org/servers.poc3.txt" -- cgit v1.2.3 From 74d701202583b49d29f5dbca00aec419bdee8e1d Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 29 Jul 2014 23:33:59 +0200 Subject: Added temp seed --- ethereum.go | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'ethereum.go') diff --git a/ethereum.go b/ethereum.go index 799e9cb39..395eba954 100644 --- a/ethereum.go +++ b/ethereum.go @@ -3,10 +3,8 @@ package eth import ( "container/list" "fmt" - "io/ioutil" "math/rand" "net" - "net/http" "strconv" "strings" "sync" @@ -21,7 +19,10 @@ import ( "github.com/ethereum/eth-go/ethwire" ) -const seedTextFileUri string = "http://www.ethereum.org/servers.poc3.txt" +const ( + seedTextFileUri string = "http://www.ethereum.org/servers.poc3.txt" + seedNodeAddress = "54.76.56.74:30303" +) var ethlogger = ethlog.NewLogger("SERV") @@ -421,22 +422,10 @@ func (s *Ethereum) Seed() { } // Connect to Peer list s.ProcessPeerList(peers) - } else { - // Fallback to servers.poc3.txt - resp, err := http.Get(seedTextFileUri) - if err != nil { - ethlogger.Warnln("Fetching seed failed:", err) - return - } - defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - ethlogger.Warnln("Reading seed failed:", err) - return - } - - s.ConnectToPeer(string(body)) } + + // XXX tmp + s.ConnectToPeer(seedNodeAddress) } func (s *Ethereum) peerHandler(listener net.Listener) { -- cgit v1.2.3 From a760ce05b948e89bc564af20599dcf95698ac0eb Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 11 Aug 2014 16:23:38 +0200 Subject: Updated chain for filtering --- ethereum.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'ethereum.go') diff --git a/ethereum.go b/ethereum.go index 69bb93cff..c1c4c2f2f 100644 --- a/ethereum.go +++ b/ethereum.go @@ -44,8 +44,8 @@ type Ethereum struct { // Channel for shutting down the ethereum shutdownChan chan bool quit chan bool + // DB interface - //db *ethdb.LDBDatabase db ethutil.Database // State manager for processing new blocks and managing the over all states stateManager *ethchain.StateManager @@ -149,6 +149,9 @@ func (s *Ethereum) StateManager() *ethchain.StateManager { func (s *Ethereum) TxPool() *ethchain.TxPool { return s.txPool } +func (self *Ethereum) Db() ethutil.Database { + return self.db +} func (s *Ethereum) ServerCaps() Caps { return s.serverCaps -- cgit v1.2.3 From eaa2e8900d1036e09b002c4e20fc6e4f9cd031bb Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 21 Aug 2014 14:47:58 +0200 Subject: PoC 6 networking code. * Added block pool for gathering blocks from the network (chunks) * Re wrote syncing --- ethereum.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'ethereum.go') diff --git a/ethereum.go b/ethereum.go index c1c4c2f2f..1e1891589 100644 --- a/ethereum.go +++ b/ethereum.go @@ -54,6 +54,8 @@ type Ethereum struct { txPool *ethchain.TxPool // The canonical chain blockChain *ethchain.BlockChain + // The block pool + blockPool *BlockPool // Peers (NYI) peers *list.List // Nonce @@ -116,6 +118,7 @@ func New(db ethutil.Database, clientIdentity ethwire.ClientIdentity, keyManager } ethereum.reactor = ethreact.New() + ethereum.blockPool = NewBlockPool(ethereum) ethereum.txPool = ethchain.NewTxPool(ethereum) ethereum.blockChain = ethchain.NewBlockChain(ethereum) ethereum.stateManager = ethchain.NewStateManager(ethereum) -- cgit v1.2.3