             nodes = res?.rows?.map (row) ->
                 row.node
             cb null, nodes
-
-exports.getListenerNodes = (listener, cb) ->
-    db.query "SELECT DISTINCT node FROM subscriptions WHERE listener=$1", [listener], (err, res) ->
-        cb err, res?.rows?.map (row) -> row.node
-
 
 LOST_TRANSACTION_TIMEOUT = 60 * 1000
 

    withNextDb (db) ->
        new Transaction(db, cb)

# TODO: currently unused, should re-check to delete local node after an unsubscribe
exports.isListeningToNode = (node, listenerJids, cb) ->
    i = 1
    conditions = listenerJids.map((listenerJid) ->
        i++
        "listener = $#{i}"
    ).join(" OR ")
    unless conditions
        # Short-cut
        return cb null, false

    withNextDb (db) ->
        db.query "SELECT listener FROM subscriptions WHERE node = $1 AND (#{conditions}) LIMIT 1"
        , [node, listenerJids...]
        , (err, res) ->
            process.nextTick ->
                dbIsAvailable(db)
            cb err, (res?.rows?[0]?)

exports.nodeExists = (node, cb) ->
    withNextDb (db) ->
        db.query "SELECT node FROM nodes WHERE node=$1", [ node ], (err, res) ->

            )
        ], cb

    getOwnersByNodePrefix: (nodePrefix, cb) ->
        db = @db
        async.waterfall [(cb2) ->
