Skip to content

Commit f212caa

Browse files
committed
evo: introduce NetInfoInterface, make MnNetInfo an implementation
1 parent 0b04978 commit f212caa

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

src/evo/deterministicmns.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ class CDeterministicMNList
385385
DMNL_NO_TEMPLATE(CBLSPublicKey);
386386
DMNL_NO_TEMPLATE(MnNetInfo);
387387
DMNL_NO_TEMPLATE(NetInfoEntry);
388+
DMNL_NO_TEMPLATE(NetInfoInterface);
388389
#undef DMNL_NO_TEMPLATE
389390
return ::SerializeHash(v);
390391
}

src/evo/netinfo.h

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,23 @@ template<> struct is_serializable_enum<NetInfoEntry::NetInfoType> : std::true_ty
126126

127127
using NetInfoList = std::vector<std::reference_wrapper<const NetInfoEntry>>;
128128

129-
class MnNetInfo
129+
class NetInfoInterface
130+
{
131+
public:
132+
virtual ~NetInfoInterface() = default;
133+
134+
virtual NetInfoStatus AddEntry(const std::string& service) = 0;
135+
virtual NetInfoList GetEntries() const = 0;
136+
137+
virtual const CService& GetPrimary() const = 0;
138+
virtual bool IsEmpty() const = 0;
139+
virtual NetInfoStatus Validate() const = 0;
140+
virtual std::string ToString() const = 0;
141+
142+
virtual void Clear() = 0;
143+
};
144+
145+
class MnNetInfo final : public NetInfoInterface
130146
{
131147
private:
132148
NetInfoEntry m_addr{};
@@ -167,15 +183,15 @@ class MnNetInfo
167183
m_addr = NetInfoEntry{service};
168184
}
169185

170-
NetInfoStatus AddEntry(const std::string& service);
171-
NetInfoList GetEntries() const;
186+
NetInfoStatus AddEntry(const std::string& service) override;
187+
NetInfoList GetEntries() const override;
172188

173-
const CService& GetPrimary() const;
174-
bool IsEmpty() const { return *this == MnNetInfo(); }
175-
NetInfoStatus Validate() const;
176-
std::string ToString() const;
189+
const CService& GetPrimary() const override;
190+
bool IsEmpty() const override { return *this == MnNetInfo(); }
191+
NetInfoStatus Validate() const override;
192+
std::string ToString() const override;
177193

178-
void Clear() { m_addr.Clear(); }
194+
void Clear() override { m_addr.Clear(); }
179195
};
180196

181197
inline std::shared_ptr<MnNetInfo> MakeNetInfo()

0 commit comments

Comments
 (0)