本文整理汇总了Golang中github.com/yahoo/coname/keyserver/kv.Batch.Delete方法的典型用法代码示例。如果您正苦于以下问题:Golang Batch.Delete方法的具体用法?Golang Batch.Delete怎么用?Golang Batch.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/yahoo/coname/keyserver/kv.Batch
的用法示例。
在下文中一共展示了Batch.Delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: step
//.........这里部分代码省略.........
// First write to DB, *then* notify subscribers. That way, if subscribers
// start listening before searching the DB, they're guaranteed to see the
// signature: either it's already in the DB, or they'll get notified. If
// the order was reversed, they could miss the notification but still not
// see anything in the DB.
ks.signatureBroadcast.Publish(epochNr, newSEH)
}
if epochNr != rs.LastEpochDelimiter.EpochNumber {
break
}
if rs.ThisReplicaNeedsToSignLastEpoch && newSEH.Signatures[ks.replicaID] != nil {
rs.ThisReplicaNeedsToSignLastEpoch = false
ks.updateEpochProposer()
// updateSignatureProposer should in general be called after writes
// have been flushed to db, but given ThisReplicaNeedsToSignLast =
// false we know that updateSignatureProposer will not access the db.
ks.updateSignatureProposer()
}
// get all existing ratifications for this epoch
allSignatures := make(map[uint64][]byte)
existingRatifications, err := ks.allRatificationsForEpoch(epochNr)
if err != nil {
log.Panicf("allRatificationsForEpoch(%d): %s", epochNr, err)
}
for _, seh := range existingRatifications {
for id, sig := range seh.Signatures {
allSignatures[id] = sig
}
}
// check whether the epoch was already ratified
wasRatified := coname.VerifyPolicy(ks.serverAuthorized, tehBytes, allSignatures)
if wasRatified {
break
}
for id, sig := range newSEH.Signatures {
allSignatures[id] = sig
}
// check whether the epoch has now become ratified
nowRatified := coname.VerifyPolicy(ks.serverAuthorized, tehBytes, allSignatures)
if !nowRatified {
break
}
if !rs.LastEpochNeedsRatification {
log.Panicf("%x: thought last epoch was not already ratified, but it was", ks.replicaID)
}
rs.LastEpochNeedsRatification = false
ks.updateEpochProposer()
var teh proto.EncodedTimestampedEpochHead
err = teh.Unmarshal(tehBytes)
if err != nil {
log.Panicf("invalid epoch head %d (%x): %s", epochNr, tehBytes, err)
}
allSignaturesSEH := &proto.SignedEpochHead{
Head: teh,
Signatures: allSignatures,
}
oldDeferredIO := deferredIO
deferredSendEpoch := ks.verifierLogAppend(&proto.VerifierStep{Type: &proto.VerifierStep_Epoch{Epoch: allSignaturesSEH}}, rs, wb)
deferredSendUpdates := []func(){}
iter := ks.db.NewIterator(kv.BytesPrefix([]byte{tableUpdatesPendingRatificationPrefix}))
defer iter.Release()
for iter.Next() {
update := &proto.SignedEntryUpdate{}
err := update.Unmarshal(iter.Value())
if err != nil {
log.Panicf("invalid pending update %x: %s", iter.Value(), err)
}
deferredSendUpdates = append(deferredSendUpdates, ks.verifierLogAppend(&proto.VerifierStep{Type: &proto.VerifierStep_Update{Update: update}}, rs, wb))
wb.Delete(iter.Key())
}
deferredIO = func() {
oldDeferredIO()
// First, send the ratified epoch to verifiers
deferredSendEpoch()
// Then send updates that were waiting for that epoch to go out
for _, f := range deferredSendUpdates {
f()
}
}
case *proto.KeyserverStep_VerifierSigned:
rNew := step.GetVerifierSigned()
for id := range rNew.Signatures {
// Note: The signature *must* have been authenticated before being inserted
// into the log, or else verifiers could just trample over everyone else's
// signatures, including our own.
dbkey := tableRatifications(rNew.Head.Head.Epoch, id)
wb.Put(dbkey, proto.MustMarshal(rNew))
}
ks.wr.Notify(step.UID, nil)
return func() {
// As above, first write to DB, *then* notify subscribers.
ks.signatureBroadcast.Publish(rNew.Head.Head.Epoch, rNew)
}
default:
log.Panicf("unknown step pb in replicated log: %#v", step)
}
return
}