| 48 | } |
| 49 | |
| 50 | void node::accept_loop() |
| 51 | { |
| 52 | auto self = shared_from_this(); |
| 53 | while( !_accept_loop_complete.canceled() ) |
| 54 | { |
| 55 | try { |
| 56 | auto new_peer = std::make_shared<peer_connection>(self); |
| 57 | _tcp_server.accept( new_peer.get_socket() ); |
| 58 | |
| 59 | if( _accept_loop_complete.canceled() ) |
| 60 | return; |
| 61 | |
| 62 | _peers.insert( new_peer ); |
| 63 | |
| 64 | |
| 65 | |
| 66 | // limit the rate at which we accept connections to mitigate DOS attacks |
| 67 | fc::usleep( fc::milliseconds(10) ); |
| 68 | } FC_CAPTURE_AND_RETHROW() |
| 69 | } |
| 70 | } // accept_loop() |
| 71 | |
| 72 | |
| 73 |