channeldb: add DeleteLinkNode method

This commit is contained in:
Wilmer Paulino
2018-06-11 14:47:15 -07:00
parent daf4a25fd9
commit 044e81bbd4
2 changed files with 50 additions and 0 deletions

View File

@@ -127,6 +127,24 @@ func putLinkNode(nodeMetaBucket *bolt.Bucket, l *LinkNode) error {
return nodeMetaBucket.Put(nodePub, b.Bytes())
}
// DeleteLinkNode removes the link node with the given identity from the
// database.
func (d *DB) DeleteLinkNode(identity *btcec.PublicKey) error {
return d.Update(func(tx *bolt.Tx) error {
return d.deleteLinkNode(tx, identity)
})
}
func (d *DB) deleteLinkNode(tx *bolt.Tx, identity *btcec.PublicKey) error {
nodeMetaBucket := tx.Bucket(nodeInfoBucket)
if nodeMetaBucket == nil {
return ErrLinkNodesNotFound
}
pubKey := identity.SerializeCompressed()
return nodeMetaBucket.Delete(pubKey)
}
// FetchLinkNode attempts to lookup the data for a LinkNode based on a target
// identity public key. If a particular LinkNode for the passed identity public
// key cannot be found, then ErrNodeNotFound if returned.