本文整理汇总了Golang中h0tb0x/crypto.Digest.Bytes方法的典型用法代码示例。如果您正苦于以下问题:Golang Digest.Bytes方法的具体用法?Golang Digest.Bytes怎么用?Golang Digest.Bytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类h0tb0x/crypto.Digest
的用法示例。
在下文中一共展示了Digest.Bytes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AddUpdateFriend
// Add a new friend, or if the friend exists, update the host and port data.
func (this *LinkMgr) AddUpdateFriend(fp *crypto.Digest, host string, port uint16) {
this.cmut.Lock()
defer this.cmut.Unlock()
// Make or insert friend
this.Db.Exec(
"INSERT OR IGNORE INTO Friend (id, fingerprint, host, port) VALUES (NULL, ?, ?, ?)",
fp.Bytes(), host, port)
row := this.Db.SingleQuery("SELECT id FROM Friend WHERE fingerprint = ?", fp.Bytes())
var id int
this.Db.Scan(row, &id)
this.Db.Exec("UPDATE Friend SET host = ?, port = ? WHERE id = ?",
host, port, id)
_, ok := this.friendsFp[fp.String()]
fi := &friendInfo{id: id, fingerprint: fp, host: host, port: port}
this.friendsFp[fp.String()] = fi
this.friendsId[id] = fi
if !ok {
// If it was added, signal upper layer
for _, f := range this.listeners {
f(id, fp, FriendAdded)
}
}
}