#include <net_peerlist.h>
Definition at line 62 of file net_peerlist.h.
◆ peerlist_storage() [1/3]
| nodetool::peerlist_storage::peerlist_storage |
( |
| ) |
|
|
inline |
◆ peerlist_storage() [2/3]
| nodetool::peerlist_storage::peerlist_storage |
( |
peerlist_storage && | | ) |
|
|
default |
◆ peerlist_storage() [3/3]
| nodetool::peerlist_storage::peerlist_storage |
( |
const peerlist_storage & | | ) |
|
|
delete |
◆ ~peerlist_storage()
| nodetool::peerlist_storage::~peerlist_storage |
( |
| ) |
|
|
noexcept |
◆ open() [1/2]
| boost::optional< peerlist_storage > nodetool::peerlist_storage::open |
( |
const std::string & | path | ) |
|
|
static |
- Returns
- Peers stored in file at path
Definition at line 191 of file net_peerlist.cpp.
192 {
193 std::ifstream src_file{};
194 src_file.open( path , std::ios_base::binary | std::ios_base::in);
195 if(src_file.fail())
196 return boost::none;
197
198 boost::optional<peerlist_storage>
out =
open(src_file,
true);
199 if (!out)
200 {
201
202 boost::filesystem::copy_file(path, path + ".unportable", boost::filesystem::copy_options::overwrite_existing);
203 src_file.close();
204 src_file.open( path , std::ios_base::binary | std::ios_base::in);
205 if(src_file.fail())
206 return boost::none;
207
209 if (!out)
210 {
211
212
213
214 MWARNING(
"Failed to load p2p config file, falling back to default config");
216 }
217 }
218
220 }
◆ open() [2/2]
| boost::optional< peerlist_storage > nodetool::peerlist_storage::open |
( |
std::istream & | src, |
|
|
const bool | new_format ) |
|
static |
- Returns
- Peers stored in stream src in new_format (portable archive or older non-portable).
Definition at line 161 of file net_peerlist.cpp.
162 {
163 try
164 {
166 if (new_format)
167 {
168 boost::archive::portable_binary_iarchive
a{src};
170 }
171 else
172 {
173 boost::archive::binary_iarchive
a{src};
175 }
176
177 if (src.good())
178 {
179 std::sort(
out.m_types.white.begin(),
out.m_types.white.end(), by_zone{});
180 std::sort(
out.m_types.gray.begin(),
out.m_types.gray.end(), by_zone{});
181 std::sort(
out.m_types.anchor.begin(),
out.m_types.anchor.end(), by_zone{});
182 return {std::move(out)};
183 }
184 }
185 catch (const std::exception& e)
186 {}
187
188 return boost::none;
189 }
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ store() [1/2]
| bool nodetool::peerlist_storage::store |
( |
const std::string & | path, |
|
|
const peerlist_types & | other ) const |
Save peers from this and other in one file at path.
Definition at line 240 of file net_peerlist.cpp.
241 {
242 std::ofstream dest_file{};
243 dest_file.open( path , std::ios_base::binary | std::ios_base::out| std::ios::trunc);
244 if(dest_file.fail())
245 return false;
246
247 return store(dest_file, other);
248 }
◆ store() [2/2]
| bool nodetool::peerlist_storage::store |
( |
std::ostream & | dest, |
|
|
const peerlist_types & | other ) const |
Save peers from this and other in stream dest.
Definition at line 225 of file net_peerlist.cpp.
226 {
227 try
228 {
229 boost::archive::portable_binary_oarchive
a{
dest};
230 const peerlist_join pj{std::cref(m_types), std::cref(other)};
233 }
234 catch (const boost::archive::archive_exception& e)
235 {}
236
237 return false;
238 }
CXA_THROW_INFO_T void(* dest)(void *))
◆ take_zone()
- Returns
- Peers in zone and from remove from this.
Definition at line 250 of file net_peerlist.cpp.
251 {
252 peerlist_types
out{};
253 out.white = do_take_zone(m_types.white, zone);
254 out.gray = do_take_zone(m_types.gray, zone);
255 out.anchor = do_take_zone(m_types.anchor, zone);
257 }
The documentation for this class was generated from the following files:
- /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/src/p2p/net_peerlist.h
- /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/src/p2p/net_peerlist.cpp