本文整理汇总了Golang中github.com/dedis/onet/log.Error函数的典型用法代码示例。如果您正苦于以下问题:Golang Error函数的具体用法?Golang Error怎么用?Golang Error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: propagateSkipBlockHandler
// propagateSkipBlock saves a new skipblock to the identity
func (s *Service) propagateSkipBlockHandler(msg network.Body) {
log.Lvlf4("Got msg %+v %v", msg, reflect.TypeOf(msg).String())
usb, ok := msg.(*UpdateSkipBlock)
if !ok {
log.Error("Wrong message-type")
return
}
sid := s.getIdentityStorage(usb.ID)
if sid == nil {
log.Error("Didn't find entity in", s)
return
}
sid.Lock()
defer sid.Unlock()
skipblock := msg.(*UpdateSkipBlock).Latest
_, msgLatest, err := network.UnmarshalRegistered(skipblock.Data)
if err != nil {
log.Error(err)
return
}
al, ok := msgLatest.(*Config)
if !ok {
log.Error(err)
return
}
sid.Data = skipblock
sid.Latest = al
sid.Proposed = nil
}
开发者ID:dedis,项目名称:cothority,代码行数:30,代码来源:service.go
示例2: Run
// Run starts the simulation on the simulation-side
func (e *Simulation) Run(config *onet.SimulationConfig) error {
msg := []byte(e.Message)
size := config.Tree.Size()
log.Lvl2("Size is:", size, "rounds:", e.Rounds)
for round := 0; round < e.Rounds; round++ {
log.Lvl1("Starting round", round, "with message", string(msg))
round := monitor.NewTimeMeasure("round")
p, err := config.Overlay.CreateProtocolOnet("NaiveTree", config.Tree)
if err != nil {
log.Error("Quitting the simulation....", err)
return err
}
pi := p.(*Protocol)
pi.Message = msg
pi.verifySignature = e.Checking
done := make(chan bool)
pi.TreeNodeInstance.OnDoneCallback(func() bool {
done <- true
return true
})
err = pi.Start()
if err != nil {
log.Error("Quitting the simulation....", err)
return err
}
<-done
round.Record()
}
return nil
}
开发者ID:dedis,项目名称:cothority,代码行数:33,代码来源:simulation.go
示例3: handleResponsePrepare
// If 'r' is nil, it will starts the response process.
func (bft *ProtocolBFTCoSi) handleResponsePrepare(r *Response) error {
if r != nil {
// check if we have enough responses
bft.tmpMutex.Lock()
bft.tempPrepareResponse = append(bft.tempPrepareResponse, r.Response)
bft.tempExceptions = append(bft.tempExceptions, r.Exceptions...)
if len(bft.tempPrepareResponse) < len(bft.Children()) {
bft.tmpMutex.Unlock()
return nil
}
bft.tmpMutex.Unlock()
}
// wait for verification
bzrReturn, ok := bft.waitResponseVerification()
// append response
if !ok {
log.Lvl2(bft.Roster(), "Refused to sign")
}
// Return if we're not root
if !bft.IsRoot() {
return bft.SendTo(bft.Parent(), bzrReturn)
}
// Since cosi does not support exceptions yet, we have to remove
// the responses that are not supposed to be there,i.e. exceptions.
cosiSig := bft.prepare.Signature()
correctResponseBuff, err := bzrReturn.Response.MarshalBinary()
if err != nil {
return err
}
// replace the old one with the corrected one
copy(cosiSig[32:64], correctResponseBuff)
bft.prepareSignature = cosiSig
// Verify the signature is correct
data := sha512.Sum512(bft.Msg)
sig := &BFTSignature{
Msg: data[:],
Sig: cosiSig,
Exceptions: bft.tempExceptions,
}
aggCommit := bft.Suite().Point().Null()
for _, c := range bft.tempPrepareCommit {
aggCommit.Add(aggCommit, c)
}
if err := sig.Verify(bft.Suite(), bft.Roster().Publics()); err != nil {
log.Error(bft.Name(), "Verification of the signature failed:", err)
bft.signRefusal = true
}
log.Lvl3(bft.Name(), "Verification of signature successful")
// Start the challenge of the 'commit'-round
if err := bft.startChallenge(RoundCommit); err != nil {
log.Error(bft.Name(), err)
return err
}
return nil
}
开发者ID:dedis,项目名称:cothority,代码行数:60,代码来源:bftcosi.go
示例4: finaliseSecret
func (jv *JVSS) finaliseSecret(sid SID) error {
secret, err := jv.secrets.secret(sid)
if err != nil {
return err
}
log.Lvlf4("Node %d: %s deals %d/%d", jv.Index(), sid, len(secret.deals),
len(jv.List()))
if len(secret.deals) == jv.info.T {
for _, deal := range secret.deals {
if _, err := secret.receiver.AddDeal(jv.Index(), deal); err != nil {
log.Error(jv.Index(), err)
return err
}
}
sec, err := secret.receiver.ProduceSharedSecret()
if err != nil {
return err
}
secret.secret = sec
isShortTermSecret := strings.HasPrefix(string(sid), string(STSS))
if isShortTermSecret {
secret.nShortConfirmsMtx.Lock()
defer secret.nShortConfirmsMtx.Unlock()
secret.numShortConfs++
} else {
secret.nLongConfirmsMtx.Lock()
defer secret.nLongConfirmsMtx.Unlock()
secret.numLongtermConfs++
}
log.Lvlf4("Node %d: %v created", jv.Index(), sid)
// Initialise Schnorr struct for long-term shared secret if not done so before
if sid.IsLTSS() && !jv.ltssInit {
jv.ltssInit = true
jv.schnorr.Init(jv.keyPair.Suite, jv.info, secret.secret)
log.Lvlf4("Node %d: %v Schnorr struct initialised",
jv.Index(), sid)
}
// Broadcast that we have finished setting up our shared secret
msg := &SecConfMsg{
Src: jv.Index(),
SID: sid,
}
if err := jv.Broadcast(msg); err != nil {
log.Error(err)
return err
}
}
return nil
}
开发者ID:dedis,项目名称:cothority,代码行数:55,代码来源:jvss.go
示例5: save
// saves the actual identity
func (s *Service) save() {
log.Lvl3("Saving service")
b, err := network.MarshalRegisteredType(s.StorageMap)
if err != nil {
log.Error("Couldn't marshal service:", err)
} else {
err = ioutil.WriteFile(s.path+"/identity.bin", b, 0660)
if err != nil {
log.Error("Couldn't save file:", err)
}
}
}
开发者ID:dedis,项目名称:cothority,代码行数:13,代码来源:service.go
示例6: PropagateSkipBlock
// PropagateSkipBlock will save a new SkipBlock
func (s *Service) PropagateSkipBlock(msg network.Body) {
sb, ok := msg.(*SkipBlock)
if !ok {
log.Error("Couldn't convert to SkipBlock")
return
}
if err := sb.VerifySignatures(); err != nil {
log.Error(err)
return
}
s.storeSkipBlock(sb)
log.Lvlf3("Stored skip block %+v in %x", *sb, s.Context.ServerIdentity().ID[0:8])
}
开发者ID:dedis,项目名称:cothority,代码行数:14,代码来源:skipchain.go
示例7: GetShaString
func GetShaString(data []byte) (res string) {
sha := sha256.New()
if _, err := sha.Write(data[:]); err != nil {
log.Error("Failed to hash data", err)
}
tmp := sha.Sum(nil)
sha.Reset()
if _, err := sha.Write(tmp); err != nil {
log.Error("Failed to hash data", err)
}
hash := sha.Sum(nil)
res = HashString(hash)
return
}
开发者ID:dedis,项目名称:cothority,代码行数:14,代码来源:utils.go
示例8: listen
// listen will select on the differents channels
func (nt *Ntree) listen() {
for {
select {
// Dispatch the block through the whole tree
case msg := <-nt.announceChan:
log.Lvl3(nt.Name(), "Received Block announcement")
nt.block = msg.BlockAnnounce.Block
// verify the block
go byzcoin.VerifyBlock(nt.block, "", "", nt.verifyBlockChan)
if nt.IsLeaf() {
nt.startBlockSignature()
continue
}
for _, tn := range nt.Children() {
err := nt.SendTo(tn, &msg.BlockAnnounce)
if err != nil {
log.Error(nt.Name(),
"couldn't send to", tn.Name(),
err)
}
}
// generate your own signature / exception and pass that up to the
// root
case msg := <-nt.blockSignatureChan:
nt.handleBlockSignature(&msg.NaiveBlockSignature)
// Dispatch the signature + expcetion made before through the whole
// tree
case msg := <-nt.roundSignatureRequestChan:
log.Lvl3(nt.Name(), " Signature Request Received")
go nt.verifySignatureRequest(&msg.RoundSignatureRequest)
if nt.IsLeaf() {
nt.startSignatureResponse()
continue
}
for _, tn := range nt.Children() {
err := nt.SendTo(tn, &msg.RoundSignatureRequest)
if err != nil {
log.Error(nt.Name(), "couldn't sent to",
tn.Name(), err)
}
}
// Decide if we want to sign this or not
case msg := <-nt.roundSignatureResponseChan:
nt.handleRoundSignatureResponse(&msg.RoundSignatureResponse)
}
}
}
开发者ID:dedis,项目名称:cothority,代码行数:50,代码来源:ntree.go
示例9: HashSum
func (tl *TransactionList) HashSum() []byte {
h := sha256.New()
for _, tx := range tl.Txs {
if _, err := h.Write([]byte(tx.Hash)); err != nil {
log.Error("Couldn't hash TX list", err)
}
}
if err := binary.Write(h, binary.LittleEndian, tl.TxCnt); err != nil {
log.Error("Couldn't hash TX list", err)
}
if err := binary.Write(h, binary.LittleEndian, tl.Fees); err != nil {
log.Error("Couldn't hash TX list", err)
}
return h.Sum(nil)
}
开发者ID:dedis,项目名称:cothority,代码行数:15,代码来源:transactionlist.go
示例10: getResponse
func (c *CoSimul) getResponse(in []abstract.Scalar) {
if c.IsLeaf() {
// This is the leaf-node and we can't verify it
return
}
verify := false
switch VerifyResponse {
case NoCheck:
log.Lvl3("Not checking at all")
case RootCheck:
verify = c.IsRoot()
case AllCheck:
verify = !c.IsLeaf()
}
if verify {
err := c.VerifyResponses(c.TreeNode().AggregatePublic())
if err != nil {
log.Error("Couldn't verify responses at our level", c.Name(), err.Error())
} else {
log.Lvl2("Successfully verified responses at", c.Name())
}
}
}
开发者ID:dedis,项目名称:cothority,代码行数:25,代码来源:protocol.go
示例11: handleSecInit
func (jv *JVSS) handleSecInit(m WSecInitMsg) error {
msg := m.SecInitMsg
log.Lvl4(jv.Name(), jv.Index(), "Received SecInit from", m.TreeNode.Name())
// Initialise shared secret
if err := jv.initSecret(msg.SID); err != nil {
return err
}
// Unmarshal received deal
deal := new(poly.Deal).UnmarshalInit(jv.info.T, jv.info.R, jv.info.N, jv.keyPair.Suite)
if err := deal.UnmarshalBinary(msg.Deal); err != nil {
return err
}
// Buffer received deal for later
secret, err := jv.secrets.secret(msg.SID)
if err != nil {
return err
}
secret.deals[msg.Src] = deal
// Finalise shared secret
if err := jv.finaliseSecret(msg.SID); err != nil {
log.Error(jv.Index(), err)
return err
}
log.Lvl4("Finished handleSecInit", jv.Name(), msg.SID)
return nil
}
开发者ID:dedis,项目名称:cothority,代码行数:31,代码来源:handlers.go
示例12: newIdentityService
func newIdentityService(c *onet.Context, path string) onet.Service {
s := &Service{
ServiceProcessor: onet.NewServiceProcessor(c),
StorageMap: &StorageMap{make(map[string]*Storage)},
skipchain: skipchain.NewClient(),
path: path,
}
var err error
s.propagateIdentity, err =
manage.NewPropagationFunc(c, "IdentityPropagateID", s.propagateIdentityHandler)
if err != nil {
return nil
}
s.propagateSkipBlock, err =
manage.NewPropagationFunc(c, "IdentityPropagateSB", s.propagateSkipBlockHandler)
if err != nil {
return nil
}
s.propagateConfig, err =
manage.NewPropagationFunc(c, "IdentityPropagateConf", s.propagateConfigHandler)
if err != nil {
return nil
}
if err := s.tryLoad(); err != nil {
log.Error(err)
}
for _, f := range []interface{}{s.ProposeSend, s.ProposeVote,
s.CreateIdentity, s.ProposeUpdate, s.ConfigUpdate} {
if err := s.RegisterHandler(f); err != nil {
log.Fatal("Registration error:", err)
}
}
return s
}
开发者ID:dedis,项目名称:cothority,代码行数:34,代码来源:service.go
示例13: propagateIdentityHandler
// propagateIdentity stores a new identity in all nodes.
func (s *Service) propagateIdentityHandler(msg network.Body) {
log.Lvlf4("Got msg %+v %v", msg, reflect.TypeOf(msg).String())
pi, ok := msg.(*PropagateIdentity)
if !ok {
log.Error("Got a wrong message for propagation")
return
}
id := ID(pi.Data.Hash)
if s.getIdentityStorage(id) != nil {
log.Error("Couldn't store new identity")
return
}
log.Lvl3("Storing identity in", s)
s.setIdentityStorage(id, pi.Storage)
return
}
开发者ID:dedis,项目名称:cothority,代码行数:17,代码来源:service.go
示例14: propagateConfigHandler
// propagateConfig handles propagation of all configuration-proposals in the identity-service.
func (s *Service) propagateConfigHandler(msg network.Body) {
log.Lvlf4("Got msg %+v %v", msg, reflect.TypeOf(msg).String())
id := ID(nil)
switch msg.(type) {
case *ProposeSend:
id = msg.(*ProposeSend).ID
case *ProposeVote:
id = msg.(*ProposeVote).ID
default:
log.Errorf("Got an unidentified propagation-request: %v", msg)
return
}
if id != nil {
sid := s.getIdentityStorage(id)
if sid == nil {
log.Error("Didn't find entity in", s)
return
}
sid.Lock()
defer sid.Unlock()
switch msg.(type) {
case *ProposeSend:
p := msg.(*ProposeSend)
sid.Proposed = p.Config
sid.Votes = make(map[string]*crypto.SchnorrSig)
case *ProposeVote:
v := msg.(*ProposeVote)
sid.Votes[v.Signer] = v.Signature
}
}
}
开发者ID:dedis,项目名称:cothority,代码行数:33,代码来源:service.go
示例15: newSkipchainService
func newSkipchainService(c *onet.Context, path string) onet.Service {
s := &Service{
ServiceProcessor: onet.NewServiceProcessor(c),
path: path,
SkipBlockMap: &SkipBlockMap{make(map[string]*SkipBlock)},
verifiers: map[VerifierID]SkipBlockVerifier{},
}
var err error
s.Propagate, err = manage.NewPropagationFunc(c, "SkipchainPropagate", s.PropagateSkipBlock)
log.ErrFatal(err)
c.ProtocolRegister(skipchainBFT, func(n *onet.TreeNodeInstance) (onet.ProtocolInstance, error) {
return bftcosi.NewBFTCoSiProtocol(n, s.bftVerify)
})
if err := s.tryLoad(); err != nil {
log.Error(err)
}
log.ErrFatal(s.RegisterHandlers(s.ProposeSkipBlock, s.SetChildrenSkipBlock,
s.GetUpdateChain))
if err := s.RegisterVerification(VerifyShard, s.VerifyShardFunc); err != nil {
log.Panic(err)
}
if err := s.RegisterVerification(VerifyNone, s.VerifyNoneFunc); err != nil {
log.Panic(err)
}
return s
}
开发者ID:dedis,项目名称:cothority,代码行数:26,代码来源:skipchain.go
示例16: Dispatch
// Dispatch listens for all channels and waits for a timeout in case nothing
// happens for a certain duration
func (p *ProtocolCount) Dispatch() error {
running := true
for running {
log.Lvl3(p.Info(), "waiting for message during", p.Timeout())
select {
case pc := <-p.PrepareCountChan:
log.Lvl3(p.Info(), "received from", pc.TreeNode.ServerIdentity.Address,
pc.Timeout)
p.SetTimeout(pc.Timeout)
p.FuncPC()
case c := <-p.CountChan:
p.FuncC(c)
running = false
case _ = <-p.NodeIsUpChan:
if p.Parent() != nil {
err := p.SendTo(p.Parent(), &NodeIsUp{})
if err != nil {
log.Error(p.Info(), "couldn't send to parent",
p.Parent().Name(), err)
}
} else {
p.Replies++
}
case <-time.After(time.Duration(p.Timeout()) * time.Millisecond):
log.Lvl3(p.Info(), "timed out while waiting for", p.Timeout())
if p.IsRoot() {
log.Lvl2("Didn't get all children in time:", p.Replies)
p.Count <- p.Replies
running = false
}
}
}
p.Done()
return nil
}
开发者ID:dedis,项目名称:cothority,代码行数:37,代码来源:count.go
示例17: triggerTransactions
func (c *Client) triggerTransactions(blocksPath string, nTxs int) error {
log.Lvl2("ByzCoin Client will trigger up to", nTxs, "transactions")
parser, err := blockchain.NewParser(blocksPath, magicNum)
if err != nil {
log.Error("Error: Couldn't parse blocks in", blocksPath,
".\nPlease download bitcoin blocks as .dat files first and place them in",
blocksPath, "Either run a bitcoin node (recommended) or using a torrent.")
return err
}
transactions, err := parser.Parse(0, ReadFirstNBlocks)
if err != nil {
return fmt.Errorf("Error while parsing transactions %v", err)
}
if len(transactions) == 0 {
return errors.New("Couldn't read any transactions.")
}
if len(transactions) < nTxs {
return fmt.Errorf("Read only %v but caller wanted %v", len(transactions), nTxs)
}
consumed := nTxs
for consumed > 0 {
for _, tr := range transactions {
// "send" transaction to server (we skip tcp connection on purpose here)
c.srv.AddTransaction(tr)
}
consumed--
}
return nil
}
开发者ID:dedis,项目名称:cothority,代码行数:30,代码来源:client.go
示例18: Copy
// Copy returns a deep copy of the AccountList.
func (c *Config) Copy() *Config {
b, err := network.MarshalRegisteredType(c)
if err != nil {
log.Error("Couldn't marshal AccountList:", err)
return nil
}
_, msg, err := network.UnmarshalRegisteredType(b, network.DefaultConstructors(network.Suite))
if err != nil {
log.Error("Couldn't unmarshal AccountList:", err)
}
ilNew := msg.(Config)
if len(ilNew.Data) == 0 {
ilNew.Data = make(map[string]string)
}
return &ilNew
}
开发者ID:dedis,项目名称:cothority,代码行数:17,代码来源:struct.go
示例19: handleChallengeCommit
// handleCommitChallenge will verify the signature + check if no more than 1/3
// of participants refused to sign.
func (bz *ByzCoin) handleChallengeCommit(ch *ChallengeCommit) error {
// marshal the block
marshalled, err := json.Marshal(bz.tempBlock)
if err != nil {
return err
}
ch.Challenge = bz.commit.Challenge(ch.Challenge)
// verify if the signature is correct
if err := cosi.VerifyCosiSignatureWithException(bz.suite, bz.aggregatedPublic, marshalled, ch.Signature, ch.Exceptions); err != nil {
log.Error(bz.Name(), "Verification of the signature failed:", err)
bz.signRefusal = true
}
// Verify if we have no more than 1/3 failed nodes
if len(ch.Exceptions) > int(bz.threshold) {
log.Errorf("More than 1/3 (%d/%d) refused to sign ! ABORT", len(ch.Exceptions), len(bz.Roster().List))
bz.signRefusal = true
}
// store the exceptions for later usage
bz.tempExceptions = ch.Exceptions
log.Lvl3("ByzCoin handle Challenge COMMIT")
if bz.IsLeaf() {
return bz.startResponseCommit()
}
// send it down
for _, tn := range bz.Children() {
err = bz.SendTo(tn, ch)
}
return nil
}
开发者ID:dedis,项目名称:cothority,代码行数:36,代码来源:byzcoin.go
示例20: HashSum
// HashSum returns a hash representation of the header
func (h *Header) HashSum() []byte {
ha := sha256.New()
if _, err := ha.Write([]byte(h.MerkleRoot)); err != nil {
log.Error("Couldn't hash header", err)
}
if _, err := ha.Write([]byte(h.Parent)); err != nil {
log.Error("Couldn't hash header", err)
}
if _, err := ha.Write([]byte(h.ParentKey)); err != nil {
log.Error("Couldn't hash header", err)
}
if _, err := ha.Write([]byte(h.PublicKey)); err != nil {
log.Error("Couldn't hash header", err)
}
return ha.Sum(nil)
}
开发者ID:dedis,项目名称:cothority,代码行数:17,代码来源:trblock.go
注:本文中的github.com/dedis/onet/log.Error函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论