improve DrandConfig dependency injection

This commit is contained in:
Yusef Napora
2020-06-23 16:01:10 -04:00
parent 99d3571772
commit b448de422e
7 changed files with 42 additions and 32 deletions
+11 -3
View File
@@ -108,9 +108,13 @@ func RetrievalResolver(l *discovery.Local) retrievalmarket.PeerResolver {
type RandomBeaconParams struct {
fx.In
DrandConfig *drand.DrandConfig `optional:"true"`
PubSub *pubsub.PubSub `optional:"true"`
PubSub *pubsub.PubSub `optional:"true"`
Cs *store.ChainStore
DrandConfig dtypes.DrandConfig
}
func BuiltinDrandConfig() dtypes.DrandConfig {
return build.DrandConfig
}
func RandomBeacon(p RandomBeaconParams, _ dtypes.AfterGenesisSet) (beacon.RandomBeacon, error) {
@@ -120,5 +124,9 @@ func RandomBeacon(p RandomBeaconParams, _ dtypes.AfterGenesisSet) (beacon.Random
}
//return beacon.NewMockBeacon(build.BlockDelay * time.Second)
return drand.NewDrandBeacon(gen.Timestamp, build.BlockDelay, p.PubSub, p.DrandConfig)
config := drand.DrandConfig{
Servers: p.DrandConfig.Servers,
ChainInfoJSON: p.DrandConfig.ChainInfoJSON,
}
return drand.NewDrandBeacon(gen.Timestamp, build.BlockDelay, p.PubSub, config)
}