Commit graph

339 commits

Author SHA1 Message Date
Gavin Andresen
f487746ded Remove half-implemented publish/subscribe system 2012-04-04 15:56:00 -04:00
Pieter Wuille
092631f0ba Condition variable for outbound connection slots
Keep a global counter for nOutbound, protected with its own waitable
critical section, and wait when all outbound slots are filled, rather
than polling.

This removes the (on average) 1 second delay between a lost connection
and a new connection attempt, and may speed up shutdowns.
2012-04-04 17:24:13 +02:00
Pieter Wuille
bf1afb02ca Give DNS seeds a random age between 3 and 7 days old
This speeds up initial connections with an old/large addr.dat a lot.
2012-03-25 16:06:16 +02:00
Gavin Andresen
a6b4a11385 Merge branch 'addrman' of https://github.com/sipa/bitcoin 2012-03-22 09:19:01 -04:00
Alistair Buxton
bb13d056ea When disconnecting a node, clear the received buffer so that we do
not process any already received messages.

The primary reason to do this is if a node spams hundreds of messages
and we ban them, we don't want to continue processing the rest of it.
2012-03-18 03:03:24 +00:00
nomnombtc
f8c478c4fb fix typo src/net.cpp 2012-03-05 19:33:24 +01:00
Gavin Andresen
972060ce0e bitcoind changes to stop storing settings in wallet.dat. 2012-02-26 23:21:33 +01:00
Pieter Wuille
5fee401fe1 CAddrMan: stochastic address manager
Design goals:
 * Only keep a limited number of addresses around, so that addr.dat does not grow without bound.
 * Keep the address tables in-memory, and occasionally write the table to addr.dat.
 * Make sure no (localized) attacker can fill the entire table with his nodes/addresses.

See comments in addrman.h for more detailed information.
2012-02-24 13:41:04 +01:00
Pieter Wuille
a3342d096f Fix #626: RecvLine wrong error message
Also moved RecvLine to net.cpp.
2012-02-19 19:06:42 +01:00
Pieter Wuille
c59881eaee Symbolic names for threads
Introduce an enum threadId, and use symbolic indices when accessing
vnThreadsRunning.
2012-02-16 12:43:06 +01:00
Pieter Wuille
999b4cacaf Merge pull request #844 from sipa/shutdownfix
Several shutdown-related fixes
2012-02-16 03:34:11 -08:00
Pieter Wuille
cc201e01f8 Several shutdown-related fixes
* do not let vnThreadsRunning[1] go negative
* do not perform locking operations while vnThreadsRunning[1] is decreased
* check vnThreadsRunning[1] at exit
2012-02-15 21:17:15 +01:00
Pieter Wuille
25ab17585e Bugfix: do not create CAddress for invalid accepts 2012-02-15 20:56:29 +01:00
Matt Corallo
baba6e7de2 Get ext. IP from UPnP, make sure addrMe IsRoutable() in version.
This fixes a potential bug where some NATs may replace the node's
interal IP with its external IP in version messages, causing
incorrect checksums when version messages begin being checksummed
on February 14, 2012.
2012-02-10 00:54:11 -05:00
Gavin Andresen
882164196e Update all copyrights to 2012 2012-02-07 11:28:30 -05:00
Gavin Andresen
9d952d17bb Look for flushwallet/listen/irc/dnsseed/upnp instead of noflushwallet/etc. And switch default for irc to 0. 2012-02-07 09:14:31 -05:00
Gregory Maxwell
5d1b8f1725 Avoid advertising the node's address when it is not listening or IsInitialBlockDownload().
This also avoids flushing setAddrKnown until 24 hours has passed,
and avoids contacting the external IP services when not listening.

Advertising non-listening nodes is just addr message spam.
It doesn't help the network, in fact it hurts the network,
and it also hurts user's privacy.

Advertising far out of sync nodes doesn't help the network—
they can't even forward (most) transactions and wastes nodes
outbound slots.
2012-02-01 18:08:03 -05:00
Matt Corallo
177dbcaace Fix UPnP by reannouncing every 20 minutes. 2012-01-31 17:42:15 -05:00
Gavin Andresen
7012b124bc Merge branch 'updateseednodes' of https://github.com/nanotube/bitcoin 2012-01-19 14:23:49 -05:00
Gavin Andresen
c55fd06b99 Merge branch 'tabs-to-space' of https://github.com/larsr/bitcoin 2012-01-19 14:22:26 -05:00
Daniel Folkinshteyn
b2f76e9ded Update seednodes, pick long-uptime nodes with version >= 0.4.0 2012-01-19 01:54:14 -05:00
Pieter Wuille
c981d768b3 Fix handling of default ports 2012-01-17 02:12:35 +01:00
Gavin Andresen
8498c59144 Merge branch 'keepnode' of https://github.com/TheBlueMatt/bitcoin 2012-01-16 16:45:43 -05:00
Lars Rasmusson
b985efaac1 Replace tabs with four spaces to comply with coding standard in doc/coding.txt 2012-01-14 12:14:36 +01:00
Matt Corallo
10ba0a3efc Minor code cleanup to use fHaveUPnP instead of #ifdef 2012-01-12 22:13:16 -05:00
Matt Corallo
b24e6e4d1b Add -keepnode which attempts to -addnode and keep a connection open 2012-01-12 22:13:16 -05:00
Gavin Andresen
a1de57a063 Compile with extra warnings turned on. And more makefile/code tidying up.
This turns on most gcc warnings, and removes some unused variables and other code that triggers warnings.
Exceptions are:
 -Wno-sign-compare : triggered by lots of comparisons of signed integer to foo.size(), which is unsigned.
 -Wno-char-subscripts : triggered by the convert-to-hex functions (I may fix this in a future commit).
2012-01-12 20:02:47 -05:00
Pieter Wuille
67a42f929b Network stack refactor
This introduces CNetAddr and CService, respectively wrapping an
(IPv6) IP address and an IP+port combination. This functionality used
to be part of CAddress, which also contains network flags and
connection attempt information. These extra fields are however not
always necessary.

These classes, along with logic for creating connections and doing
name lookups, are moved to netbase.{h,cpp}, which does not depend on
headers.h.

Furthermore, CNetAddr is mostly IPv6-ready, though IPv6
functionality is not yet enabled for the application itself.
2012-01-06 18:55:37 +01:00
Gavin Andresen
0fcf91ea1e Fix issue #659, and cleanup wallet/command-line argument handling a bit 2012-01-03 10:17:28 -05:00
Pieter Wuille
a75d7066b8 Fix some address-handling deadlocks
Made three critical blocks for cs_mapAddresses smaller, and moved
writing to the database out of them. This should also improve the
concurrency of the code.
2012-01-03 02:01:56 +01:00
Wladimir J. van der Laan
bde280b9a4 Revert "Use standard C99 (and Qt) types for 64-bit integers"
This reverts commit 21d9f36781.
2011-12-21 22:33:19 +01:00
Luke Dashjr
21d9f36781 Use standard C99 (and Qt) types for 64-bit integers 2011-12-20 16:52:59 -05:00
Gavin Andresen
26ce92b352 Use std::numeric_limits<> for typesafe INT_MAX/etc 2011-12-19 19:10:34 -05:00
Gavin Andresen
1f3bc1c239 Merge pull request #707 from gavinandresen/BIP14
Implement BIP 14 : separate protocol version from client version
2011-12-19 07:25:16 -08:00
Gavin Andresen
f8ded588a2 Implement BIP 14 : separate protocol version from client version 2011-12-19 10:24:23 -05:00
Luke Dashjr
647734881c Add my DNS seed domain 2011-12-16 18:34:47 -05:00
Matt Corallo
61a8c0569e Add sipa's new dnsseed. 2011-12-16 11:30:36 -05:00
Gavin Andresen
ca287d66f2 Merge pull request #694 from luke-jr/restore_old_miniupnp_compat
Restore compatibility with miniupnpc 1.5 (without breaking miniupnp 1.6)
2011-12-12 11:32:48 -08:00
Luke Dashjr
94b97046fd Restore compatibility with miniupnpc 1.5 (without breaking miniupnp 1.6) 2011-12-10 11:52:50 -05:00
Matt Corallo
2bc6cecebb Move DNS Seed lookup to a new thread. 2011-11-26 14:28:46 -05:00
Jeff Garzik
02d630c37f Remove vladimir's DNS seed, at his request. 2011-10-31 12:42:01 -04:00
Gavin Andresen
6853e627f1 Fix build on windows and mac
Replaced all occurrences of #if* __WXMSW__ with WIN32,
and all occurrences of __WXMAC_OSX__ with MAC_OSX, and made
sure those are defined appropriately in the makefile and bitcoin-qt.pro.
2011-10-07 11:02:21 -04:00
Gavin Andresen
8bc52d0692 Merge pull request #558 from luke-jr/bugfix_CreateThread_ThreadSocketHandler_errReporting
Bugfix: ThreadSocketHandler creation error
2011-10-05 07:27:56 -07:00
Gavin Andresen
9ec4fa7b50 Merge pull request #561 from luke-jr/optimize_conn_adjtime
Only GetAdjustedTime once for the retry loop
2011-10-05 07:22:52 -07:00
Luke Dashjr
65ba3e2f50 Bugfix: report error creating ThreadSocketHandler thread just like the rest 2011-10-03 23:45:42 -04:00
Luke Dashjr
a4e6ae101a Only GetAdjustedTime once for the retry loop 2011-10-03 23:41:47 -04:00
Gavin Andresen
15f3ad4dbd Framework for banning mis-behaving peers 2011-09-21 12:49:53 -04:00
Pieter Wuille
88367a5fb8 SocketHandler thread can be detached 2011-09-19 13:08:22 +02:00
Gavin Andresen
9406696578 Fix AddAddress cs_mapaddresses/db transaction deadlock 2011-09-06 20:28:15 -04:00
Gavin Andresen
b53e277ba1 Stay connected to seed nodes; disconnecting causes problems if you are trying to make the initial blockchain download. 2011-09-02 12:25:25 -04:00
Gavin Andresen
86fd7c5af6 Give hard-coded seed nodes a random last-seen time, to randomize order they're tried. 2011-09-02 11:01:45 -04:00
Daniel Folkinshteyn
bca179e8bd Update the list of seednodes.
Nodes culled from MagicalTux's database of bitcoin nodes,
http://dump.bitcoin.it/misc/
by version and longevity, and tested for connectivity.
2011-09-02 00:02:45 -04:00
Gavin Andresen
dd7868364d Merge branch 'code-cleanup' of git://github.com/muggenhor/bitcoin 2011-09-01 11:52:07 -04:00
Matt Corallo
b4ada906c0 Upgrade dependancies and tweak build process.
* Upgrade to use miniupnpc 1.6
* Upgrade to wxWidgets 2.9.2
* Upgrade to Bost 1.47 for Win32 Builds
2011-08-23 13:00:34 -04:00
Giel van Schijndel
99860de3c9 Make some global variables less-global (static)
Explicitly make these global variables less-global to reduce the maximum
scope of this global state.

In my experience global variables tend to be a major source of bugs. As
such the less accessible they are the less likely they are to be the
source of a bug.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2011-08-19 07:24:37 +02:00
Gavin Andresen
498a2c9b16 Merge pull request #458 from TheBlueMatt/copyright
Unify copyright notices.
2011-08-11 10:34:29 -07:00
Venkatesh Srinivas
ec93a0e219 Test for SO_NOSIGPIPE rather than assuming all BSDs support it.
Signed-off-by: Jeff Garzik <jgarzik@exmulti.com>
2011-08-10 22:36:20 -04:00
Gavin Andresen
9f0ac16942 Do-nothing MapPort() ifndef USE_UPNP. fixes #450 2011-08-09 12:38:17 -04:00
Matt Corallo
b2120e223a Unify copyright notices.
To a variation on:
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2011 The Bitcoin developers
2011-08-09 13:32:52 +02:00
Johannes Henninger
1565698169 Identify as "Bitcoin + version number" when mapping UPnP port
Makes Bitcoin identify itself as "Bitcoin + version number" instead of
the nondescript "libminiupnpc" when forwarding a port via UPnP.
2011-08-01 16:34:59 +02:00
Stéphane Gimenez
d655a26c9d Single DB transaction for addresses from DNS seeds 2011-07-14 03:50:06 +02:00
Patrick Varilly
8c41469140 Single DB transaction for all addresses in a message
Cuts disk activity at startup immensely
2011-07-14 03:29:07 +02:00
Giel van Schijndel
858cebed7d fix warning: unused variable 'X' [-Wunused-variable]
Remove several unused variables.

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2011-07-13 05:10:15 +02:00
Giel van Schijndel
d7f1d200ab fix warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
Don't check for a negative parameter count, because not only will it
never happen, it doesn't make any sense either.

Invalid sockets (as returned by socket(2)) are always exactly -1 (not
just negative as negative file descriptors are technically not
prohibited by POSIX) on POSIX systems.  Since we store them in SOCKET
(unsigned int), however, that really is ~0U (or MAX_UINT) which happens
to be what INVALID_SOCKET is already defined to, so an additional check
for being negative is not only unnecessary (unsigned integers aren't
*ever* negative) its redundant as well (the INVALID_SOCKET comparison is
enough).

Signed-off-by: Giel van Schijndel <me@mortis.eu>
2011-07-13 05:07:44 +02:00
Matt Corallo
fa105b1d3a Added a couple minor things to match newer build process.
This adds the relevent patches which are applied to wx,
and updates for cross compiling.
2011-07-05 00:59:00 +02:00
Matt Corallo
013df1cc3b Give more detailed error messages for connection failure. 2011-07-02 13:25:18 +02:00
Jeff Garzik
b73ab2d885 Merge pull request #368 from TheBlueMatt/dnsseed
Only use dnsseeds when not on testnet.
2011-07-01 16:33:28 -07:00
Matt Corallo
ce8f78a7bb Only use dnsseeds and static seeds when not on testnet. 2011-07-01 17:33:19 +02:00
Pieter Wuille
4973174534 Limit response to getblocks to half of output buffer size
Introduce SendBufferSize() and ReceiveBufferSize(), and limit
the blocks sent as response to the "getblocks" message to
half of the active send buffer size.
2011-07-01 09:39:44 +02:00
Jeff Garzik
44d16327c1 Merge pull request #367 from TheBlueMatt/dnsseed
Add new DNSSeed dnsseed.bluematt.me.
2011-06-30 14:51:55 -07:00
Matt Corallo
f03c31db82 Add new DNSSeed dnsseed.bluematt.me.
This seed will pull a random set of 20 nodes from the network which
are tested to be online instead of a static list.
2011-06-30 23:42:59 +02:00
Joerie de Gram
ecd3e728b7 Fix connection failure debug output 2011-06-28 22:34:52 +02:00
Pieter Wuille
64c7ee7e6b CWallet class
* A new class CKeyStore manages private keys, and script.cpp depends on access to CKeyStore.
* A new class CWallet extends CKeyStore, and contains all former wallet-specific globals; CWallet depends on script.cpp, not the other way around.
* Wallet-specific functions in CTransaction/CTxIn/CTxOut (GetDebit, GetCredit, GetChange, IsMine, IsFromMe), are moved to CWallet, taking their former 'this' argument as an explicit parameter
* CWalletTx objects know which CWallet they belong to, for convenience, so they have their own direct (and caching) GetDebit/... functions.
* Some code was moved from CWalletDB to CWallet, such as handling of reserve keys.
* Main.cpp keeps a set of all 'registered' wallets, which should be informed about updates to the block chain, and does not have any notion about any 'main' wallet. Function in main.cpp that require a wallet (such as GenerateCoins), take an explicit CWallet* argument.
* The actual CWallet instance used by the application is defined in init.cpp as "CWallet* pwalletMain". rpc.cpp and ui.cpp use this variable.
* Functions in main.cpp and db.cpp that are not used by other modules are marked static.
* The code for handling the 'submitorder' message is removed, as it not really compatible with the idea that a node is independent from the wallet(s) connected to it, and obsolete anyway.
2011-06-15 11:05:55 +02:00
Jeff Garzik
19ea44208f Merge pull request #226 from jordanlewis/betterheaders
Optimize header dependencies; improve Makefile dependency graph
2011-06-14 02:05:57 -07:00
Pieter Wuille
76d660ebd3 Faster timeout when connecting
Use non-blocking connects, and a select() call to wait a predefined
time (5s by default, but configurable with -timeout) for either
success or failure. This allows much more connections to be tried
per time unit.

Based on a patch by phantomcircuit.
2011-06-12 00:29:05 +02:00
Matt Corallo
c6710c7a70 Fix CPU Usage bug when using -nolisten and have no connections. 2011-06-07 00:54:41 +02:00
Doug Huff
482cb65690 Fix rfc1918 and rfc3927 compliance for ignoring non-internet-routable hosts. 2011-06-02 14:46:41 -05:00
Pieter Wuille
e104c79374 Bugfix for dnsseed introduced by dnslookup 2011-06-02 16:22:49 +02:00
Jeff Garzik
112262cb24 Merge pull request #221 from gavinandresen/portoption
-port option to listen on arbitrary port
2011-05-16 22:29:28 -07:00
Jordan Lewis
fdd7d04744 Only include strlcpy.h when we have to 2011-05-15 22:23:42 -05:00
Jordan Lewis
edd309e537 Only include init.h when we have to 2011-05-15 22:23:37 -05:00
Jordan Lewis
40c2614ef4 Only include net.h when we have to 2011-05-15 22:19:17 -05:00
Jordan Lewis
1512d5ce64 Only include db.h when we have to. 2011-05-15 22:19:16 -05:00
Jordan Lewis
f23f9a03c8 Only include irc.h when needed 2011-05-15 22:19:16 -05:00
Gavin Andresen
00bcfe0b7e -port option to listen on arbitrary port 2011-05-15 12:36:21 -04:00
Wladimir J. van der Laan
223b6f1ba4 make bitcoin include files more modular 2011-05-15 12:04:20 +02:00
Pieter Wuille
545a679aed bugfix in dnslookup code: didn't compile in mingw 2011-05-14 18:13:58 +02:00
Pieter Wuille
a6a5bb7c20 Support for name lookups in -connect and -addnode
* A new option -dns is introduced that enables name lookups in
  -connect and -addnode, which is not enabled by default,
  as it may be considered a security issue.
* A Lookup function is added that supports retrieving one or
  more addresses based on a host name
* CAddress constructors (optionally) support name lookups.
* The different places in the source code that did name lookups
  are refactored to use NameLookup or CAddress instead (dns seeding,
  irc server lookup, getexternalip, ...).
* Removed ToStringLog() from CAddress, and switched to ToString(),
  since it was empty.
2011-05-10 23:49:30 +02:00
Jaromil
84c3fb07b0 directory re-organization (keeps the old build system)
there is no internal modification of any file in this commit

files are moved into directories according to established standards in
sourcecode distribution; these directories contain:

 src - Files that are used in constructing the executable binaries,
       but are not installed.

 doc - Files in HTML and text format that document usage, quirks of
       the implementation, and contributor checklists.

 locale - Files that contain human language translation of strings
          used in the program

 contrib - Files contributed from distributions or other third party
 	   implementing scripts and auxiliary programs
2011-04-23 12:10:25 +02:00
Renamed from net.cpp (Browse further)