func (db *DB) DeletePeer(addr lncore.LnAddr) (err error) {

	var tx *sql.Tx
	if tx, err = db.DBHandler.Begin(); err != nil {
		return
	}

	defer func() {
		if err != nil {
			tx.Rollback()
			err = fmt.Errorf("Error while deleting peer: \n%s", err)
			return
		}
		err = tx.Commit()
	}()

	// use peer schema
	if _, err = tx.Exec("USE " + db.peerSchema + ";"); err != nil {
		return
	}

	// delete the peer from the peer table
	deletePeerQuery := fmt.Sprintf("DELETE FROM %s WHERE lnaddr='%s';", db.peerTableName, addr.ToString())
	if _, err = tx.Exec(deletePeerQuery); err != nil {
		return
	}

	return
}
// DeletePeer deletes a peer from the database
DeletePeer deletes a peer from the database
// DeletePeer deletes a peer from the database
func (db *DB) DeletePeer(addr lncore.LnAddr) (err error) {
	var tx *sql.Tx
	if tx, err = db.DBHandler.Begin(); err != nil {
		return
	}
	defer func() {
		if err != nil {
			tx.Rollback()
			err = fmt.Errorf("Error while deleting peer: \n%s", err)
			return
		}
		err = tx.Commit()
	}()
	if _, err = tx.Exec("USE " + db.peerSchema + ";"); err != nil {
		return
	}
	deletePeerQuery := fmt.Sprintf("DELETE FROM %s WHERE lnaddr='%s';", db.peerTableName, addr.ToString())
	if _, err = tx.Exec(deletePeerQuery); err != nil {
		return
	}
	return
}
func ( db * DB ) DeletePeer ( addr lncore . LnAddr ) ( err error ) { var tx * sql . Tx if tx , err = db . DBHandler . Begin ( ) ; err != nil { return } defer func ( ) { if err != nil { tx . Rollback ( ) err = fmt . Errorf ( " \n " , err ) return } err = tx . Commit ( ) } ( ) if _ , err = tx . Exec ( " " + db . peerSchema + " " ) ; err != nil { return } deletePeerQuery := fmt . Sprintf ( " " , db . peerTableName , addr . ToString ( ) ) if _ , err = tx . Exec ( deletePeerQuery ) ; err != nil { return } return }
DeletePeer deletes a peer from the database
DeletePeer deletes a peer from the database
// use peer schema // delete the peer from the peer table