mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2024-11-11 19:10:55 +00:00
* Transports: update IsBandwidthExceeded() and comments in header
This commit is contained in:
parent
642bcfcdea
commit
aef6b7712c
@ -200,9 +200,9 @@ namespace transport
|
|||||||
|
|
||||||
bool Transports::IsBandwidthExceeded () const
|
bool Transports::IsBandwidthExceeded () const
|
||||||
{
|
{
|
||||||
if (i2p::context.GetRouterInfo ().IsExtraBandwidth ()) return false;
|
auto limit = i2p::context.GetBandwidthLimit() * 1024; // convert to bytes
|
||||||
auto bw = std::max (m_InBandwidth, m_OutBandwidth);
|
auto bw = std::max (m_InBandwidth, m_OutBandwidth);
|
||||||
return bw > (i2p::context.GetRouterInfo ().IsHighBandwidth () ? HIGH_BANDWIDTH_LIMIT : LOW_BANDWIDTH_LIMIT);
|
return bw > limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transports::SendMessage (const i2p::data::IdentHash& ident, std::shared_ptr<i2p::I2NPMessage> msg)
|
void Transports::SendMessage (const i2p::data::IdentHash& ident, std::shared_ptr<i2p::I2NPMessage> msg)
|
||||||
|
@ -66,8 +66,6 @@ namespace transport
|
|||||||
};
|
};
|
||||||
|
|
||||||
const size_t SESSION_CREATION_TIMEOUT = 10; // in seconds
|
const size_t SESSION_CREATION_TIMEOUT = 10; // in seconds
|
||||||
const uint32_t LOW_BANDWIDTH_LIMIT = 32*1024; // 32KBs
|
|
||||||
const uint32_t HIGH_BANDWIDTH_LIMIT = 256*1024; // 256KBs
|
|
||||||
class Transports
|
class Transports
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -94,8 +92,8 @@ namespace transport
|
|||||||
void UpdateReceivedBytes (uint64_t numBytes) { m_TotalReceivedBytes += numBytes; };
|
void UpdateReceivedBytes (uint64_t numBytes) { m_TotalReceivedBytes += numBytes; };
|
||||||
uint64_t GetTotalSentBytes () const { return m_TotalSentBytes; };
|
uint64_t GetTotalSentBytes () const { return m_TotalSentBytes; };
|
||||||
uint64_t GetTotalReceivedBytes () const { return m_TotalReceivedBytes; };
|
uint64_t GetTotalReceivedBytes () const { return m_TotalReceivedBytes; };
|
||||||
uint32_t GetInBandwidth () const { return m_InBandwidth; }; // bytes per second
|
uint32_t GetInBandwidth () const { return m_InBandwidth; };
|
||||||
uint32_t GetOutBandwidth () const { return m_OutBandwidth; }; // bytes per second
|
uint32_t GetOutBandwidth () const { return m_OutBandwidth; };
|
||||||
bool IsBandwidthExceeded () const;
|
bool IsBandwidthExceeded () const;
|
||||||
size_t GetNumPeers () const { return m_Peers.size (); };
|
size_t GetNumPeers () const { return m_Peers.size (); };
|
||||||
std::shared_ptr<const i2p::data::RouterInfo> GetRandomPeer () const;
|
std::shared_ptr<const i2p::data::RouterInfo> GetRandomPeer () const;
|
||||||
@ -138,7 +136,7 @@ namespace transport
|
|||||||
DHKeysPairSupplier m_DHKeysPairSupplier;
|
DHKeysPairSupplier m_DHKeysPairSupplier;
|
||||||
|
|
||||||
std::atomic<uint64_t> m_TotalSentBytes, m_TotalReceivedBytes;
|
std::atomic<uint64_t> m_TotalSentBytes, m_TotalReceivedBytes;
|
||||||
uint32_t m_InBandwidth, m_OutBandwidth;
|
uint32_t m_InBandwidth, m_OutBandwidth; // bytes per second
|
||||||
uint64_t m_LastInBandwidthUpdateBytes, m_LastOutBandwidthUpdateBytes;
|
uint64_t m_LastInBandwidthUpdateBytes, m_LastOutBandwidthUpdateBytes;
|
||||||
uint64_t m_LastBandwidthUpdateTime;
|
uint64_t m_LastBandwidthUpdateTime;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user