Commit graph

290 commits

Author SHA1 Message Date
Dave Collins
8c981e4ef2
server: Use local addr var in version handler.
This modifies the OnVersion handler for server peers to use a local
variable for the remote address of the peer in order to avoid grabbing
the mutex multiple times.

There are no functional changes.

Backported from Decred.
2018-09-20 22:32:59 -05:00
Dave Collins
c8b9fab820
server: Only advertise local addr when current.
This changes the server peers OnVersion handler to only advertise the
server as a viable target for inbound connections when the server
believes it is close the best known tip.

Backported from Decred.
2018-09-20 22:32:41 -05:00
Dave Collins
d2c7892aa4
server: Use local inbound var in version handler.
This modifies the OnVersion handler for server peers to use a local
variable for the inbound status of the peer in order to avoid grabbing
the mutex multiple times.

While here, it also does some light cleanup.  There are no functional
changes.

Backported from Decred.
2018-09-20 22:32:16 -05:00
Dave Collins
4b20d4f86a
server: Update addrmgr services on outbound conns.
This adds code to update the address manager services for a known
address to the services advertised by peers when they are connected to
via an outbound connection.  It is only done for outbound connections to
help prevent malicious behavior from inbound connections.

Backported from Decred.
2018-09-20 22:31:50 -05:00
Dave Collins
9151ebc90b
server: Reject outbound conns to non-full nodes.
This modifies the server connection code to reject outbound peers that
do not offer full node services.
2018-09-20 22:30:46 -05:00
Dave Collins
7b103e2434
peer: Allow OnVersion callback to reject peer.
This modifies the OnVersion callback to allow a reject message to be
returned in which case the message will be sent to the peer and the peer
will be disconnected.

Backported from Decred.
2018-09-20 22:29:27 -05:00
Dave Collins
118f55233b
peer: Rework version negotiation.
This modifies the negotiation logic to ensure the callback has the
opportunity to see the message before the peer is disconnected and
improves the error handling when reading the remote version message.

It also has the side effect of ensuring the protocol version is
negotiated before sending reject messages with the exception of the
first message not being a version message since negotiation is not
possible in that case.

This is being changed because it is useful for the server to see the
message regardless in order to have the opportunity to things such as
update the address manager and reject peers that don't have desired
services.

Backported from Decred.
2018-09-20 22:26:36 -05:00
qshuai
badf5453e9 server: Fix struct name mismatch 2018-09-08 22:34:41 +08:00
Olaoluwa Osuntokun
222a6dac0d
server: fix panic bug when looking for cf checkpoint cache intersection w/ chain
In this commit, we fix a panic bug that can arise when we attempt to
process a cf checkpoint message from a remote peer. Before this commit,
if the size of the checkpoint cache was large than the number of
checkpoints requested by the peer, we would panic with an out of bounds
error. In order to prevent, this we'll now use the size of the requested
set of hashes as our bound to ensure that we don't panic.
2018-08-27 17:49:45 -07:00
Olaoluwa Osuntokun
c8e6363e22
server: modify locking in OnGetCFCheckpt to allow for read concurrency
In this commit, we modify the locking scheme when serving cf checkpoints
for peers to allow the server to serve multiple peers at the same time.
Before this commit, we would first grab the write lock, check to see for
expansion, then release the read lock. In this commit we reverse this
and instead will grab the read lock, and upgrade to the write lock if we
need to actually expand the size of the cache.
2018-08-27 17:46:41 -07:00
Conner Fromknecht
ae733e7291
server: switch TrickleTimeout -> TrickleInterval 2018-08-23 22:55:21 -07:00
Olaoluwa Osuntokun
bb912b6e03
Merge pull request #1222 from halseth/trickle-timeout
config/peer: make trickleTimeout configurable
2018-08-22 19:39:33 -07:00
Olaoluwa Osuntokun
f899737d7f
Merge pull request #1169 from stevenroose/filteradd
server: Fix bug disconnecting peer on filteradd
2018-08-09 17:06:19 -07:00
Conner Fromknecht
90c2094cbd
server: always reply with get headers
backport of https://github.com/decred/dcrd/pull/1295
2018-07-31 21:15:02 -07:00
Johan T. Halseth
08619220b4
config/peer: make trickleTimeout configurable 2018-07-24 12:59:44 +02:00
Olaoluwa Osuntokun
5e86c37411
server: fix bug in cf checkpoint serving
In this commit, we fix a bug in the way that we previously attempted to
server cfcheckpoints. In the prior version we would never actually
fetch the current length of the cache. As a result, after the first time
the checkpoints were fetched, we would always continually grow the
cache rather than using what's there if sufficient.

In this commit, we fix this behavior by always checking the length, then
either keeping the rite lock, or downgrading to a read lock if the size
was sufficient.
2018-07-16 16:31:11 -07:00
Olaoluwa Osuntokun
f7366fb51b
server: ensure we only fetch filters we know of 2018-07-14 12:20:20 -07:00
Steven Roose
fbe1bfa659 server: print full name of cf index in main log 2018-07-06 14:40:27 -05:00
Jim Posen
4d0e856ea1 server: Handler for getcfcheckpt messages. 2018-05-23 16:46:15 -07:00
Jim Posen
4c991c8783 wire: Populate cfheaders message with filter hashes instead of headers. 2018-05-23 16:46:15 -07:00
Jim Posen
175af18043 multi: Modify CFHeaders message to have a PrevFilterHeader field. 2018-05-23 16:46:15 -07:00
Jim Posen
7a53a05878 multi: Redefine GetCFHeaders to have StartHeight and StopHash. 2018-05-23 16:46:15 -07:00
Jim Posen
daac60675e multi: Redefine GetCFilters to have StartHeight and StopHash. 2018-05-23 16:46:15 -07:00
Jim Posen
621f347929 wire: Remove cftypes and getcftypes commands. 2018-05-23 16:46:15 -07:00
Olaoluwa Osuntokun
5291c455c2 server: properly set feeEstimator in newServer 2018-05-23 16:46:15 -07:00
Daniel Krawisz
47113d428c It is now possible to save and restore the state of the FeeEstimator
and the server searches the database for a previous state to load
when the program is turned on.
2018-05-23 16:46:15 -07:00
Daniel Krawisz
4fd446028f Enable estimatefee rpc command. 2018-05-23 16:46:15 -07:00
Daniel Krawisz
1333ad7f78 FeeEstimator added to server. Mempool alerts the fee estimator of
new txs that it observes. The block manager alerts the fee estimator
of new and orphaned blocks.

Check for invalid state and recreate FeeEstimator if necessary.
2018-05-23 16:46:15 -07:00
Olaoluwa Osuntokun
10432160d5 multi: rebase to upstream, update API's 2018-05-23 16:46:15 -07:00
Alex
e0a357abb5 server: add TODO for querying supported filter types 2018-05-23 16:46:15 -07:00
Alex
c7e7acc7fd multi: use hidden varint for cftypes count; make filter type enum, not uint8 2018-05-23 16:46:15 -07:00
Alex
5772bdde86 server: add OnGetCFTypes callback to serverPeer 2018-05-23 16:46:15 -07:00
Alex
621c73dad1 multi: change cfilter Extended bool to FilterType uint8
The cfilter BIP specifies that the filter type is a uint8. The
current code encodes it correctly on the wire, but everywhere else,
it's treated as a boolean (false for basic filter, true for
extended). This commit corrects that to account for possible
additional filter types in the future. All package changes are
done in one commit as they're all interdependent. The following
packages are updated:

* blockchain/indexers
* btcjson
* peer
* wire
* main (server.go and rpcserver.go)
2018-05-23 16:46:15 -07:00
Alex
c5c392c5c5 server: init rpcserver with cfindex 2018-05-23 16:46:15 -07:00
Alex
6589cffb19 server: change logging in OnGetCFilter to be less verbose 2018-05-23 16:46:15 -07:00
Alex
92f1de6dd9 Fix case where 0 headers are retrieved. 2018-05-23 16:46:15 -07:00
Alex
dabb8000fb Add Extended flag to cfilter and cfheaders messages 2018-05-23 16:46:15 -07:00
Alex
936caad9c2 Add last blockhash to cfheaders and blockhash to cfilter messages 2018-05-23 16:46:15 -07:00
Alex
ba4a2f77a5 wire/server: allocate hash once per loop to prevent overwriting 2018-05-23 16:46:15 -07:00
Alex
29b5ece196 Changed getcfheaders/cfheaders messages to get multiple headers. 2018-05-23 16:46:15 -07:00
Alex
8ad7aa5d5d Rename CFilterHeader to CFHeader on P2P side; fix some bugs/tests 2018-05-23 16:46:15 -07:00
pedro martelletto
b8c3be740f Add CFilterHeader p2p counterparts 2018-05-23 16:46:15 -07:00
Alex
6102e129c5 Fixed a couple of bugs and added --dropcfindex option 2018-05-23 16:46:15 -07:00
pedro martelletto
cdb3d44fa8 p2p needs a new message to return committed filters 2018-05-23 16:46:15 -07:00
pedro martelletto
71c421db66 Differentiate between basic/extended filters in p2p/RPC 2018-05-23 16:46:15 -07:00
pedro martelletto
396d28955c better separation between filters; comments 2018-05-23 16:46:15 -07:00
pedro martelletto
6e5f650be9 CBFilter -> CFilter, discussed with davec@ 2018-05-23 16:46:15 -07:00
pedro martelletto
a77b1e00d5 FilterByBlockHash(), pointed out by davec@ 2018-05-23 16:46:15 -07:00
pedro martelletto
43bf8db793 Look up filters from p2p GetCBF message 2018-05-23 16:46:15 -07:00
pedro martelletto
3b0038093a Hook CBF indexer to server code 2018-05-23 16:46:15 -07:00