![]() |
Bitcoin Core 31.1.0
P2P Digital Currency
|
#include <net.h>
Public Member Functions | |
| V1Transport (NodeId node_id) noexcept | |
| bool | ReceivedMessageComplete () const override EXCLUSIVE_LOCKS_REQUIRED(!m_recv_mutex) |
| Returns true if the current message is complete (so GetReceivedMessage can be called). | |
| Info | GetInfo () const noexcept override |
| Retrieve information about this transport. | |
| bool | ReceivedBytes (std::span< const uint8_t > &msg_bytes) override EXCLUSIVE_LOCKS_REQUIRED(!m_recv_mutex) |
| Feed wire bytes to the transport. | |
| CNetMessage | GetReceivedMessage (std::chrono::microseconds time, bool &reject_message) override EXCLUSIVE_LOCKS_REQUIRED(!m_recv_mutex) |
| Retrieve a completed message from transport. | |
| bool | SetMessageToSend (CSerializedNetMsg &msg) noexcept override EXCLUSIVE_LOCKS_REQUIRED(!m_send_mutex) |
| Set the next message to send. | |
| BytesToSend | GetBytesToSend (bool have_next_message) const noexcept override EXCLUSIVE_LOCKS_REQUIRED(!m_send_mutex) |
| Get bytes to send on the wire, if any, along with other information about it. | |
| void | MarkBytesSent (size_t bytes_sent) noexcept override EXCLUSIVE_LOCKS_REQUIRED(!m_send_mutex) |
| Report how many bytes returned by the last GetBytesToSend() have been sent. | |
| size_t | GetSendMemoryUsage () const noexcept override EXCLUSIVE_LOCKS_REQUIRED(!m_send_mutex) |
| Return the memory usage of this transport attributable to buffered data to send. | |
| bool | ShouldReconnectV1 () const noexcept override |
| Whether upon disconnections, a reconnect with V1 is warranted. | |
| Public Member Functions inherited from Transport | |
| virtual | ~Transport ()=default |
Private Member Functions | |
| CHash256 hasher | GUARDED_BY (m_recv_mutex) |
| uint256 data_hash | GUARDED_BY (m_recv_mutex) |
| bool in_data | GUARDED_BY (m_recv_mutex) |
| DataStream hdrbuf | GUARDED_BY (m_recv_mutex) |
| CMessageHeader hdr | GUARDED_BY (m_recv_mutex) |
| DataStream vRecv | GUARDED_BY (m_recv_mutex) |
| unsigned int nHdrPos | GUARDED_BY (m_recv_mutex) |
| unsigned int nDataPos | GUARDED_BY (m_recv_mutex) |
| const uint256 & | GetMessageHash () const EXCLUSIVE_LOCKS_REQUIRED(m_recv_mutex) |
| int | readHeader (std::span< const uint8_t > msg_bytes) EXCLUSIVE_LOCKS_REQUIRED(m_recv_mutex) |
| int | readData (std::span< const uint8_t > msg_bytes) EXCLUSIVE_LOCKS_REQUIRED(m_recv_mutex) |
| void | Reset () EXCLUSIVE_LOCKS_REQUIRED(m_recv_mutex) |
| bool | CompleteInternal () const noexcept EXCLUSIVE_LOCKS_REQUIRED(m_recv_mutex) |
| std::vector< uint8_t > m_header_to_send | GUARDED_BY (m_send_mutex) |
| The header of the message currently being sent. | |
| CSerializedNetMsg m_message_to_send | GUARDED_BY (m_send_mutex) |
| The data of the message currently being sent. | |
| bool m_sending_header | GUARDED_BY (m_send_mutex) |
| Whether we're currently sending header bytes or message bytes. | |
| size_t m_bytes_sent | GUARDED_BY (m_send_mutex) |
| How many bytes have been sent so far (from m_header_to_send, or from m_message_to_send.data). | |
Private Attributes | |
| const MessageStartChars | m_magic_bytes |
| const NodeId | m_node_id |
| Mutex | m_recv_mutex |
| Lock for receive state. | |
| Mutex | m_send_mutex |
| Lock for sending state. | |
Additional Inherited Members | |
| Public Types inherited from Transport | |
| using | BytesToSend |
| Return type for GetBytesToSend, consisting of: | |
|
explicitnoexcept |
|
inlineprivatenoexcept |
|
overridevirtualnoexcept |
Get bytes to send on the wire, if any, along with other information about it.
As a const function, it does not modify the transport's observable state, and is thus safe to be called multiple times.
| [in] | have_next_message | If true, the "more" return value reports whether more will be sendable after a SetMessageToSend call. It is set by the caller when they know they have another message ready to send, and only care about what happens after that. The have_next_message argument only affects this "more" return value and nothing else. |
Effectively, there are three possible outcomes about whether there are more bytes to send:
The boolean 'more' is true for Yes, false for Blocked, and have_next_message controls what is returned for No.
Implements Transport.
Definition at line 866 of file net.cpp.
|
overridevirtualnoexcept |
|
private |
|
overridevirtual |
Retrieve a completed message from transport.
This can only be called when ReceivedMessageComplete() is true.
If reject_message=true is returned the message itself is invalid, but (other than false returned by ReceivedBytes) the transport is not in an inconsistent state.
Implements Transport.
Definition at line 802 of file net.cpp.
|
overridevirtualnoexcept |
|
private |
|
private |
|
inlineprivate |
|
private |
|
inlineprivate |
|
private |
|
mutableprivate |
|
mutableprivate |
|
inlineprivate |
|
inlineprivate |
|
private |
The data of the message currently being sent.
|
private |
The header of the message currently being sent.
|
overridevirtualnoexcept |
Report how many bytes returned by the last GetBytesToSend() have been sent.
bytes_sent cannot exceed to_send.size() of the last GetBytesToSend() result.
If bytes_sent=0, this call has no effect.
Implements Transport.
Definition at line 887 of file net.cpp.
|
private |
|
private |
|
inlineoverridevirtual |
Feed wire bytes to the transport.
Consumed bytes are chopped off the front of msg_bytes.
Implements Transport.
Definition at line 434 of file net.h.
|
inlineoverridevirtual |
|
inlineprivate |
|
overridevirtualnoexcept |
Set the next message to send.
If no message can currently be set (perhaps because the previous one is not yet done being sent), returns false, and msg will be unmodified. Otherwise msg is enqueued (and possibly moved-from) and true is returned.
Implements Transport.
Definition at line 841 of file net.cpp.
|
inlineoverridevirtualnoexcept |
|
private |
|
mutableprivate |
|
mutableprivate |