Skip to content

Commit

Permalink
quic: move Map types into relevant classes
Browse files Browse the repository at this point in the history
PR-URL: nodejs#294
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
jasnell committed Feb 3, 2020
1 parent a088a97 commit e67decb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/quic/node_quic_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,8 @@ class QuicSocket : public AsyncWrap,
QlogMode qlog_ = QlogMode::kDisabled;
BaseObjectPtr<crypto::SecureContext> server_secure_context_;
std::string server_alpn_;
QuicCIDMap<BaseObjectPtr<QuicSession>> sessions_;
QuicCIDMap<QuicCID> dcid_to_scid_;
QuicCID::Map<BaseObjectPtr<QuicSession>> sessions_;
QuicCID::Map<QuicCID> dcid_to_scid_;

uint8_t token_secret_[kTokenSecretLen];
uint8_t reset_token_secret_[NGTCP2_STATELESS_RESET_TOKENLEN];
Expand All @@ -498,7 +498,7 @@ class QuicSocket : public AsyncWrap,
// remote address.
SocketAddressMap<size_t> reset_counts_;

StatelessResetTokenMap<QuicSession> token_map_;
StatelessResetToken::Map<QuicSession> token_map_;

// The validated_addrs_ vector is used as an LRU cache for
// validated addresses only when the VALIDATE_ADDRESS_LRU
Expand Down
23 changes: 11 additions & 12 deletions src/quic/node_quic_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ class QuicCID : public MemoryRetainer {
SET_MEMORY_INFO_NAME(QuicCID)
SET_SELF_SIZE(QuicCID)

template <typename T>
using Map = std::unordered_map<QuicCID, T, QuicCID::Hash, QuicCID::Compare>;

private:
ngtcp2_cid cid_{};
const ngtcp2_cid* ptr_;
Expand Down Expand Up @@ -324,23 +327,19 @@ class StatelessResetToken : public MemoryRetainer {
SET_MEMORY_INFO_NAME(StatelessResetToken)
SET_SELF_SIZE(StatelessResetToken)

template <typename T>
using Map =
std::unordered_map<
StatelessResetToken,
BaseObjectPtr<T>,
StatelessResetToken::Hash,
StatelessResetToken::Compare>;

private:
uint8_t buf_[NGTCP2_STATELESS_RESET_TOKENLEN];
const uint8_t* token_;
};

template <typename T>
using StatelessResetTokenMap =
std::unordered_map<
StatelessResetToken,
BaseObjectPtr<T>,
StatelessResetToken::Hash,
StatelessResetToken::Compare>;

template <typename T>
using QuicCIDMap =
std::unordered_map<QuicCID, T, QuicCID::Hash, QuicCID::Compare>;

template <typename T>
inline size_t get_length(const T*, size_t len);

Expand Down

0 comments on commit e67decb

Please sign in to comment.