- dropped the dev-dependency on
once_cell
- due to the use of
std::sync::{LazyLock, OnceLock}
in tests and examples, the MSRV is bumped to 1.80
Node::toggle_listener
OnDisconnect::enable_disconnect
is now::enable_on_disconnect
Node::listening_addr
is now anasync fn
Node::start_listening
(::toggle_listener
is now used instead)
Writing::INITIAL_BUFFER_SIZE
- renamed
Config::listener_ip
to::listener_addr
- dropped the dependency on
async_trait
in favor of Rust 1.75 features - bumped the MSRV to 1.75
Config::{allow_random_port, desired_listening_port}
once_cell
is now only a dev dependency- due to the use of
std::sync::OnceLock
, the MSRV is increased to 1.70 protocols::Disconnect
was renamed to::OnDisconnect
Disconnect::handle_disconnect
is nowOnDisconnect::on_disconnect
Config::connection_timeout_ms
protocols::OnConnect
- increased the minimum required version of
tokio
to1.24
due to RUSTSEC-2023-0001
ConnectionInfo
, which contains basic information related to an active connectionNode::{connection_info, connection_infos}
, which returnConnectionInfo
for the given address or for all of the active connectionsStats::created
, which registers the creation time of the node and the connections
- the
Stats
no longer track generic failures
KnownPeers
(in favor ofConnectionInfo
, which containsStats
)Node::known_peers
Stats::failures
Node::connect_using_socket
, which can be used to create outbound connections using pre-configured, user-supplied socketsNode::start_listening
which makes the node listen for inbound connections
- the nodes no longer start listening for inbound connections automatically
Node::new
is no longerasync
and doesn't return anio::Result
anymore
Config::bound_addr
(Node::connect_using_socket
is much more versatile)
Config::bound_addr
- downgraded the
WARN
log in caseNode::disconnect
is called on a nonexistent connection toDEBUG
and made it more clear
Reading
no longer triggers an additional noop call toNode::disconnect
in case of read errors- in some rare cases, it was possible for protocol handler tasks to not be able to notify their owning tasks that they were complete; this is now handled gracefully
- the same was done with connection handlers
Node::new
now takesConfig
instead ofOption<Config>
- renamed
Writing::{send_direct_message, send_broadcast}
to::{unicast, broadcast}
Reading::codec
andWriting::codec
now also have aside
parameter
Handshake::{take_stream, return_stream}
Config::{inbound_queue_depth, initial_read_buffer_size}
were moved toReading::{MESSAGE_QUEUE_DEPTH, INITIAL_BUFFER_SIZE}
Config::max_handshake_time_ms
was moved toHandshake::TIMEOUT_MS
Config::outbound_queue_depth
was moved toWriting::MESSAGE_QUEUE_DEPTH
Writing::send_direct_message
now returns anio::Result<oneshot::Receiver<io::Result<()>>>
instead ofio::Result<oneshot::Receiver<bool>>
- several objects and trait methods indended to not be used outside of the crate were made private
Reading::map_codec
is now generic overAsyncRead
- use
OnceBox
instead ofOnceCell
in the protocols - the
Reading
protocol should now be a bit faster to start reading
- nodes that implement neither
Reading
norWriting
no longer instantly disconnect from peers
Config::invalid_read_delay_secs
(not that practical)Reading::take_reader
Writing::take_writer
- the fuzz tests (as the buffering is outsourced now)
- fixed a panic when a protocol handler can't be triggered
- some protocol plumbing (shouldn't affect public APIs)
Connection::{addr, side}
Handshake::{borrow_stream}
Reading::{codec, take_reader, Codec}
Writing::{codec, take_writer, Codec}
- added
PartialEq
andEq
toConnectionSide
- the
Reading
andWriting
protocols now take advantage oftokio-util
'sDecoder
andEncoder
traits - the signature od
Writing::write_to_stream
has changed - the protocol handler objects and
ReturnableItem
are no longerpub
(onlypub(crate)
) Connection
's fields are no longerpub
Connection::{reader, writer}
Reading::{process_buffer, read_from_stream, read_message}
Writing::write_message
- the
handshaking
test (thenoise_handshake
example is much more comprehensive)
- a new method,
Node::is_connecting
- removed
Config::protocol_handler_queue_depth
- a
cargo-fuzz
powered fuzz test - extended the docs and added links
- MSRV in the TOML
- bumped the
snow
dev-dependency to0.9
- marked some obvious inlining targets as
#[inline]
- made
Writing::send_broadcast
return anio::Result<()>
instead of nothing - made
Writing::send_direct_message
return anio::Result<oneshot::Receiver<bool>>
instead ofio::Result<()>
- made
Writing::send_direct_message
return anio::ErrorKind::NotConnected
if the given address is not connected
- bumped the
parking_lot
dependency to0.12
- improved the clarity of a few logs
Node::new
will now conclude only once the listening task has started (if listening is enabled)- made protocol-enabling methods async to have better control over their progress
- made
Node::listening_addr
return the configured IP (instead of always the local one)
- updated Rust edition to 2021
- increased the minimum required version of
tokio
to1.14
- increased the minimum required version of
tracing-subscriber
(dev-dependency) to0.3
- some new
clippy
lints
Reading::process_message
no longer has a default dummy impl
- set the
tokio
version to1.10
due to theRUSTSEC-2021-0072
security advisory
- moved
Node::{send_broadcast, send_direct_message}
toWriting
- the way the protocols are structured
- renamed
Handshaking
toHandshake
- the
bytes
dependency (no longer mandatory)
- an off-by-one in
Reading::read_from_stream
found by fuzzing
- the signature of
Reading::read_message
was simplified Reading::read_message
errors can now be non-fatal too
- the connection buffers are now elastic/growable, i.e. they don't immediately allocate their configured size
Writing::write_message
now expects anio::Write
instead of a&mut [u8]
, and it returnsio::Result<()>
- the
NodeConfig
members with names starting withconn_
lose this prefix NodeConfig
was renamed toConfig
- the
fxhash
dependency (no difference in performance) NodeConfig::conn_write_buffer_size
(no longer needed or useful)
- the
Connection
no longer carries a reference to theNode
- the
ReturnableConnection
type alias was replaced with a more genericReturnableItem<T, U>
- an
ERROR
log when a write is attempted withWriting
protocol disabled
KnownPeers::{get, snapshot}
- the
Node
now tracks its internal failures (currently full channel errors)
- the node no longer has to listen for connections
- some
ErrorKind::Other
errors were made more specific - merged
NodeStats
withPeerStats
- the peer stats no longer follow the number of connections
PeerStats
andNodeStats
(merged intoStats
)KnownPeers::{read, register_connection, write}
- a new protocol,
Disconnect
Node::send_broadcast
doesn't return a value anymore- the node no longer waits when a per-connection inbound queue is full; the message gets dropped
- downgraded the disconnect log from
INFO
toDEBUG
- 2
ERROR
logs now display the missing node id
Node::{send_direct_message, send_broadcast}
are now non-asyncNodeConfig::conn_outbound_queue_depth
was increased from16
to64
- the node will now recognize a zero-read as EOF and break the related connection
- stream read errors are now properly checked against
NodeConfig::fatal_io_errors
- removed one redundant
connecting
registration when initiating connections - the node is now guarded against connection spam by making connection responses concurrent
Node::num_connecting
- use atomics in
PeerStats
- improved the accounting of connecting (but not yet connected) peers
PeerStats.{added, last_connected}
- not super-interesting
KnownPeers::register_failure
won't overflow anymore, as it is saturating at its maximum
- the default
tokio
runtime feature is now justrt
(which is compatible withrt-multi-thread
) - the
ProtocolHandler
is now created from just ampsc::Sender<ReturnableConnection>
- the
tokio
dependency has thert-multi-thread
feature enabled by default in order to not fail to build in crates that don't use it on their own
NodeConfig.fatal_io_errors
that specifies which IO errors should break connections
- the list of read errors considered fatal is longer
- connections are now broken on write errors considered fatal too
- the
io::ErrorKind
s returned byNode::connect
are more specific
- the default value for
NodeConfig.conn_inbound_queue_depth
is now 64 instead of 256 - adjusted dependency features further
- (internal) automatically test for potential memleaks
- adjusted dependency features
Handshaking::perform_handshake
that has no default implementationconnections::Connection
is now re-exported
Handshaking
now requiresSelf: Clone + Send + Sync + 'static
Handshaking::enable_handshaking
now has a default implementationNodeConfig.max_protocol_setup_time_ms
is nowNodeConfig.max_handshake_time_ms
and only applies toHandshaking
NodeStats.connections
and the relatedNodeStats::register_connection
(unused)
- the
fixed_length_crusaders
example needed a bump to the defaultmax_protocol_setup_time_ms
introduced in0.16.2
connections::ConnectionSide
is now re-exported, i.e. it can be imported withuse pea2pea::ConnectionSide
NodeConfig.max_protocol_setup_time_ms
, which restricts the amount of time that a connection can take to enact all its protocols; set to 3s by default
- the reading loop in the default
Reading::enable_reading
impl is now delayed until the connection is fully established
- in the default
Reading::enable_reading
impl, the message processing task is now spawned before the message reading task
- there is now an additional anti-self-connect safeguard in
Node::connect
Reading::read_from_stream
andWriting::write_to_stream
are now generic overAsyncRead
andAsyncWrite
respectively and their arguments were extendedReading::read_from_stream
now returnsio::Result<usize>
instead ofio::Result<()>
Connection.reader
now containsOption<OwnedReadHalf>
Connection.writer
now containsOption<OwnedWriteHalf>
connections::{ConnectionReader, ConnectionWriter}
NodeConfig.listener_ip
- the default IP the node listens at is now
Ipv4Addr::UNSPECIFIED
instead ofIpv4Addr::LOCALHOST
ReadingHandler
andWritingHandler
are now a commonProtocolHandler
applicable also toHandshaking
NodeConfig.{reading_handler_queue_depth, writing_handler_queue_depth}
were merged into.protocol_handler_queue_depth
- instead of
Node
, keep a copy of itsSpan
inConnectionReader
&ConnectionWriter
- renamed
NodeConfig.invalid_message_penalty_secs
to.invalid_read_delay_secs
Node::{reading_handler, writing_handler}
methods are now private
Node::shutdown
now also shuts down the handshaking task ifHandshaking
is enabled- the
Node
no longer panics on attempts to send to dying connections - corrected the doc on
NodeConfig.invalid_message_penalty_secs
(now.invalid_read_delay_secs
)
- the
Node
can no longer connect to its own listening address
- exposed previously public
Node
members as public methods Connection
now drops its tasks in reverse order
Node::shut_down
that performs a full shutdown of the node
Pea2Pea::node
now returns a&Node
- tweaked a few logs
Connection
s now shut their associated tasks down when dropped- critical protocol failures no longer cause panics in their main tasks
- some edge cases in protocol handling
NodeConfig.max_connections
with a default value of 100
- updading
PeerStats
no longer implicitly adds an entry
PeerStats.last_connected
no longer shows a timestamp if there were no connectionsPeerStats.times_connected
no longer shows one extra connectionNode::connect
is now guarded against overlapping connection attempts
NodeConfig.max_allowed_failures
- not used internally, not necessarily needed, easy to handle on user sidePeerStats.last_seen
- ditto
Writing::write_to_stream
with a default implementation- a new example with fixed-length messages
- average throughput is now displayed at the end of the benchmark in
benches
- renamed
Node::initiate_connection
to::connect
Writing::write_message
now requires aSocketAddr
and&mut [u8]
instead of&mut ConnectionWriter
- a test with a duplicate connection
- an example in the README
- refactored code around establishing connections
Connections::disconnect
is now::remove
NodeStats::register_connection
now happens as soon as the connection is barely establishedKnownPeers::add
doesn't occur before the connection is fully establishedConnection
now carries its task handles in a singleVec
Connection
no longer usesOnceCell
internally (Option
is used instead)Connection
now carriesConnectionReader
andConnectionWriter
while the procols are being enabledHandshakingObjects
,ReadingObjects
, andWritingObjects
are now merged intoReturnableConnection
Connection::send_message
(unused)
- improved and extended some logs
- added more comments
- a small refactoring in
Node::new
- the listening task handle is now kept within the
Node
- a new
clippy
lint introduced in Rust 1.49
ConnectionWriter
object was isolated fromConnection
Writing
protocol was introducedNodeConfig
has gained some new fields
- the crate's structure and exports were overhauled
connection
module was merged intoconnections
Messaging
protocol becameReading
InboundHandler
becameReadingHandler
MessagingObjects
becameReadingObjects
- protocol handlers now carry handles to the tasks they have spawned