feat: add config level blocklist support
This commit is contained in:
parent
42fa773b52
commit
438e76dfb8
|
@ -21,7 +21,8 @@ type P2PConfig struct {
|
|||
}
|
||||
|
||||
type PeersConfig struct {
|
||||
Initial []string `mapstructure:"initial"`
|
||||
Initial []string `mapstructure:"initial"`
|
||||
Blocklist []string `mapstructure:"blocklist"`
|
||||
}
|
||||
|
||||
type HTTPAPIConfig struct {
|
||||
|
|
|
@ -134,6 +134,16 @@ func (p *P2PServiceDefault) Init(ctx context.Context) error {
|
|||
p.bucket = bucket
|
||||
p.inited = true
|
||||
|
||||
for _, peer := range p.Config().P2P.Peers.Blocklist {
|
||||
_, err := encoding.DecodeNodeId(peer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
p.incomingPeerBlockList.Put(peer, true)
|
||||
p.outgoingPeerBlocklist.Put(peer, true)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
func (p *P2PServiceDefault) ConnectToNode(connectionUris []*url.URL, retry uint, fromPeer net.Peer) error {
|
||||
|
|
Loading…
Reference in New Issue