aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* | Merge #9930: Trivial: Correct indentation and bracingWladimir J. van der Laan2017-04-261-79/+79
|\ \ | | | | | | | | | | | | | | | 31a14d4 Correct indentation and remove unnecessary braces (Matthias Grundmann) Tree-SHA512: c0e827ec4474133c7674254dfd13f59608820cd639debc7759bddae71d73451645fcfe14384f343d08f74d69ac3922bafc12a514f3b790ae2bf9271aa67d5f36
| * | Correct indentation and remove unnecessary bracesMatthias Grundmann2017-04-021-79/+79
| | |
* | | Merge #9665: Use cached [compact] blocks to respond to getdata messagesWladimir J. van der Laan2017-04-131-18/+36
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | b49ad44 Add comment about cs_most_recent_block coverage (Matt Corallo) c47f5b7 Cache witness-enabled state with recent-compact-block-cache (Matt Corallo) efc135f Use cached [compact] blocks to respond to getdata messages (Matt Corallo) Tree-SHA512: ffc478bddbf14b8ed304a3041f47746520ce545bdeffa9652eff2ccb25c8b0d5194abe72568c10f9c1b246ee361176ba217767af834752a2ca7263d292005e87
| * | | Add comment about cs_most_recent_block coverageMatt Corallo2017-02-231-0/+1
| | | |
| * | | Cache witness-enabled state with recent-compact-block-cacheMatt Corallo2017-02-231-2/+6
| | | |
| * | | Use cached [compact] blocks to respond to getdata messagesMatt Corallo2017-02-231-17/+30
| | | |
* | | | Merge #9725: CValidationInterface CleanupsWladimir J. van der Laan2017-04-101-12/+14
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | b1a6d4c Take a CTransactionRef in AddToWalletIfInvolvingMe to avoid a copy (Matt Corallo) 1c95e2f Use std::shared_ptr instead of boost::shared_ptr in ScriptForMining (Matt Corallo) 91f1e6c Remove dead-code tracking of requests for blocks we generated (Matt Corallo) acad82f Add override to functions using CValidationInterface methods (Matt Corallo) e6d5e6c Hold cs_wallet for whole block [dis]connection processing (Matt Corallo) 461e49f SyncTransaction->TxAddedToMempool/BlockConnected/Disconnected (Matt Corallo) f404334 Handle SyncTransaction in ActivateBestChain instead of ConnectTrace (Matt Corallo) a147687 Keep conflictedTxs in ConnectTrace per-block (Matt Corallo) d3167ba Handle conflicted transactions directly in ConnectTrace (Matt Corallo) 29e6e23 Make ConnectTrace::blocksConnected private, hide behind accessors (Matt Corallo) 822000c Add pblock to connectTrace at the end of ConnectTip, not start (Matt Corallo) f5e9a01 Include missing #include in zmqnotificationinterface.h (Matt Corallo) Tree-SHA512: 8893d47559da3b28d2ef7359768547cba8a4b43b6f891d80f5848f995a84b1517bfb0f706fdc8cd43f09a1350349eb440d9724a59363ab517dfcc4fcb31b2018
| * | | | SyncTransaction->TxAddedToMempool/BlockConnected/DisconnectedMatt Corallo2017-04-071-12/+14
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This simplifies fixing the wallet-returns-stale-info issue as we can now hold cs_wallet across an entire block instead of only per-tx (though we only actually do so in the next commit). This change also removes the NOT_IN_BLOCK constant in favor of only passing the CBlockIndex* parameter to SyncTransactions when a new block is being connected, instead of also when a block is being disconnected. This change adds a parameter to BlockConnectedDisconnected which lists the transactions which were removed from mempool due to confliction as a result of this operation. While its somewhat of a shame to make block-validation-logic generate a list of mempool changes to be included in its generated callbacks, fixing this isnt too hard. Further in this change-set, CValidationInterface starts listening to mempool directly, placing it in the middle and giving it a bit of logic to know how to route notifications from block-validation, mempool, etc (though not listening for conflicted-removals yet).
* | | | Merge #10135: [p2p] Send the correct error code in reject messagesWladimir J. van der Laan2017-04-101-3/+3
|\ \ \ \ | |/ / / |/| | | | | | | | | | | | | | | 5d08c9c Send the correct error code in reject messages (John Newbery) Tree-SHA512: 0cd3ef3ae202584b138cc0bbfba4125635822e0c5a755fb9276a604b39286959ab22dabc3104aa5d7e71358cd69d965de2a333ff04bf3e8ed43cf0296ac01264
| * | | Send the correct error code in reject messagesJohn Newbery2017-03-311-3/+3
| | | |
* | | | Change LogAcceptCategory to use uint32_t rather than sets of strings.Gregory Maxwell2017-04-011-69/+71
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes the logging categories to boolean flags instead of strings. This simplifies the acceptance testing by avoiding accessing a scoped static thread local pointer to a thread local set of strings. It eliminates the only use of boost::thread_specific_ptr outside of lockorder debugging. This change allows log entries to be directed to multiple categories and makes it easy to change the logging flags at runtime (e.g. via an RPC, though that isn't done by this commit.) It also eliminates the fDebug global. Configuration of unknown logging categories now produces a warning.
* | | No longer allow "free" transactionsAlex Morcos2017-03-031-4/+3
| | | | | | | | | | | | | | | | | | Remove -limitfreerelay and always enforce minRelayTxFee in the mempool (except from disconnected blocks) Remove -relaypriority, the option was only used for the ability to allow free transactions to be relayed regardless of their priority. Both notions no longer apply.
* | | Merge #9720: net: fix banning and disallow sending messages before receiving ↵Wladimir J. van der Laan2017-02-141-49/+68
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | verack d943491 qa: add a test to detect leaky p2p messages (Cory Fields) 8650bbb qa: Expose on-connection to mininode listeners (Matt Corallo) 5b5e4f8 qa: mininode learns when a socket connects, not its first action (Matt Corallo) cbfc5a6 net: require a verack before responding to anything else (Cory Fields) 8502e7a net: parse reject earlier (Cory Fields) c45b9fb net: correctly ban before the handshake is complete (Cory Fields)
| * | | net: require a verack before responding to anything elseCory Fields2017-02-131-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7a8c251901 made this logic hard to follow. After that change, messages would not be sent to a peer via SendMessages() before the handshake was complete, but messages could still be sent as a response to an incoming message. For example, if a peer had not yet sent a verack, we wouldn't notify it about new blocks, but we would respond to a PING with a PONG. This change makes the behavior straightforward: until we've received a verack, never send any message other than version/verack/reject. The behavior until a VERACK is received has always been undefined, this change just tightens our policy. This also makes testing much easier, because we can now connect but not send version/verack, and anything sent to us is an error.
| * | | net: parse reject earlierCory Fields2017-02-131-26/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this change, all messages were ignored until a VERSION message was received, as well as possibly incurring a ban score. Since REJECT messages can be sent at any time (including as a response to a bad VERSION message), make sure to always parse them. Moving this parsing up keeps it from being caught in the if (pfrom->nVersion == 0) check below.
| * | | net: correctly ban before the handshake is completeCory Fields2017-02-131-23/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7a8c251901 made a change to avoid getting into SendMessages() until the version handshake (VERSION + VERACK) is complete. That was done to avoid leaking out messages to nodes who could connect, but never bothered sending us their version/verack. Unfortunately, the ban tally and possible disconnect are done as part of SendMessages(). So after 7a8c251901, if a peer managed to do something bannable before completing the handshake (say send 100 non-version messages before their version), they wouldn't actually end up getting disconnected/banned. That's fixed here by checking the banscore as part of ProcessMessages() in addition to SendMessages().
* | | | Move CNode::addrLocal access behind locked accessorsMatt Corallo2017-02-101-2/+2
| | | |
* | | | Move CNode::addrName accesses behind locked accessorsMatt Corallo2017-02-101-1/+1
| | | |
* | | | Make nTimeBestReceived atomicMatt Corallo2017-02-101-1/+1
| | | |
* | | | Move [clean|str]SubVer writes/copyStats into a lockMatt Corallo2017-02-101-3/+8
| | | |
* | | | net: fix a few races. Credit @TheBlueMattCory Fields2017-02-101-1/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are (afaik) all long-standing races or concurrent accesses. Going forward, we can clean these up so that they're not all individual atomic accesses. - Reintroduce cs_vRecv to guard receive-specific vars - Lock vRecv/vSend for CNodeStats - Make some vars atomic. - Only set the connection time in CNode's constructor so that it doesn't change
* | | Merge #9604: [Trivial] add comment about setting peer as HB peer.Wladimir J. van der Laan2017-02-071-1/+9
|\ \ \ | | | | | | | | | | | | dd5b011 [Trivial] add comment about setting peer as HB peer. (John Newbery)
| * | | [Trivial] add comment about setting peer as HB peer.John Newbery2017-01-201-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a comment to the new logic for setting HB peers based on block validation (and aligns the code below to reflect the comment). It's not obvious why we're checking mapBlocksInFlight. Add a comment to explain.
* | | | Merge #9659: Net: Turn some methods and params/variables constWladimir J. van der Laan2017-02-061-9/+9
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | 0729102 Net: pass interruptMsgProc as const where possible (Jorge Timón) fc7f2ff Net: Make CNetMsgMaker more const (Jorge Timón) d45955f Net: CConnman: Make some methods const (Jorge Timón)
| * | | | Net: pass interruptMsgProc as const where possibleJorge Timón2017-01-311-4/+4
| | | | |
| * | | | Net: Make CNetMsgMaker more constJorge Timón2017-01-311-5/+5
| | |/ / | |/| |
* | | | net: Disallow sending messages until the version handshake is completeCory Fields2017-02-021-3/+3
| | | | | | | | | | | | | | | | This is a change in behavior, though it's much more sane now than before.
* | | | net: deserialize the entire version message locallyCory Fields2017-02-021-27/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This avoids having some vars set if the version negotiation fails. Also copy it all into CNode at the same site. nVersion and fSuccessfullyConnected are set last, as they are the gates for the other vars. Make them atomic for that reason.
* | | | Dont deserialize nVersion into CNode, should fix #9212Matt Corallo2017-02-021-6/+8
|/ / /
* | | Refactor: Remove using namespace <xxx> from src/*.cpp.Karl-Johan Alm2017-01-271-53/+51
| | |
* | | Merge #9594: Send final alert message to older peers after connecting.Wladimir J. van der Laan2017-01-261-0/+6
|\ \ \ | | | | | | | | | | | | 8ff8d21 Send final alert message to older peers after connecting. (Gregory Maxwell)
| * | | Send final alert message to older peers after connecting.Gregory Maxwell2017-01-201-0/+6
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old Bitcoin alert system has long since been retired. ( See also: https://bitcoin.org/en/alert/2016-11-01-alert-retirement ) This change causes each node to send any old peers that it connects with a copy of the final alert. The alert it hardcode cancels all other alerts including other final alerts.
* / / Do not shadow local variable named `tx`.Pavel Janík2017-01-201-2/+2
|/ /
* | Merge #9499: Use recent-rejects, orphans, and recently-replaced txn for ↵Wladimir J. van der Laan2017-01-191-4/+31
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | compact-block-reconstruction c594580 Add braces around AddToCompactExtraTransactions (Matt Corallo) 1ccfe9b Clarify comment about mempool/extra conflicts (Matt Corallo) fac4c78 Make PartiallyDownloadedBlock::InitData's second param const (Matt Corallo) b55b416 Add extra_count lower bound to compact reconstruction debug print (Matt Corallo) 863edb4 Consider all (<100k memusage) txn for compact-block-extra-txn cache (Matt Corallo) 7f8c8ca Consider all orphan txn for compact-block-extra-txn cache (Matt Corallo) 93380c5 Use replaced transactions in compact block reconstruction (Matt Corallo) 1531652 Keep shared_ptrs to recently-replaced txn for compact blocks (Matt Corallo) edded80 Make ATMP optionally return the CTransactionRefs it replaced (Matt Corallo) c735540 Move ORPHAN constants from validation.h to net_processing.h (Matt Corallo)
| * | Add braces around AddToCompactExtraTransactionsMatt Corallo2017-01-161-2/+4
| | |
| * | Consider all (<100k memusage) txn for compact-block-extra-txn cacheMatt Corallo2017-01-101-1/+4
| | |
| * | Consider all orphan txn for compact-block-extra-txn cacheMatt Corallo2017-01-101-0/+2
| | |
| * | Use replaced transactions in compact block reconstructionMatt Corallo2017-01-101-2/+2
| | |
| * | Keep shared_ptrs to recently-replaced txn for compact blocksMatt Corallo2017-01-101-2/+22
| | |
* | | Merge #9561: Wake message handling thread when we receive a new blockPieter Wuille2017-01-161-0/+1
|\ \ \ | | | | | | | | | | | | | | | | 241d893 Wake message handling thread when we receive a new block (Matt Corallo) f13914a Make WakeMessageHandler public (Matt Corallo)
| * | | Wake message handling thread when we receive a new blockMatt Corallo2017-01-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | This forces the message handling thread to make another full iteration of SendMessages prior to going back to sleep, ensuring we announce the new block to all peers before sleeping.
* | | | Merge #9400: Set peers as HB peers upon full block validationPieter Wuille2017-01-151-27/+28
|\ \ \ \ | | | | | | | | | | | | | | | d4781ac Set peers as HB peers upon full block validation (Gregory Sanders)
| * | | | Set peers as HB peers upon full block validationGregory Sanders2016-12-301-27/+28
| | | | |
* | | | | Merge #9486: Make peer=%d log prints consistentWladimir J. van der Laan2017-01-151-3/+3
|\ \ \ \ \ | |_|/ / / |/| | | | | | | | | e6111b2 Make peer id logging consistent ("peer=%d" instead of "peer %d") (Matt Corallo)
| * | | | Make peer id logging consistent ("peer=%d" instead of "peer %d")Matt Corallo2017-01-071-3/+3
| | | | |
* | | | | Merge #9375: Relay compact block messages prior to full block connectionPieter Wuille2017-01-131-41/+161
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 02ee4eb Make most_recent_compact_block a pointer to a const (Matt Corallo) 73666ad Add comment to describe callers to ActivateBestChain (Matt Corallo) 962f7f0 Call ActivateBestChain without cs_main/with most_recent_block (Matt Corallo) 0df777d Use a temp pindex to avoid a const_cast in ProcessNewBlockHeaders (Matt Corallo) c1ae4fc Avoid holding cs_most_recent_block while calling ReadBlockFromDisk (Matt Corallo) 9eb67f5 Ensure we meet the BIP 152 old-relay-types response requirements (Matt Corallo) 5749a85 Cache most-recently-connected compact block (Matt Corallo) 9eaec08 Cache most-recently-announced block's shared_ptr (Matt Corallo) c802092 Relay compact block messages prior to full block connection (Matt Corallo) 6987219 Add a CValidationInterface::NewPoWValidBlock callback (Matt Corallo) 180586f Call AcceptBlock with the block's shared_ptr instead of CBlock& (Matt Corallo) 8baaba6 [qa] Avoid race in preciousblock test. (Matt Corallo) 9a0b2f4 [qa] Make compact blocks test construction using fetch methods (Matt Corallo) 8017547 Make CBlockIndex*es in net_processing const (Matt Corallo)
| * | | | | Make most_recent_compact_block a pointer to a constMatt Corallo2017-01-131-2/+2
| | | | | |
| * | | | | Call ActivateBestChain without cs_main/with most_recent_blockMatt Corallo2017-01-111-4/+14
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | There is still a call to ActivateBestChain with cs_main if a peer requests the block prior to it being validated, but this one is more specifically-gated, so should be less of an issue.
| * | | | Avoid holding cs_most_recent_block while calling ReadBlockFromDiskMatt Corallo2017-01-051-8/+13
| | | | |
| * | | | Ensure we meet the BIP 152 old-relay-types response requirementsMatt Corallo2017-01-051-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to do this, we must call ActivateBestChain prior to responding getdata requests for blocks which we announced using compact blocks. For getheaders responses we dont need code changes, but do note that we must reset the bestHeaderSent so that the SendMessages call re-announces the header in question. While we could do something smarter for getblocks, calling ActivateBestChain is simple and more obviously correct, instead of doing something more similar to getheaders. See-also the BIP clarifications at https://github.com/bitcoin/bips/pull/486