本文整理汇总了Golang中github.com/dedis/onet.TreeNodeInstance.OnDoneCallback方法的典型用法代码示例。如果您正苦于以下问题:Golang TreeNodeInstance.OnDoneCallback方法的具体用法?Golang TreeNodeInstance.OnDoneCallback怎么用?Golang TreeNodeInstance.OnDoneCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/dedis/onet.TreeNodeInstance
的用法示例。
在下文中一共展示了TreeNodeInstance.OnDoneCallback方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewBFTCoSiProtocol
// NewBFTCoSiProtocol returns a new bftcosi struct
func NewBFTCoSiProtocol(n *onet.TreeNodeInstance, verify VerificationFunction) (*ProtocolBFTCoSi, error) {
// initialize the bftcosi node/protocol-instance
bft := &ProtocolBFTCoSi{
TreeNodeInstance: n,
collectStructs: collectStructs{
prepare: cosi.NewCosi(n.Suite(), n.Private(), n.Roster().Publics()),
commit: cosi.NewCosi(n.Suite(), n.Private(), n.Roster().Publics()),
},
verifyChan: make(chan bool),
VerificationFunction: verify,
threshold: (len(n.Tree().List()) + 1) * 2 / 3,
Msg: make([]byte, 0),
Data: make([]byte, 0),
}
idx, _ := n.Roster().Search(bft.ServerIdentity().ID)
bft.index = idx
// Registering channels.
err := bft.RegisterChannels(&bft.announceChan,
&bft.challengePrepareChan, &bft.challengeCommitChan,
&bft.commitChan, &bft.responseChan)
if err != nil {
return nil, err
}
n.OnDoneCallback(bft.nodeDone)
return bft, nil
}
示例2: NewByzCoinProtocol
// NewByzCoinProtocol returns a new byzcoin struct
func NewByzCoinProtocol(n *onet.TreeNodeInstance) (*ByzCoin, error) {
// create the byzcoin
bz := new(ByzCoin)
bz.TreeNodeInstance = n
bz.suite = n.Suite()
bz.prepare = cosi.NewCosi(n.Suite(), n.Private())
bz.commit = cosi.NewCosi(n.Suite(), n.Private())
bz.verifyBlockChan = make(chan bool)
bz.doneProcessing = make(chan bool, 2)
bz.doneSigning = make(chan bool, 1)
bz.timeoutChan = make(chan uint64, 1)
//bz.endProto, _ = end.NewEndProtocol(n)
bz.aggregatedPublic = n.Roster().Aggregate
bz.threshold = int(math.Ceil(float64(len(bz.Tree().List())) / 3.0))
bz.viewChangeThreshold = int(math.Ceil(float64(len(bz.Tree().List())) * 2.0 / 3.0))
// register channels
if err := n.RegisterChannel(&bz.announceChan); err != nil {
return bz, err
}
if err := n.RegisterChannel(&bz.commitChan); err != nil {
return bz, err
}
if err := n.RegisterChannel(&bz.challengePrepareChan); err != nil {
return bz, err
}
if err := n.RegisterChannel(&bz.challengeCommitChan); err != nil {
return bz, err
}
if err := n.RegisterChannel(&bz.responseChan); err != nil {
return bz, err
}
if err := n.RegisterChannel(&bz.viewchangeChan); err != nil {
return bz, err
}
n.OnDoneCallback(bz.nodeDone)
go bz.listen()
return bz, nil
}