Skip to content

Commit

Permalink
neutrino: Added UnbanPeer method to ChainService
Browse files Browse the repository at this point in the history
Signed-off-by: Ononiwu Maureen <amaka013@gmail.com>
  • Loading branch information
Chinwendu20 committed May 10, 2024
1 parent eb5942f commit 0ab59ff
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions neutrino.go
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,24 @@ func (s *ChainService) BanPeer(addr string, reason banman.Reason) error {
return s.banStore.BanIPNet(ipNet, reason, BanDuration)
}

// UnbanPeer connects and unbans a previously banned peer.
func (s *ChainService) UnbanPeer(addr string, parmanent bool) error {
log.Infof("UnBanning peer %v", addr)

ipNet, err := banman.ParseIPNet(addr, nil)
if err != nil {
return fmt.Errorf("unable to parse IP network for peer %v: %v",
addr, err)
}

err = s.banStore.UnbanIPNet(ipNet)
if err != nil {
return fmt.Errorf("unable to unban peer: %v", err)
}

return s.ConnectNode(addr, parmanent)
}

// IsBanned returns true if the peer is banned, and false otherwise.
func (s *ChainService) IsBanned(addr string) bool {
ipNet, err := banman.ParseIPNet(addr, nil)
Expand Down

0 comments on commit 0ab59ff

Please sign in to comment.