 ###
 
 DHT::_onFindNode = (addr, message) ->
-  self = this
   nodeId = message.a and message.a.target
   if !nodeId
     errMessage = '`find_node` missing required `a.target` field'
-    self._debug errMessage
-    self._sendError addr, message.t, ERROR_TYPE.PROTOCOL, errMessage
-    return
-  self._debug 'got find_node %s from %s', idToHexString(nodeId), addr
+    @_debug errMessage
+    @_sendError addr, message.t, ERROR_TYPE.PROTOCOL, errMessage
+    return
+  @_debug 'got find_node %s from %s', idToHexString(nodeId), addr
   # Convert nodes to "compact node info" representation
-  nodes = convertToNodeInfo(self.nodes.closest({ id: nodeId }, K))
+  nodes = convertToNodeInfo(@nodes.closest({ id: nodeId }, K))
   res =
     t: message.t
     y: MESSAGE_TYPE.RESPONSE
     r:
-      id: self.nodeId
+      id: @nodeId
       nodes: nodes
-  self._send addr, res
+  @_send addr, res
   return
 
 ###*

    )
    lookup()
    # TODO: keep retrying after one failure
    self._bootstrapTimeout = setTimeout((->
      if self._destroyed
        return
      # If 0 nodes are in the table after a timeout, retry with bootstrap nodes
      if self.nodes.count() == 0
        self._debug 'No DHT bootstrap nodes replied, retry'
        lookup()
      return
    ), BOOTSTRAP_TIMEOUT)
    self._bootstrapTimeout.unref and self._bootstrapTimeout.unref()
    return
  return


###

DHT::_rotateSecrets = ->
  # Initialize secrets array
  # @secrets[0] is the current secret, used to generate new tokens
  # @secrets[1] is the last secret, which is still accepted

  createSecret = ->
    new Buffer(hat(SECRET_ENTROPY), 'hex')

  if !@secrets
    @secrets = [
      createSecret()
      createSecret()
    ]
    return
  @secrets[1] = @secrets[0]
  @secrets[0] = createSecret()
  return

###*
