log.Info("peer is deleted")
break
}
- if ban := bkPeer.addBanScore(50, 0, "block process error"); ban {
+ if ban := bkPeer.addBanScore(20, 0, "block process error"); ban {
bk.sw.AddBannedPeer(swPeer)
bk.sw.StopPeerGracefully(swPeer)
}
if isOrphan, err := bk.chain.ValidateTx(tx); err != nil && isOrphan == false {
if bkPeer, ok := bk.peers.Peer(txsResponse.peerID); ok {
swPeer := bkPeer.getPeer()
- if ban := bkPeer.addBanScore(50, 0, "tx error"); ban {
+ if ban := bkPeer.addBanScore(10, 0, "tx error"); ban {
bk.sw.AddBannedPeer(swPeer)
bk.sw.StopPeerGracefully(swPeer)
}
return
}
swPeer := fPeer.getPeer()
- if ban := fPeer.addBanScore(50, 0, "block process error"); ban {
+ if ban := fPeer.addBanScore(20, 0, "block process error"); ban {
f.sw.AddBannedPeer(swPeer)
f.sw.StopPeerGracefully(swPeer)
}
reconnectInterval = 10 * time.Second
bannedPeerKey = "BannedPeer"
- defaultBanDuration = time.Hour * 24
+ defaultBanDuration = time.Hour * 1
)
var ErrConnectBannedPeer = errors.New("Connect banned peer")
return nil
}
-func (sw *Switch) DelBannedPeer(addr string) error {
- sw.mtx.Lock()
- defer sw.mtx.Unlock()
-
+func (sw *Switch) delBannedPeer(addr string) error {
delete(sw.bannedPeer, addr)
datajson, err := json.Marshal(sw.bannedPeer)
if err != nil {
}
func (sw *Switch) checkBannedPeer(peer string) error {
+ sw.mtx.Lock()
+ defer sw.mtx.Unlock()
+
if banEnd, ok := sw.bannedPeer[peer]; ok {
if time.Now().Before(banEnd) {
return ErrConnectBannedPeer
}
- sw.DelBannedPeer(peer)
+ sw.delBannedPeer(peer)
}
return nil
}