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

24 lines
704 B

package signature
import (
"encoding/binary"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/woop-chain/woop/internal/params"
)
// ConstructCommitPayload returns the commit payload for consensus signatures.
func ConstructCommitPayload(
config *params.ChainConfig, 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 !config.IsStaking(epoch) {
return commitPayload
}
viewIDBytes := make([]byte, 8)
binary.LittleEndian.PutUint64(viewIDBytes, viewID)
return append(commitPayload, viewIDBytes...)
}