Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
RouterInfo: refactor buffer getter
Browse files Browse the repository at this point in the history
- Removes unnecessary buffer loading function
- Refactors getter to load buffer if empty
  • Loading branch information
anonimal committed May 5, 2017
1 parent 5c5751b commit 33db5e4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/core/router/info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ void RouterInfo::Update(const std::uint8_t* buf, std::uint16_t len)
// don't delete buffer until saved to file
}

const std::uint8_t* RouterInfo::LoadBuffer()
const std::uint8_t* RouterInfo::GetBuffer() const
{
if (!m_Buffer)
{
Expand Down
13 changes: 2 additions & 11 deletions src/core/router/info.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,6 @@ class RouterInfo : public RouterInfoTraits, public RoutingDestination
/// @param len New RI length
void Update(const std::uint8_t* buf, std::uint16_t len);

/// @brief Loads RI buffer (by reading) if buffer is not yet available
/// @notes Required by NetDb
/// TODO(anonimal): remove, refactor (buffer should at least be guaranteed with getter)
const std::uint8_t* LoadBuffer();

/// @brief Create RI and put into buffer
/// @param private_keys Private keys used to derive signing key
/// (and subsequently sign the RI with)
Expand All @@ -491,12 +486,8 @@ class RouterInfo : public RouterInfoTraits, public RoutingDestination

public:
/// @return Pointer to RI buffer
/// TODO(anonimal): refactor
const std::uint8_t* GetBuffer() const
{
auto buf = m_Buffer.get();
return buf;
}
/// @notes Loads RI from file if buffer is not yet available
const std::uint8_t* GetBuffer() const;

/// @return RI buffer length
std::uint16_t GetBufferLen() const noexcept
Expand Down
1 change: 0 additions & 1 deletion src/core/router/net_db/impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,6 @@ void NetDb::HandleDatabaseLookupMsg(
auto router = FindRouter(ident);
if (router) {
LOG(debug) << "NetDb: requested RouterInfo " << key.data() << " found";
router->LoadBuffer();
if (router->GetBuffer())
reply_msg = CreateDatabaseStoreMsg(router);
}
Expand Down

0 comments on commit 33db5e4

Please sign in to comment.