Allow to peers behind NAT to get up to preffered_max connections
If peer has only outbound connections it's mot likely behind NAT and we should not stop it from getting more outbound connections
* wip
* big refactor, regretting doing this now
* PeerAddr everywhere
* cleanup
* fixup server tests
* peers api working for GET, POST is still WIP
* we can now ban/unban peers by ip only (port optional)
* fix: Fix race condition with dandelion_relay peer map and make more semantic
* Fix bug where we don't actually re-read the dandelion_relay variable after refreshing it
If WouldBlock error happens Stratum server drops part of a message to
read or write. This PR inroduces a worker's buffer to store partially
read message which will be completed next time. For write the existing
util function is used.
Fixes#2524
* Allow to have more than min_peers/2 outbound peers
Default value is 8, so we allow only 4 outbound peers, unfortunately if a node is behind NAT it can't get inbound peers and it stucks with 4 peers as maximum.
This PR allows a number of outbound peers to be between min_peers and max_peers/2. Node behind NAT will eventually have just min_peers number of peers.
* Extract into healthy_peers_mix function
* protect rpc_response from None.unwrap
* protect login handler from crashing before current_block_versions has had time to get populated
* protect worker_stats_id finding from None
It was introduced in #2418, it turns out std read_line always appends to
the string, not writes from the beginning, so when we have multiple
workers to read from all messages are concatenated
* outbound connection count
* rustfmt
* display outbound peer count
* rustfmt
* wip - allow connections to exceed max when trying to create new outcound connections
any in excess of total max will be cleaned up subsequently
* fix
* we care about connected outbound peer count when deciding to connect to new peers
Currently we allocate a string in the heap per each worker check (not even
read) and clone message in write. This pr introduces a buffer which is
used for a round of workers check and remove clone in write_message.
Read optimization reduces number of allocations by factor of N (where N
is a number of workers), if N = 1 number of allocations doesn't change.
* fix: avoid duplicate connection
* ignore the duplicate connecting to same peer within 10 seconds
* refactor: use hashmap instead of vector for connecting history
* remove the double checking for already connected peer on connect
* add previous connecting time to the log
* fix a mistake on shrink
* move the now() into the inter loop for accurate time
* change the minimum allowed inverval time from 10s to 30s
* Only update outputs with unconfirmed transactions outstanding
* add further check for Unspent output that have been spent to check_repair
* rename to
* make updating all outputs optional API parameter. do full update before a wallet check, remove unspent->spent check from check process
* rustfmt
* typo
* add recover from phrase option to init
* rustfmt
* don't panic if recover is cancelled, grin-wallet.toml is created but wallet_data dir doesn't yet exits
* rustfmt
* Only update outputs with unconfirmed transactions outstanding
* add further check for Unspent output that have been spent to check_repair
* rename to
* make updating all outputs optional API parameter. do full update before a wallet check, remove unspent->spent check from check process
* rustfmt
* typo
* shutdown the tcpstream when peer connect or accept fail
* remove the unnecessary 3 times retry on peer connecting
* connect/accept are actually handshakings instead of tcpstream connect/accept