本文整理汇总了Golang中github.com/keybase/client/go/protocol.KID.IsValid方法的典型用法代码示例。如果您正苦于以下问题:Golang KID.IsValid方法的具体用法?Golang KID.IsValid怎么用?Golang KID.IsValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/keybase/client/go/protocol.KID
的用法示例。
在下文中一共展示了KID.IsValid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: UpdateDevices
// UpdateDevices takes the Device object from the given ChainLink
// and updates keys to reflects any device changes encoded therein.
func (ckf *ComputedKeyFamily) UpdateDevices(tcl TypedChainLink) (err error) {
G.Log.Debug("+ UpdateDevice")
defer func() {
G.Log.Debug("- UpdateDevice -> %s", ErrToOk(err))
}()
var dobj *Device
if dobj = tcl.GetDevice(); dobj == nil {
return
}
did := dobj.ID
kid := dobj.Kid
G.Log.Debug("| Device ID=%s; KID=%s", did, kid.String())
var prevKid keybase1.KID
if existing, found := ckf.cki.Devices[did]; found {
G.Log.Debug("| merge with existing")
prevKid = existing.Kid
existing.Merge(dobj)
dobj = existing
} else {
G.Log.Debug("| New insert")
ckf.cki.Devices[did] = dobj
}
// Clear out the old Key that this device used to refer to.
// We might wind up just clobbering it with the same thing, but
// that's fine for now.
if prevKid.IsValid() {
G.Log.Debug("| Clear out old key")
delete(ckf.cki.KIDToDeviceID, prevKid)
}
if kid.IsValid() {
ckf.cki.KIDToDeviceID[kid] = did
}
return
}
示例2: UpdateDevices
// UpdateDevices takes the Device object from the given ChainLink
// and updates keys to reflects any device changes encoded therein.
func (ckf *ComputedKeyFamily) UpdateDevices(tcl TypedChainLink) (err error) {
var dobj *Device
if dobj = tcl.GetDevice(); dobj == nil {
ckf.G().VDL.Log(VLog1, "Short-circuit of UpdateDevices(); not a device link")
return
}
defer ckf.G().Trace("UpdateDevice", func() error { return err })()
did := dobj.ID
kid := dobj.Kid
ckf.G().Log.Debug("| Device ID=%s; KID=%s", did, kid.String())
var prevKid keybase1.KID
if existing, found := ckf.cki.Devices[did]; found {
ckf.G().Log.Debug("| merge with existing")
prevKid = existing.Kid
existing.Merge(dobj)
dobj = existing
} else {
ckf.G().Log.Debug("| New insert")
ckf.cki.Devices[did] = dobj
}
// Clear out the old Key that this device used to refer to.
// We might wind up just clobbering it with the same thing, but
// that's fine for now.
if prevKid.IsValid() {
ckf.G().Log.Debug("| Clear out old key")
delete(ckf.cki.KIDToDeviceID, prevKid)
}
if kid.IsValid() {
ckf.cki.KIDToDeviceID[kid] = did
}
return
}
示例3: UpdateDevices
// UpdateDevices takes the Device object from the given ChainLink
// and updates keys to reflects any device changes encoded therein.
func (ckf *ComputedKeyFamily) UpdateDevices(tcl TypedChainLink) (err error) {
var dobj *Device
if dobj = tcl.GetDevice(); dobj == nil {
ckf.G().VDL.Log(VLog1, "Short-circuit of UpdateDevices(); not a device link")
return
}
defer ckf.G().Trace("UpdateDevice", func() error { return err })()
did := dobj.ID
kid := dobj.Kid
ckf.G().Log.Debug("| Device ID=%s; KID=%s", did, kid.String())
var prevKid keybase1.KID
if existing, found := ckf.cki.Devices[did]; found {
ckf.G().Log.Debug("| merge with existing")
prevKid = existing.Kid
existing.Merge(dobj)
dobj = existing
} else {
ckf.G().Log.Debug("| New insert")
ckf.cki.Devices[did] = dobj
}
// If a KID is specified, we should clear out any previous KID from the
// KID->Device map. But if not, leave the map as it is. Later "device"
// blobs in the sigchain aren't required to repeat the KID every time.
if kid.IsValid() {
if prevKid.IsValid() {
ckf.G().Log.Debug("| Clear out old key")
delete(ckf.cki.KIDToDeviceID, prevKid)
}
ckf.cki.KIDToDeviceID[kid] = did
}
return
}