diff options
author | obscuren <geffobscura@gmail.com> | 2014-02-10 20:59:05 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-02-10 20:59:05 +0800 |
commit | 8ab6c53231deb92db1fe46bab263b1e2b12a8fb5 (patch) | |
tree | 2544c5d693bee35b0cab6e9fffdfb0a2033dccee | |
parent | 1d26ae2deaeb9e8995e923018db432eb64b764c5 (diff) | |
download | dexon-8ab6c53231deb92db1fe46bab263b1e2b12a8fb5.tar dexon-8ab6c53231deb92db1fe46bab263b1e2b12a8fb5.tar.gz dexon-8ab6c53231deb92db1fe46bab263b1e2b12a8fb5.tar.bz2 dexon-8ab6c53231deb92db1fe46bab263b1e2b12a8fb5.tar.lz dexon-8ab6c53231deb92db1fe46bab263b1e2b12a8fb5.tar.xz dexon-8ab6c53231deb92db1fe46bab263b1e2b12a8fb5.tar.zst dexon-8ab6c53231deb92db1fe46bab263b1e2b12a8fb5.zip |
Reversed back
-rw-r--r-- | ethereum.go | 4 | ||||
-rw-r--r-- | peer.go | 25 |
2 files changed, 15 insertions, 14 deletions
diff --git a/ethereum.go b/ethereum.go index cc3f1695b..565800361 100644 --- a/ethereum.go +++ b/ethereum.go @@ -58,8 +58,8 @@ type Ethereum struct { } func New(caps Caps, usePnp bool) (*Ethereum, error) { - db, err := ethdb.NewLDBDatabase() - //db, err := ethdb.NewMemDatabase() + //db, err := ethdb.NewLDBDatabase() + db, err := ethdb.NewMemDatabase() if err != nil { return nil, err } @@ -1,7 +1,7 @@ package eth import ( - "bytes" + _ "bytes" "fmt" "github.com/ethereum/ethchain-go" "github.com/ethereum/ethutil-go" @@ -139,8 +139,6 @@ func NewPeer(conn net.Conn, ethereum *Ethereum, inbound bool) *Peer { } func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer { - data, _ := ethutil.Config.Db.Get([]byte("KeyRing")) - pubkey := ethutil.NewValueFromBytes(data).Get(2).Bytes() p := &Peer{ outputQueue: make(chan *ethwire.Msg, outputBufferSize), @@ -150,7 +148,6 @@ func NewOutboundPeer(addr string, ethereum *Ethereum, caps Caps) *Peer { connected: 0, disconnect: 0, caps: caps, - pubkey: pubkey, } // Set up the connection in another goroutine so we don't block the main thread @@ -283,7 +280,6 @@ func (p *Peer) HandleInbound() { msg.Data = msg.Data var block *ethchain.Block for i := msg.Data.Length() - 1; i >= 0; i-- { - // FIXME block = ethchain.NewBlockFromRlpValue(ethutil.NewValue(msg.Data.Get(i).AsRaw())) err := p.ethereum.BlockManager.ProcessBlock(block) @@ -440,9 +436,12 @@ func (p *Peer) Stop() { } func (p *Peer) pushHandshake() error { + data, _ := ethutil.Config.Db.Get([]byte("KeyRing")) + pubkey := ethutil.NewValueFromBytes(data).Get(2).Bytes() + clientId := fmt.Sprintf("/Ethereum(G) v%s/%s", ethutil.Config.Ver, runtime.GOOS) msg := ethwire.NewMessage(ethwire.MsgHandshakeTy, []interface{}{ - uint32(3), uint32(0), clientId, byte(p.caps), p.port, p.pubkey, + uint32(3), uint32(0), clientId, byte(p.caps), p.port, pubkey, }) p.QueueMessage(msg) @@ -485,13 +484,15 @@ func (p *Peer) handleHandshake(msg *ethwire.Msg) { p.port = uint16(c.Get(4).AsUint()) // Self connect detection - data, _ := ethutil.Config.Db.Get([]byte("KeyRing")) - pubkey := ethutil.NewValueFromBytes(data).Get(2).Bytes() - if bytes.Compare(pubkey, p.pubkey) == 0 { - p.Stop() + /* + data, _ := ethutil.Config.Db.Get([]byte("KeyRing")) + pubkey := ethutil.NewValueFromBytes(data).Get(2).Bytes() + if bytes.Compare(pubkey, p.pubkey) == 0 { + p.Stop() - return - } + return + } + */ istr = "inbound" } else { |