Revision 3e80678a
Added by Marc Dequènes over 13 years ago
- ID 3e80678af8072c7c8842c8c793bd4f634f8c279e
lib/cyborghood/cyborg/botnet.rb | ||
---|---|---|
end
|
||
|
||
def contact_peer(peer, block, dont_open_new_connection = false)
|
||
return block.call @comm_list[peer] if @comm_list.has_key? peer
|
||
if @comm_list.has_key? peer
|
||
logger.debug "Botnet: Reusing connection for peer #{peer}"
|
||
return block.call @comm_list[peer]
|
||
end
|
||
|
||
return if dont_open_new_connection
|
||
|
||
logger.debug "Botnet: Trying to open a new connection to peer #{peer}"
|
||
|
||
if @comm_list_attempt.has_key? peer
|
||
@comm_list_attempt[peer] << block
|
||
else
|
||
... | ... | |
begin
|
||
yield(callback)
|
||
rescue
|
||
logger.debug "Botnet: connection attempt to peer #{peer} failed: " + $!
|
||
# TODO: retry (wait_timer + recursive call + counter)
|
||
block.call false
|
||
end
|
Also available in: Unified diff
[debug] log more when connecting to peer