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/consensus/signature/signature.go

28 lines
787 B

package signature
import (
"encoding/binary"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/harmony-one/harmony/internal/params"
)
type signatureChainReader interface {
Config() *params.ChainConfig
}
// ConstructCommitPayload returns the commit payload for consensus signatures.
func ConstructCommitPayload(
chain signatureChainReader, epoch *big.Int, blockHash common.Hash, blockNum, viewID uint64,
) []byte {
blockNumBytes := make([]byte, 8)
binary.LittleEndian.PutUint64(blockNumBytes, blockNum)
commitPayload := append(blockNumBytes, blockHash.Bytes()...)
if !chain.Config().IsStaking(epoch) {
return commitPayload
}
viewIDBytes := make([]byte, 8)
binary.LittleEndian.PutUint64(viewIDBytes, viewID)
return append(commitPayload, viewIDBytes...)
}