---
title: llarp/layers/onion/onion_layer.hpp

---

# llarp/layers/onion/onion_layer.hpp



## Namespaces

| Name           |
| -------------- |
| **[llarp](Namespaces/namespacellarp.md)** <br>[crypto.hpp] |
| **[llarp::path](Namespaces/namespacellarp_1_1path.md)**  |
| **[llarp::layers](Namespaces/namespacellarp_1_1layers.md)**  |
| **[llarp::layers::onion](Namespaces/namespacellarp_1_1layers_1_1onion.md)**  |

## Classes

|                | Name           |
| -------------- | -------------- |
| class | **[llarp::layers::onion::OnionLayer](Classes/classllarp_1_1layers_1_1onion_1_1OnionLayer.md)**  |




## Source code

```cpp
#pragma once

#include <unordered_map>
#include <unordered_set>

#include <llarp/path/path_types.hpp>
#include "onion_stats.hpp"

namespace llarp
{
  struct AbstractRouter;
  class EventLoopWakeup;
}  // namespace llarp

namespace llarp::path
{
  struct IHopHandler;
}

namespace llarp::layers::onion
{
  class OnionLayer
  {
    std::unordered_set<std::shared_ptr<path::IHopHandler>> _all;
    std::unordered_map<PathID_t, std::weak_ptr<path::IHopHandler>> _id_to_owned;
    std::unordered_map<PathID_t, std::weak_ptr<path::IHopHandler>> _id_to_transit;

    AbstractRouter& _router;

    std::shared_ptr<EventLoopWakeup> _work;

    void
    submit_work() const;

    void
    remove_expired();

   public:
    explicit OnionLayer(AbstractRouter&);

    void
    trigger_work() const;

    void
    start();

    void
    stop();

    OnionStats
    current_stats() const;
  };

}  // namespace llarp::layers::onion
```


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

Updated on 2023-04-27 at 04:17:17 +0000
