---
title: llarp/router_version.hpp

---

# llarp/router_version.hpp



## Namespaces

| Name           |
| -------------- |
| **[llarp](Namespaces/namespacellarp.md)** <br>[crypto.hpp] |

## Classes

|                | Name           |
| -------------- | -------------- |
| struct | **[llarp::RouterVersion](Classes/structllarp_1_1RouterVersion.md)**  |




## Source code

```cpp
#pragma once

#include <array>
#include "util/bencode.hpp"
#include "constants/version.hpp"
#include "constants/proto.hpp"
#include "util/formattable.hpp"

namespace llarp
{
  struct RouterVersion
  {
    using Version_t = std::array<uint16_t, 3>;

    RouterVersion() = default;

    explicit RouterVersion(const Version_t& routerVersion, uint64_t protoVersion);

    bool
    BEncode(llarp_buffer_t* buf) const;

    bool
    BDecode(llarp_buffer_t* buf);

    bool
    IsEmpty() const;

    void
    Clear();

    std::string
    ToString() const;

    bool
    IsCompatableWith(const RouterVersion& other) const;

    bool
    operator<(const RouterVersion& other) const
    {
      return std::tie(m_ProtoVersion, m_Version) < std::tie(other.m_ProtoVersion, other.m_Version);
    }

    bool
    operator!=(const RouterVersion& other) const
    {
      return !(*this == other);
    }

    bool
    operator==(const RouterVersion& other) const
    {
      return m_ProtoVersion == other.m_ProtoVersion && m_Version == other.m_Version;
    }

   private:
    Version_t m_Version = {{0, 0, 0}};
    int64_t m_ProtoVersion = llarp::constants::proto_version;
  };

  template <>
  constexpr inline bool IsToStringFormattable<RouterVersion> = true;

  static constexpr int64_t INVALID_VERSION = -1;
  static const RouterVersion emptyRouterVersion({0, 0, 0}, INVALID_VERSION);

}  // namespace llarp
```


-------------------------------

Updated on 2022-11-04 at 14:36:39 +0000
