Assign positive scores to drand bootstrappers
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
e91cc9cd08
commit
7762cd0a68
@ -34,3 +34,12 @@ func BuiltinBootstrap() ([]peer.AddrInfo, error) {
|
|||||||
})
|
})
|
||||||
return out, err
|
return out, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DrandBootstrap() ([]peer.AddrInfo, error) {
|
||||||
|
addrs := []string{
|
||||||
|
"/dnsaddr/pl-eu.testnet.drand.sh/",
|
||||||
|
"/dnsaddr/pl-us.testnet.drand.sh/",
|
||||||
|
"/dnsaddr/pl-sin.testnet.drand.sh/",
|
||||||
|
}
|
||||||
|
return addrutil.ParseAddresses(context.TODO(), addrs)
|
||||||
|
}
|
||||||
|
@ -218,6 +218,7 @@ func Online() Option {
|
|||||||
// TODO: Fix offline mode
|
// TODO: Fix offline mode
|
||||||
|
|
||||||
Override(new(dtypes.BootstrapPeers), modules.BuiltinBootstrap),
|
Override(new(dtypes.BootstrapPeers), modules.BuiltinBootstrap),
|
||||||
|
Override(new(dtypes.DrandBootstrap), modules.DrandBootstrap),
|
||||||
|
|
||||||
Override(HandleIncomingMessagesKey, modules.HandleIncomingMessages),
|
Override(HandleIncomingMessagesKey, modules.HandleIncomingMessages),
|
||||||
|
|
||||||
|
@ -89,3 +89,7 @@ func ConfigBootstrap(peers []string) func() (dtypes.BootstrapPeers, error) {
|
|||||||
func BuiltinBootstrap() (dtypes.BootstrapPeers, error) {
|
func BuiltinBootstrap() (dtypes.BootstrapPeers, error) {
|
||||||
return build.BuiltinBootstrap()
|
return build.BuiltinBootstrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DrandBootstrap() (dtypes.DrandBootstrap, error) {
|
||||||
|
return build.DrandBootstrap()
|
||||||
|
}
|
||||||
|
@ -3,5 +3,6 @@ package dtypes
|
|||||||
import "github.com/libp2p/go-libp2p-core/peer"
|
import "github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
|
||||||
type BootstrapPeers []peer.AddrInfo
|
type BootstrapPeers []peer.AddrInfo
|
||||||
|
type DrandBootstrap []peer.AddrInfo
|
||||||
|
|
||||||
type Bootstrapper bool
|
type Bootstrapper bool
|
||||||
|
@ -41,6 +41,7 @@ type GossipIn struct {
|
|||||||
Host host.Host
|
Host host.Host
|
||||||
Nn dtypes.NetworkName
|
Nn dtypes.NetworkName
|
||||||
Bp dtypes.BootstrapPeers
|
Bp dtypes.BootstrapPeers
|
||||||
|
Db dtypes.DrandBootstrap
|
||||||
Cfg *config.Pubsub
|
Cfg *config.Pubsub
|
||||||
Sk *dtypes.ScoreKeeper
|
Sk *dtypes.ScoreKeeper
|
||||||
}
|
}
|
||||||
@ -61,6 +62,11 @@ func GossipSub(in GossipIn) (service *pubsub.PubSub, err error) {
|
|||||||
for _, pi := range in.Bp {
|
for _, pi := range in.Bp {
|
||||||
bootstrappers[pi.ID] = struct{}{}
|
bootstrappers[pi.ID] = struct{}{}
|
||||||
}
|
}
|
||||||
|
drandBootstrappers := make(map[peer.ID]struct{})
|
||||||
|
for _, pi := range in.Db {
|
||||||
|
drandBootstrappers[pi.ID] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
isBootstrapNode := in.Cfg.Bootstrapper
|
isBootstrapNode := in.Cfg.Bootstrapper
|
||||||
drandTopic, err := getDrandTopic()
|
drandTopic, err := getDrandTopic()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -83,6 +89,11 @@ func GossipSub(in GossipIn) (service *pubsub.PubSub, err error) {
|
|||||||
return 2500
|
return 2500
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, ok = drandBootstrappers[p]
|
||||||
|
if ok && !isBootstrapNode {
|
||||||
|
return 1500
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: we want to plug the application specific score to the node itself in order
|
// TODO: we want to plug the application specific score to the node itself in order
|
||||||
// to provide feedback to the pubsub system based on observed behaviour
|
// to provide feedback to the pubsub system based on observed behaviour
|
||||||
return 0
|
return 0
|
||||||
|
Loading…
Reference in New Issue
Block a user