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_service.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 {
79 };
80
82 notify() noexcept
83 : zone_(nullptr)
84 , core_(nullptr)
85 {}
86
88 explicit notify(boost::asio::io_service& service, std::shared_ptr<connections> p2p, epee::byte_slice noise, epee::net_utils::zone zone, bool pad_txs, i_core_events& core);
89
90 notify(const notify&) = delete;
91 notify(notify&&) = default;
92
93 ~notify() noexcept;
94
95 notify& operator=(const notify&) = delete;
96 notify& operator=(notify&&) = default;
97
99 status get_status() const noexcept;
100
102 void new_out_connection();
103
104 void on_handshake_complete(const boost::uuids::uuid &id, bool is_income);
105 void on_connection_close(const boost::uuids::uuid &id);
106
108 void run_epoch();
109
111 void run_stems();
112
114 void run_fluff();
115
131 bool send_txs(std::vector<blobdata> txs, const boost::uuids::uuid& source, relay_method tx_relay);
132 };
133} // levin
134} // net
handles core cryptonote functionality
Definition: cryptonote_core.h:87
Provides tx notification privacy.
Definition: levin_notify.h:70
bool send_txs(std::vector< blobdata > txs, const boost::uuids::uuid &source, relay_method tx_relay)
Definition: levin_notify.cpp:808
void new_out_connection()
Probe for new outbound connection - skips if not needed.
Definition: levin_notify.cpp:749
status get_status() const noexcept
Definition: levin_notify.cpp:741
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:759
void run_stems()
Run the logic for the next stem timeout imemdiately. Only use in testing.
Definition: levin_notify.cpp:792
~notify() noexcept
Definition: levin_notify.cpp:738
void run_epoch()
Run the logic for the next epoch immediately. Only use in testing.
Definition: levin_notify.cpp:785
notify(notify &&)=default
notify(const notify &)=delete
void on_connection_close(const boost::uuids::uuid &id)
Definition: levin_notify.cpp:774
void run_fluff()
Run the logic for flushing all Dandelion++ fluff queued txs. Only use in testing.
Definition: levin_notify.cpp:801
std::shared_ptr< detail::zone > zone_
Definition: levin_notify.h:71
notify() noexcept
Construct an instance that cannot notify.
Definition: levin_notify.h:82
Definition: byte_slice.h:69
Definition: levin_protocol_handler_async.h:81
#define const
Definition: ipfrdr.c:80
relay_method tx_relay
Definition: levin_notify.cpp:545
const char * uuid
Definition: minissdp.c:598
Definition: portable_binary_archive.hpp:29
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
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:266
Definition: levin_notify.h:76
bool has_noise
Definition: levin_notify.h:77
bool connections_filled
Definition: levin_notify.h:78
Definition: net_node.h:112
Definition: minissdpd.c:83