# File lib/moped/cluster.rb, line 172
    def refresh(nodes_to_refresh = seeds)
      refreshed_nodes = []
      seen = {}
      # Set up a recursive lambda function for refreshing a node and it's peers.
      refresh_node = ->(node) do
        unless node.address.resolved
          begin
            node.refresh
          rescue Errors::ConnectionFailure
          end
        end
        unless seen[node] || !node.address.resolved
          seen[node] = true
          # Add the node to the global list of known nodes.
          seeds.push(node) unless seeds.include?(node)
          begin
            node.refresh
            # This node is good, so add it to the list of nodes to return.
            refreshed_nodes.push(node) unless refreshed_nodes.include?(node)
            # Now refresh any newly discovered peer nodes - this will also
            # remove nodes that are not included in the peer list.
            refresh_peers(node, &refresh_node)
          rescue Errors::ConnectionFailure
            # We couldn't connect to the node.
          end
        end
      end

      nodes_to_refresh.each(&refresh_node)
      refreshed_nodes
    end