Skip to content

Commit

Permalink
smartcontract: add GetMajorityNodeCount()
Browse files Browse the repository at this point in the history
  • Loading branch information
fyrchik committed Mar 9, 2021
1 parent 717be43 commit 7a17672
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/smartcontract/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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
}

0 comments on commit 7a17672

Please sign in to comment.