diff --git a/pkg/smartcontract/contract.go b/pkg/smartcontract/contract.go index e413c7c07..7168e83e4 100644 --- a/pkg/smartcontract/contract.go +++ b/pkg/smartcontract/contract.go @@ -49,7 +49,7 @@ func CreateDefaultMultiSigRedeemScript(publicKeys keys.PublicKeys) ([]byte, erro // using publicKeys length with m set to majority. func CreateMajorityMultiSigRedeemScript(publicKeys keys.PublicKeys) ([]byte, error) { n := len(publicKeys) - m := n - (n-1)/2 + m := GetMajorityHonestNodeCount(n) return CreateMultiSigRedeemScript(m, publicKeys) } @@ -58,3 +58,9 @@ func CreateMajorityMultiSigRedeemScript(publicKeys keys.PublicKeys) ([]byte, err func GetDefaultHonestNodeCount(n int) int { return n - (n-1)/3 } + +// GetMajorityHonestNodeCount returns minimum number of honest nodes +// required for majority-style agreement. +func GetMajorityHonestNodeCount(n int) int { + return n - (n-1)/2 +}