-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcs.go
More file actions
29 lines (24 loc) · 764 Bytes
/
cs.go
File metadata and controls
29 lines (24 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright IBM Corp. All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
package cs
import (
"math/big"
cs "github.com/SmartBFT-Go/randomcommittees/internal"
committee "github.com/SmartBFT-Go/randomcommittees/pkg"
)
func NewCommitteeSelection(logger committee.Logger) *cs.CommitteeSelection {
return &cs.CommitteeSelection{
SelectCommittee: func(config committee.Config, seed []byte) []int32 {
failureChance := big.NewRat(1, config.InverseFailureChance)
size := cs.CommitteeSize(int64(len(config.Nodes)), config.FailedTotalNodesPercentage, *failureChance)
return cs.SelectCommittee(config, seed, size)
},
Logger: logger,
}
}
func StateFromBytes(b []byte) (*cs.State, error) {
s := &cs.State{}
return s, s.Initialize(b)
}