aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-03-04 23:54:36 +0800
committerFelix Lange <fjl@twurst.com>2015-03-04 23:54:36 +0800
commit215c763d53fc8e06e8c9807875eacaccf3ef45fa (patch)
tree3b6b9f6fc2448af8be2dc7e98a698b055dc0bb56
parent429828cd9205a8db0024652fd9da96cfbdaeae86 (diff)
downloaddexon-215c763d53fc8e06e8c9807875eacaccf3ef45fa.tar.gz
dexon-215c763d53fc8e06e8c9807875eacaccf3ef45fa.tar.zst
dexon-215c763d53fc8e06e8c9807875eacaccf3ef45fa.zip
eth, p2p: delete p2p.Blacklist
It is unused and untested right now. We can bring it back later if required.
-rw-r--r--eth/backend.go9
-rw-r--r--p2p/server.go59
2 files changed, 1 insertions, 67 deletions
diff --git a/eth/backend.go b/eth/backend.go
index 5cd7b308f..8b76e0ca3 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -108,11 +108,9 @@ func (cfg *Config) nodeKey() (*ecdsa.PrivateKey, error) {
type Ethereum struct {
// Channel for shutting down the ethereum
shutdownChan chan bool
- quit chan bool
// DB interface
- db ethutil.Database
- blacklist p2p.Blacklist
+ db ethutil.Database
//*** SERVICES ***
// State manager for processing new blocks and managing the over all states
@@ -170,10 +168,8 @@ func New(config *Config) (*Ethereum, error) {
eth := &Ethereum{
shutdownChan: make(chan bool),
- quit: make(chan bool),
db: db,
keyManager: keyManager,
- blacklist: p2p.NewBlacklist(),
eventMux: &event.TypeMux{},
logger: ethlogger,
}
@@ -206,7 +202,6 @@ func New(config *Config) (*Ethereum, error) {
Name: config.Name,
MaxPeers: config.MaxPeers,
Protocols: protocols,
- Blacklist: eth.blacklist,
NAT: config.NAT,
NoDial: !config.Dial,
BootstrapNodes: config.parseBootNodes(),
@@ -280,8 +275,6 @@ func (s *Ethereum) Stop() {
// Close the database
defer s.db.Close()
- close(s.quit)
-
s.txSub.Unsubscribe() // quits txBroadcastLoop
s.blockSub.Unsubscribe() // quits blockBroadcastLoop
diff --git a/p2p/server.go b/p2p/server.go
index 8f99bc33d..34000cb4c 100644
--- a/p2p/server.go
+++ b/p2p/server.go
@@ -66,10 +66,6 @@ type Server struct {
// each peer.
Protocols []Protocol
- // If Blacklist is set to a non-nil value, the given Blacklist
- // is used to verify peer connections.
- Blacklist Blacklist
-
// If ListenAddr is set to a non-nil address, the server
// will listen for incoming connections.
//
@@ -183,9 +179,6 @@ func (srv *Server) Start() (err error) {
if srv.setupFunc == nil {
srv.setupFunc = setupConn
}
- if srv.Blacklist == nil {
- srv.Blacklist = NewBlacklist()
- }
// node table
ntab, err := discover.ListenUDP(srv.PrivateKey, srv.ListenAddr, srv.NAT)
@@ -417,8 +410,6 @@ func (srv *Server) addPeer(id discover.NodeID, p *Peer) (bool, DiscReason) {
return false, DiscTooManyPeers
case srv.peers[id] != nil:
return false, DiscAlreadyConnected
- case srv.Blacklist.Exists(id[:]):
- return false, DiscUselessPeer
case id == srv.ntab.Self():
return false, DiscSelf
}
@@ -432,53 +423,3 @@ func (srv *Server) removePeer(p *Peer) {
srv.lock.Unlock()
srv.peerWG.Done()
}
-
-type Blacklist interface {
- Get([]byte) (bool, error)
- Put([]byte) error
- Delete([]byte) error
- Exists(pubkey []byte) (ok bool)
-}
-
-type BlacklistMap struct {
- blacklist map[string]bool
- lock sync.RWMutex
-}
-
-func NewBlacklist() *BlacklistMap {
- return &BlacklistMap{
- blacklist: make(map[string]bool),
- }
-}
-
-func (self *BlacklistMap) Get(pubkey []byte) (bool, error) {
- self.lock.RLock()
- defer self.lock.RUnlock()
- v, ok := self.blacklist[string(pubkey)]
- var err error
- if !ok {
- err = fmt.Errorf("not found")
- }
- return v, err
-}
-
-func (self *BlacklistMap) Exists(pubkey []byte) (ok bool) {
- self.lock.RLock()
- defer self.lock.RUnlock()
- _, ok = self.blacklist[string(pubkey)]
- return
-}
-
-func (self *BlacklistMap) Put(pubkey []byte) error {
- self.lock.Lock()
- defer self.lock.Unlock()
- self.blacklist[string(pubkey)] = true
- return nil
-}
-
-func (self *BlacklistMap) Delete(pubkey []byte) error {
- self.lock.Lock()
- defer self.lock.Unlock()
- delete(self.blacklist, string(pubkey))
- return nil
-}