---
title: llarp/layers/flow/flow_layer.hpp

---

# llarp/layers/flow/flow_layer.hpp



## Namespaces

| Name           |
| -------------- |
| **[llarp](Namespaces/namespacellarp.md)** <br>[crypto.hpp] |
| **[llarp::service](Namespaces/namespacellarp_1_1service.md)**  |
| **[llarp::layers](Namespaces/namespacellarp_1_1layers.md)**  |
| **[llarp::layers::flow](Namespaces/namespacellarp_1_1layers_1_1flow.md)**  |

## Classes

|                | Name           |
| -------------- | -------------- |
| class | **[llarp::layers::flow::FlowLayer](Classes/classllarp_1_1layers_1_1flow_1_1FlowLayer.md)** <br>flow layer's context that holds all the things in the flow layer  |




## Source code

```cpp
#pragma once

#include "flow_addr.hpp"
#include "flow_identity.hpp"
#include "flow_tag.hpp"
#include "flow_stats.hpp"
#include "flow_traffic.hpp"

#include "llarp/layers/flow/flow_info.hpp"
#include "name_cache.hpp"
#include "name_resolver.hpp"

#include <llarp/config/config.hpp>
#include <memory>
#include <type_traits>
#include <vector>

namespace llarp
{
  struct AbstractRouter;
}

namespace llarp::service
{
  struct Endpoint;
}

namespace llarp::layers::flow
{

  class FlowLayer
  {
    const NetworkConfig _conf;
    std::vector<std::shared_ptr<FlowIdentity>> _local_flows;

    FlowIdentityPrivateKeys _privkeys;

    NameCache _name_cache;

    std::shared_ptr<service::Endpoint> _deprecated_endpoint;

    std::vector<FlowTraffic> _recv;

    std::shared_ptr<EventLoopWakeup> _wakeup;

    void
    maybe_store_or_load_privkeys();

    FlowTag
    unique_flow_tag() const;

    bool
    has_flow_tag(const FlowTag&) const;

   public:
    FlowLayer(AbstractRouter&, NetworkConfig);
    ~FlowLayer();

    FlowLayer(const FlowLayer&) = delete;
    FlowLayer(FlowLayer&&) = delete;

    FlowStats
    current_stats() const;

    bool
    has_flow(const flow::FlowInfo& flow_info) const;

    void
    remove_flow(const flow::FlowInfo& flow_info);

    inline FlowAddr
    local_addr() const
    {
      return current_stats().local_addr;
    }

    std::shared_ptr<service::Endpoint>
    local_deprecated_loki_endpoint() const;

    std::shared_ptr<FlowIdentity>
    flow_to(const FlowAddr& to);

    std::vector<FlowTraffic>
    poll_flow_traffic();

    void
    offer_flow_traffic(FlowTraffic&& traff);

    void
    start();

    void
    stop();

    NameResolver name_resolver;

    AbstractRouter& router;
  };
}  // namespace llarp::layers::flow
```


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

Updated on 2023-03-06 at 20:36:34 +0000
