Monero
Loading...
Searching...
No Matches
levin_notify.h
Go to the documentation of this file.
1// Copyright (c) 2019-2022, The Monero Project
2//
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without modification, are
6// permitted provided that the following conditions are met:
7//
8// 1. Redistributions of source code must retain the above copyright notice, this list of
9// conditions and the following disclaimer.
10//
11// 2. Redistributions in binary form must reproduce the above copyright notice, this list
12// of conditions and the following disclaimer in the documentation and/or other
13// materials provided with the distribution.
14//
15// 3. Neither the name of the copyright holder nor the names of its contributors may be
16// used to endorse or promote products derived from this software without specific
17// prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29#pragma once
30
31#include <boost/asio/io_context.hpp>
32#include <boost/uuid/uuid.hpp>
33#include <memory>
34#include <vector>
35
36#include "byte_slice.h"
40#include "net/enums.h"
41#include "span.h"
42
43namespace epee
44{
45namespace levin
46{
47 template<typename> class async_protocol_handler_config;
48}
49}
50
51namespace nodetool
52{
53 template<typename> struct p2p_connection_context_t;
54}
55
56namespace cryptonote
57{
58namespace levin
59{
60 namespace detail
61 {
63 struct zone;
64 } // detail
65
67
69 class notify
70 {
71 std::shared_ptr<detail::zone> zone_;
73
74 public:
75 struct status
76 {
80 };
81
83 notify() noexcept
84 : zone_(nullptr)
85 , core_(nullptr)
86 {}
87
89 explicit notify(boost::asio::io_context& service, std::shared_ptr<connections> p2p, epee::byte_slice noise, epee::net_utils::zone zone, bool pad_txs, i_core_events& core);
90
91 notify(const notify&) = delete;
92 notify(notify&&) = default;
93
94 ~notify() noexcept;
95
96 notify& operator=(const notify&) = delete;
97 notify& operator=(notify&&) = default;
98
100 status get_status() const noexcept;
101
103 void new_out_connection();
104
105 void on_handshake_complete(const boost::uuids::uuid &id, bool is_income);
106 void on_connection_close(const boost::uuids::uuid &id);
107
109 void run_epoch();
110
112 void run_stems();
113
115 void run_fluff();
116
132 bool send_txs(std::vector<blobdata> txs, const boost::uuids::uuid& source, relay_method tx_relay);
133 };
134} // levin
135} // net
handles core cryptonote functionality
Definition cryptonote_core.h:87
bool send_txs(std::vector< blobdata > txs, const boost::uuids::uuid &source, relay_method tx_relay)
Definition levin_notify.cpp:819
void new_out_connection()
Probe for new outbound connection - skips if not needed.
Definition levin_notify.cpp:759
status get_status() const noexcept
Definition levin_notify.cpp:746
i_core_events * core_
Definition levin_notify.h:72
void on_handshake_complete(const boost::uuids::uuid &id, bool is_income)
Definition levin_notify.cpp:770
void run_stems()
Run the logic for the next stem timeout imemdiately. Only use in testing.
Definition levin_notify.cpp:803
~notify() noexcept
Definition levin_notify.cpp:743
void run_epoch()
Run the logic for the next epoch immediately. Only use in testing.
Definition levin_notify.cpp:796
notify(notify &&)=default
notify(const notify &)=delete
void on_connection_close(const boost::uuids::uuid &id)
Definition levin_notify.cpp:785
void run_fluff()
Run the logic for flushing all Dandelion++ fluff queued txs. Only use in testing.
Definition levin_notify.cpp:812
std::shared_ptr< detail::zone > zone_
Definition levin_notify.h:71
notify() noexcept
Construct an instance that cannot notify.
Definition levin_notify.h:83
Definition byte_slice.h:69
Definition levin_protocol_handler_async.h:81
#define const
Definition ipfrdr.c:80
const char * uuid
Definition minissdp.c:598
Definition portable_binary_archive.hpp:29
nodetool::p2p_connection_context_t< cryptonote::cryptonote_connection_context > p2p_context
Definition levin_notify.h:62
epee::levin::async_protocol_handler_config< detail::p2p_context > connections
Definition levin_notify.h:66
Holds cryptonote related classes and helpers.
Definition blockchain_db.cpp:45
relay_method
Methods tracking how a tx was received and relayed.
Definition enums.h:37
std::string blobdata
Definition blobdatatype.h:39
declaration and default definition for the functions used the API
Definition expect.cpp:34
Definition levin_base.h:44
zone
Definition enums.h:50
TODO: (mj-xmr) This will be reduced in an another PR.
Definition byte_slice.h:40
Definition levin_notify.h:52
Definition p2p.py:1
Definition enums.h:68
const CharType(& source)[N]
Definition pointer.h:1147
Definition i_core_events.h:38
Definition levin_notify.cpp:268
Definition levin_notify.h:76
bool has_noise
Definition levin_notify.h:77
bool has_outgoing
True when zone has outgoing connections.
Definition levin_notify.h:79
bool connections_filled
True when has zone has CRYPTONOTE_NOISE_CHANNELS outgoing noise channels.
Definition levin_notify.h:78
Definition net_node.h:112
Definition minissdpd.c:83