| 
    Kagome
    
   Polkadot Runtime Engine in C++17 
   | 
 
#include <sync_protocol_impl.hpp>
Classes | |
| struct | CacheRecord | 
Public Member Functions | |
| BlocksResponseCache (std::size_t capacity, std::chrono::seconds expiration_time) | |
| bool | isDuplicate (const PeerId &peer_id, BlocksRequest::Fingerprint request_fingerprint) | 
Private Types | |
| using | ExpirationTimepoint = std::chrono::time_point< std::chrono::system_clock > | 
| using | CacheRecordIndex = std::size_t | 
Private Member Functions | |
| void | cache (const PeerId &peer_id, BlocksRequest::Fingerprint request_fingerprint, std::optional< CacheRecordIndex > target_slot=std::nullopt) | 
| void | purge () | 
| removes all stale records  More... | |
Private Attributes | |
| const std::size_t | capacity_ | 
| const std::chrono::seconds | expiration_time_ | 
| std::unordered_map< PeerId, CacheRecordIndex > | lookup_table_ | 
| std::vector< std::optional< CacheRecord > > | storage_ | 
| std::unordered_set< CacheRecordIndex > | free_slots_ | 
Container to store the most recent block requests by peers we replied to with non empty responses.
Definition at line 40 of file sync_protocol_impl.hpp.
| struct kagome::network::detail::BlocksResponseCache::CacheRecord | 
Definition at line 85 of file sync_protocol_impl.hpp.
| Class Members | ||
|---|---|---|
| circular_buffer< Fingerprint > | fingerprints | |
| PeerId | peer_id | |
| ExpirationTimepoint | valid_till | |
      
  | 
  private | 
Definition at line 69 of file sync_protocol_impl.hpp.
      
  | 
  private | 
Definition at line 68 of file sync_protocol_impl.hpp.
| kagome::network::detail::BlocksResponseCache::BlocksResponseCache | ( | std::size_t | capacity, | 
| std::chrono::seconds | expiration_time | ||
| ) | 
Initialize the cache
| capacity | - max amount of cache entries | 
| expiration_time | - cache entry expiry time in seconds | 
Definition at line 22 of file sync_protocol_impl.cpp.
      
  | 
  private | 
Save a record about peer's request to cache
| peer_id | - peer identifier | 
| request_fingerprint | - request identifier | 
| target_slot | - (optional) a slot of internal storage to put a record into | 
Definition at line 67 of file sync_protocol_impl.cpp.
| bool kagome::network::detail::BlocksResponseCache::isDuplicate | ( | const PeerId & | peer_id, | 
| BlocksRequest::Fingerprint | request_fingerprint | ||
| ) | 
Checks whether specified request came from the peer more than once.
Some repeating request done past "expiration_time" seconds since last request from the peer would not be considered as duplicating request.
| peer_id | - peer identifier | 
| request_fingerprint | - request identifier | 
Definition at line 35 of file sync_protocol_impl.cpp.
      
  | 
  private | 
removes all stale records
Definition at line 103 of file sync_protocol_impl.cpp.
      
  | 
  private | 
Definition at line 92 of file sync_protocol_impl.hpp.
      
  | 
  private | 
Definition at line 93 of file sync_protocol_impl.hpp.
      
  | 
  private | 
Definition at line 96 of file sync_protocol_impl.hpp.
      
  | 
  private | 
Definition at line 94 of file sync_protocol_impl.hpp.
      
  | 
  private | 
Definition at line 95 of file sync_protocol_impl.hpp.