2020-10-28 17:35:56 +00:00
|
|
|
package node
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2020-11-14 00:03:47 +00:00
|
|
|
"github.com/Secured-Finance/dione/types"
|
|
|
|
|
2020-10-28 17:35:56 +00:00
|
|
|
"github.com/Secured-Finance/dione/beacon"
|
|
|
|
"github.com/Secured-Finance/dione/config"
|
|
|
|
"github.com/Secured-Finance/dione/drand"
|
|
|
|
)
|
|
|
|
|
2020-11-14 00:03:47 +00:00
|
|
|
// NewBeaconClient creates a new beacon chain client
|
|
|
|
func (n *Node) NewBeaconClient() (beacon.BeaconNetworks, error) {
|
|
|
|
networks := beacon.BeaconNetworks{}
|
2020-10-28 17:35:56 +00:00
|
|
|
bc, err := drand.NewDrandBeacon(config.ChainGenesis, config.TaskEpochInterval, n.PubSubRouter.Pubsub)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("creating drand beacon: %w", err)
|
|
|
|
}
|
2020-11-14 00:03:47 +00:00
|
|
|
networks = append(networks, beacon.BeaconNetwork{Start: types.DrandRound(config.ChainGenesis), Beacon: bc})
|
|
|
|
// NOTE: currently we use only one network
|
2020-10-28 17:35:56 +00:00
|
|
|
|
2020-11-14 00:03:47 +00:00
|
|
|
return networks, nil
|
2020-10-28 17:35:56 +00:00
|
|
|
}
|