Skip to content

Commit c4ac8ac

Browse files
committed
neutrino: Added UnbanPeer method to ChainService
Signed-off-by: Ononiwu Maureen <[email protected]>
1 parent ea3402e commit c4ac8ac

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

neutrino.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,24 @@ func (s *ChainService) BanPeer(addr string, reason banman.Reason) error {
10811081
return s.banStore.BanIPNet(ipNet, reason, BanDuration)
10821082
}
10831083

1084+
// UnbanPeer connects and unbans a previously banned peer.
1085+
func (s *ChainService) UnbanPeer(addr string, parmanent bool) error {
1086+
log.Infof("UnBanning peer %v", addr)
1087+
1088+
ipNet, err := banman.ParseIPNet(addr, nil)
1089+
if err != nil {
1090+
return fmt.Errorf("unable to parse IP network for peer %v: %v",
1091+
addr, err)
1092+
}
1093+
1094+
err = s.banStore.UnbanIPNet(ipNet)
1095+
if err != nil {
1096+
return fmt.Errorf("unable to unban peer: %v", err)
1097+
}
1098+
1099+
return s.ConnectNode(addr, parmanent)
1100+
}
1101+
10841102
// IsBanned returns true if the peer is banned, and false otherwise.
10851103
func (s *ChainService) IsBanned(addr string) bool {
10861104
ipNet, err := banman.ParseIPNet(addr, nil)

0 commit comments

Comments
 (0)