The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
woop/drand/drand_leader_msg.go

29 lines
884 B

package drand
import (
"github.com/harmony-one/harmony/api/proto"
msg_pb "github.com/harmony-one/harmony/api/proto/message"
"github.com/harmony-one/harmony/internal/utils"
)
// Constructs the init message
func (dRand *DRand) constructInitMessage() []byte {
message := &msg_pb.Message{
ServiceType: msg_pb.ServiceType_DRAND,
Type: msg_pb.MessageType_DRAND_INIT,
Request: &msg_pb.Message_Drand{
Drand: &msg_pb.DrandRequest{},
},
}
drandMsg := message.GetDrand()
drandMsg.SenderPubkey = dRand.pubKey.Serialize()
drandMsg.BlockHash = dRand.blockHash[:]
drandMsg.ShardId = dRand.ShardID
// Don't need the payload in init message
marshaledMessage, err := dRand.signAndMarshalDRandMessage(message)
if err != nil {
utils.Logger().Error().Err(err).Msg("Failed to sign and marshal the init message")
}
return proto.ConstructDRandMessage(marshaledMessage)
}