Electroneum
Toggle main menu visibility
Loading...
Searching...
No Matches
core.h
Go to the documentation of this file.
1
// Copyrights(c) 2017-2021, The Electroneum Project
2
// Copyrights(c) 2014-2019, The Monero Project
3
//
4
// All rights reserved.
5
//
6
// Redistribution and use in source and binary forms, with or without modification, are
7
// permitted provided that the following conditions are met:
8
//
9
// 1. Redistributions of source code must retain the above copyright notice, this list of
10
// conditions and the following disclaimer.
11
//
12
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
13
// of conditions and the following disclaimer in the documentation and/or other
14
// materials provided with the distribution.
15
//
16
// 3. Neither the name of the copyright holder nor the names of its contributors may be
17
// used to endorse or promote products derived from this software without specific
18
// prior written permission.
19
//
20
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30
#pragma once
31
32
#include "
blocks/blocks.h
"
33
#include "
cryptonote_core/cryptonote_core.h
"
34
#include "
cryptonote_protocol/cryptonote_protocol_handler.h
"
35
#include "
misc_log_ex.h
"
36
37
#undef ELECTRONEUM_DEFAULT_LOG_CATEGORY
38
#define ELECTRONEUM_DEFAULT_LOG_CATEGORY "daemon"
39
40
namespace
daemonize
41
{
42
43
class
t_core
final
44
{
45
public
:
46
static
void
init_options
(boost::program_options::options_description & option_spec)
47
{
48
cryptonote::core::init_options
(option_spec);
49
}
50
private
:
51
typedef
cryptonote::t_cryptonote_protocol_handler<cryptonote::core>
t_protocol_raw;
52
cryptonote::core
m_core;
53
// TEMPORARY HACK - Yes, this creates a copy, but otherwise the original
54
// variable map could go out of scope before the run method is called
55
boost::program_options::variables_map
const
m_vm_HACK;
56
public
:
57
t_core
(
58
boost::program_options::variables_map
const
& vm
59
)
60
: m_core{nullptr}
61
, m_vm_HACK{vm}
62
{
63
}
64
65
// TODO - get rid of circular dependencies in internals
66
void
set_protocol
(t_protocol_raw & protocol)
67
{
68
m_core.set_cryptonote_protocol(&protocol);
69
}
70
71
bool
run
()
72
{
73
//initialize core here
74
MGINFO
(
"Initializing core..."
);
75
#if defined(PER_BLOCK_CHECKPOINT)
76
const
cryptonote::GetCheckpointsCallback
& get_checkpoints =
blocks::GetCheckpointsData
;
77
#else
78
const
cryptonote::GetCheckpointsCallback
& get_checkpoints =
nullptr
;
79
#endif
80
if
(!m_core.init(m_vm_HACK,
nullptr
, get_checkpoints))
81
{
82
return
false
;
83
}
84
MGINFO
(
"Core initialized OK"
);
85
return
true
;
86
}
87
88
cryptonote::core
&
get
()
89
{
90
return
m_core;
91
}
92
93
~t_core
()
94
{
95
MGINFO
(
"Deinitializing core..."
);
96
try
{
97
m_core.deinit();
98
m_core.set_cryptonote_protocol(
nullptr
);
99
}
catch
(...) {
100
MERROR
(
"Failed to deinitialize core..."
);
101
}
102
}
103
};
104
105
}
blocks.h
cryptonote::core
handles core cryptonote functionality
Definition
cryptonote_core.h:86
cryptonote::core::init_options
static void init_options(boost::program_options::options_description &desc)
adds command line options to the given options set
Definition
cryptonote_core.cpp:346
cryptonote::t_cryptonote_protocol_handler
Definition
cryptonote_protocol_handler.h:78
daemonize::t_core::get
cryptonote::core & get()
Definition
core.h:88
daemonize::t_core::run
bool run()
Definition
core.h:71
daemonize::t_core::set_protocol
void set_protocol(t_protocol_raw &protocol)
Definition
core.h:66
daemonize::t_core::init_options
static void init_options(boost::program_options::options_description &option_spec)
Definition
core.h:46
daemonize::t_core::~t_core
~t_core()
Definition
core.h:93
daemonize::t_core::t_core
t_core(boost::program_options::variables_map const &vm)
Definition
core.h:57
cryptonote_core.h
cryptonote_protocol_handler.h
This is the orginal cryptonote protocol network-events handler, modified by us.
misc_log_ex.h
MERROR
#define MERROR(x)
Definition
misc_log_ex.h:73
MGINFO
#define MGINFO(x)
Definition
misc_log_ex.h:80
blocks::GetCheckpointsData
const epee::span< const unsigned char > GetCheckpointsData(cryptonote::network_type network)
Definition
blocks.cpp:21
cryptonote::GetCheckpointsCallback
std::function< const epee::span< const unsigned char >(cryptonote::network_type network)> GetCheckpointsCallback
Callback routine that returns checkpoints data for specific network type.
Definition
blockchain.h:92
daemonize
Definition
command_parser_executor.cpp:38
src
daemon
core.h
Generated on
for Electroneum by
1.17.0