Browse Source

Remove PEX/AddrBook

pull/169/head
Jae Kwon 9 years ago
parent
commit
67e74756f4
1 changed files with 0 additions and 14 deletions
  1. +0
    -14
      node/node.go

+ 0
- 14
node/node.go View File

@ -31,9 +31,7 @@ import _ "net/http/pprof"
type Node struct { type Node struct {
sw *p2p.Switch sw *p2p.Switch
evsw *events.EventSwitch evsw *events.EventSwitch
book *p2p.AddrBook
blockStore *bc.BlockStore blockStore *bc.BlockStore
pexReactor *p2p.PEXReactor
bcReactor *bc.BlockchainReactor bcReactor *bc.BlockchainReactor
mempoolReactor *mempl.MempoolReactor mempoolReactor *mempl.MempoolReactor
consensusState *consensus.ConsensusState consensusState *consensus.ConsensusState
@ -74,10 +72,6 @@ func NewNode() *Node {
Exit(Fmt("Failed to start switch: %v", err)) Exit(Fmt("Failed to start switch: %v", err))
} }
// Make PEXReactor
book := p2p.NewAddrBook(config.GetString("addrbook_file"))
pexReactor := p2p.NewPEXReactor(book)
// Make BlockchainReactor // Make BlockchainReactor
bcReactor := bc.NewBlockchainReactor(state.Copy(), proxyAppCtxConsensus, blockStore, config.GetBool("fast_sync")) bcReactor := bc.NewBlockchainReactor(state.Copy(), proxyAppCtxConsensus, blockStore, config.GetBool("fast_sync"))
@ -94,7 +88,6 @@ func NewNode() *Node {
// Make p2p network switch // Make p2p network switch
sw := p2p.NewSwitch() sw := p2p.NewSwitch()
sw.AddReactor("PEX", pexReactor)
sw.AddReactor("MEMPOOL", mempoolReactor) sw.AddReactor("MEMPOOL", mempoolReactor)
sw.AddReactor("BLOCKCHAIN", bcReactor) sw.AddReactor("BLOCKCHAIN", bcReactor)
sw.AddReactor("CONSENSUS", consensusReactor) sw.AddReactor("CONSENSUS", consensusReactor)
@ -114,9 +107,7 @@ func NewNode() *Node {
return &Node{ return &Node{
sw: sw, sw: sw,
evsw: eventSwitch, evsw: eventSwitch,
book: book,
blockStore: blockStore, blockStore: blockStore,
pexReactor: pexReactor,
bcReactor: bcReactor, bcReactor: bcReactor,
mempoolReactor: mempoolReactor, mempoolReactor: mempoolReactor,
consensusState: consensusState, consensusState: consensusState,
@ -129,7 +120,6 @@ func NewNode() *Node {
// Call Start() after adding the listeners. // Call Start() after adding the listeners.
func (n *Node) Start() error { func (n *Node) Start() error {
n.book.Start()
n.sw.SetNodeInfo(makeNodeInfo(n.sw, n.privKey)) n.sw.SetNodeInfo(makeNodeInfo(n.sw, n.privKey))
n.sw.SetNodePrivKey(n.privKey) n.sw.SetNodePrivKey(n.privKey)
_, err := n.sw.Start() _, err := n.sw.Start()
@ -140,7 +130,6 @@ func (n *Node) Stop() {
log.Notice("Stopping Node") log.Notice("Stopping Node")
// TODO: gracefully disconnect from peers. // TODO: gracefully disconnect from peers.
n.sw.Stop() n.sw.Stop()
n.book.Stop()
} }
// Add the event switch to reactors, mempool, etc. // Add the event switch to reactors, mempool, etc.
@ -156,7 +145,6 @@ func SetFireable(evsw *events.EventSwitch, eventables ...events.Eventable) {
func (n *Node) AddListener(l p2p.Listener) { func (n *Node) AddListener(l p2p.Listener) {
log.Notice(Fmt("Added %v", l)) log.Notice(Fmt("Added %v", l))
n.sw.AddListener(l) n.sw.AddListener(l)
n.book.AddOurAddress(l.ExternalAddress())
} }
// Dial a list of seeds in random order // Dial a list of seeds in random order
@ -179,11 +167,9 @@ func (n *Node) dialSeed(addr *p2p.NetAddress) {
peer, err := n.sw.DialPeerWithAddress(addr) peer, err := n.sw.DialPeerWithAddress(addr)
if err != nil { if err != nil {
log.Error("Error dialing seed", "error", err) log.Error("Error dialing seed", "error", err)
//n.book.MarkAttempt(addr)
return return
} else { } else {
log.Notice("Connected to seed", "peer", peer) log.Notice("Connected to seed", "peer", peer)
n.book.AddAddress(addr, addr)
} }
} }


Loading…
Cancel
Save