- EAF9888F03CFC0267577D217D24B0FBA45D5D141E9D8536081059B97195590A0F7AA8D27704CABD46D1AF5033733B96D1BB01C47DCFBD636DB659DB101CC4A45
+ 712C2726313EE78027C22B67DB8F148572C19003463D8438F47D64DC4F354376A7B492D5A7BFBE324FE8B8E6023E4836473B2B76099B72F58262D616665D0F41
bitcoin/src/net.cpp
(4 . 7)(4 . 6)
504 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
505
506 #include "headers.h"
507 #include "irc.h"
508 #include "db.h"
509 #include "net.h"
510 #include "init.h"
(244 . 24)(243 . 6)
512 }
513
514
515 void ThreadGetMyExternalIP(void* parg)
516 {
517 // Wait for IRC to get it first
518 if (!GetBoolArg("-noirc"))
519 {
520 for (int i = 0; i < 2 * 60; i++)
521 {
522 Sleep(1000);
523 if (fGotExternalIP || fShutdown)
524 return;
525 }
526 }
527
528 // Fallback in case IRC fails to get it
529 // ... nope.
530 }
531
532
533 bool AddAddress(CAddress addr, int64 nTimePenalty, CAddrDB *pAddrDB)
534 {
535 if (!addr.IsRoutable())
(1060 . 11)(1041 . 6)
537 if (nSinceLastTry < nDelay)
538 continue;
539
540 // If we have IRC, we'll be notified when they first come online,
541 // and again every 24 hours by the refresh broadcast.
542 if (nGotIRCAddresses > 0 && vNodes.size() >= 2 && nSinceLastSeen > 24 * 60 * 60)
543 continue;
544
545 // Only try the old stuff if we don't have enough connections
546 if (vNodes.size() >= 8 && nSinceLastSeen > 24 * 60 * 60)
547 continue;
(1298 . 21)(1274 . 22)
549 {
550 // Proxies can't take incoming connections
551 addrLocalHost.ip = CAddress("0.0.0.0").ip;
552 printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str());
553 }
554 else
555 {
556 CreateThread(ThreadGetMyExternalIP, NULL);
557 addrLocalHost.ip = CAddress(mapArgs["-myip"]).ip;
558 if (!addrLocalHost.IsValid())
559 throw runtime_error(strprintf(_("You must set myip=<ipaddress> on the command line or in the configuration file:\n%s\n"
560 "If the file does not exist, create it with owner-readable-only file permissions."),
561 GetConfigFile().c_str()));
562 }
563
564 printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str());
565
566 //
567 // Start threads
568 //
569
570 // Get addresses from IRC and advertise ours
571 if (!CreateThread(ThreadIRCSeed, NULL))
572 printf("Error: CreateThread(ThreadIRCSeed) failed\n");
573
574 // Send and receive from sockets, accept connections
575 if (!CreateThread(ThreadSocketHandler, NULL))
576 printf("Error: CreateThread(ThreadSocketHandler) failed\n");