本文整理汇总了Golang中github.com/ipfs/go-ipfs/namesys/pb.IpnsEntry.GetValidityType方法的典型用法代码示例。如果您正苦于以下问题:Golang IpnsEntry.GetValidityType方法的具体用法?Golang IpnsEntry.GetValidityType怎么用?Golang IpnsEntry.GetValidityType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/ipfs/go-ipfs/namesys/pb.IpnsEntry
的用法示例。
在下文中一共展示了IpnsEntry.GetValidityType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ipnsEntryDataForSig
func ipnsEntryDataForSig(e *pb.IpnsEntry) []byte {
return bytes.Join([][]byte{
e.Value,
e.Validity,
[]byte(fmt.Sprint(e.GetValidityType())),
},
[]byte{})
}
示例2: checkEOL
func checkEOL(e *pb.IpnsEntry) (time.Time, bool) {
if e.GetValidityType() == pb.IpnsEntry_EOL {
eol, err := u.ParseRFC3339(string(e.GetValidity()))
if err != nil {
return time.Time{}, false
}
return eol, true
}
return time.Time{}, false
}
示例3: ValidateIpnsRecord
// ValidateIpnsRecord implements ValidatorFunc and verifies that the
// given 'val' is an IpnsEntry and that that entry is valid.
func ValidateIpnsRecord(k key.Key, val []byte) error {
entry := new(pb.IpnsEntry)
err := proto.Unmarshal(val, entry)
if err != nil {
return err
}
switch entry.GetValidityType() {
case pb.IpnsEntry_EOL:
t, err := u.ParseRFC3339(string(entry.GetValidity()))
if err != nil {
log.Debug("Failed parsing time for ipns record EOL")
return err
}
if time.Now().After(t) {
return ErrExpiredRecord
}
default:
return ErrUnrecognizedValidity
}
return nil
}