Monero
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 
43 namespace epee
44 {
45 namespace levin
46 {
47  template<typename> class async_protocol_handler_config;
48 }
49 }
50 
51 namespace nodetool
52 {
53  template<typename> struct p2p_connection_context_t;
54 }
55 
56 namespace cryptonote
57 {
58 namespace 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  {
77  bool has_noise;
79  bool has_outgoing;
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
const CharType(& source)[N]
Definition: pointer.h:1147
status get_status() const noexcept
Definition: levin_notify.cpp:746
Definition: levin_notify.h:75
Definition: portable_binary_archive.hpp:29
void run_stems()
Run the logic for the next stem timeout imemdiately. Only use in testing.
Definition: levin_notify.cpp:803
Definition: minissdpd.c:83
Definition: enums.h:67
void on_connection_close(const boost::uuids::uuid &id)
Definition: levin_notify.cpp:785
bool connections_filled
True when has zone has CRYPTONOTE_NOISE_CHANNELS outgoing noise channels.
Definition: levin_notify.h:78
Definition: levin_notify.cpp:267
bool has_outgoing
True when zone has outgoing connections.
Definition: levin_notify.h:79
Provides tx notification privacy.
Definition: levin_notify.h:69
Definition: i_core_events.h:37
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:44
notify() noexcept
Construct an instance that cannot notify.
Definition: levin_notify.h:83
default
Definition: pymoduletest.py:17
void run_fluff()
Run the logic for flushing all Dandelion++ fluff queued txs. Only use in testing. ...
Definition: levin_notify.cpp:812
declaration and default definition for the functions used the API
Definition: expect.cpp:33
std::shared_ptr< detail::zone > zone_
Definition: levin_notify.h:71
const char * uuid
Definition: minissdp.c:598
i_core_events * core_
Definition: levin_notify.h:72
void run_epoch()
Run the logic for the next epoch immediately. Only use in testing.
Definition: levin_notify.cpp:796
handles core cryptonote functionality
Definition: cryptonote_core.h:86
void new_out_connection()
Probe for new outbound connection - skips if not needed.
Definition: levin_notify.cpp:759
Definition: byte_slice.h:68
bool send_txs(std::vector< blobdata > txs, const boost::uuids::uuid &source, relay_method tx_relay)
Definition: levin_notify.cpp:819
relay_method tx_relay
Definition: levin_notify.cpp:549
std::string blobdata
Definition: blobdatatype.h:39
TODO: (mj-xmr) This will be reduced in an another PR.
Definition: byte_slice.h:39
~notify() noexcept
Definition: levin_notify.cpp:743
Definition: p2p.py:1
Definition: levin_protocol_handler_async.h:80
Definition: levin_notify.h:53
Definition: levin_notify.h:51
zone
Definition: enums.h:49
relay_method
Methods tracking how a tx was received and relayed.
Definition: enums.h:36
bool has_noise
Definition: levin_notify.h:77
#define const
Definition: ipfrdr.c:80
void on_handshake_complete(const boost::uuids::uuid &id, bool is_income)
Definition: levin_notify.cpp:770