Skip to content

Commit 3919059

Browse files
hebastoajtowns
andcommitted
refactor: Move code from ctor into private BanMan::LoadBanlist()
Co-authored-by: Anthony Towns <[email protected]>
1 parent 4d0c00d commit 3919059

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/banman.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@
1616
BanMan::BanMan(fs::path ban_file, CClientUIInterface* client_interface, int64_t default_ban_time)
1717
: m_client_interface(client_interface), m_ban_db(std::move(ban_file)), m_default_ban_time(default_ban_time)
1818
{
19+
LoadBanlist();
20+
DumpBanlist();
21+
}
22+
23+
BanMan::~BanMan()
24+
{
25+
DumpBanlist();
26+
}
27+
28+
void BanMan::LoadBanlist()
29+
{
30+
LOCK(m_cs_banned);
31+
1932
if (m_client_interface) m_client_interface->InitMessage(_("Loading banlist…").translated);
2033

2134
int64_t n_start = GetTimeMillis();
@@ -29,13 +42,6 @@ BanMan::BanMan(fs::path ban_file, CClientUIInterface* client_interface, int64_t
2942
m_banned = {};
3043
m_is_dirty = true;
3144
}
32-
33-
DumpBanlist();
34-
}
35-
36-
BanMan::~BanMan()
37-
{
38-
DumpBanlist();
3945
}
4046

4147
void BanMan::DumpBanlist()

src/banman.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class BanMan
8080
void DumpBanlist();
8181

8282
private:
83+
void LoadBanlist() EXCLUSIVE_LOCKS_REQUIRED(!m_cs_banned);
8384
bool BannedSetIsDirty();
8485
//!set the "dirty" flag for the banlist
8586
void SetBannedSetDirty(bool dirty = true);

0 commit comments

Comments
 (0)