smartcontract: add GetMajorityNodeCount()
This commit is contained in:
parent
717be43a5d
commit
7a176727ca
1 changed files with 7 additions and 1 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue