From bf2ff964e14c022aa4c10849cb4421ee9a710d40 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 8 Apr 2015 15:26:45 -0700 Subject: Utils::now() removal and a bunch of compile fixes. --- node/Network.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'node/Network.cpp') diff --git a/node/Network.cpp b/node/Network.cpp index 13c81344..1f762a91 100644 --- a/node/Network.cpp +++ b/node/Network.cpp @@ -350,7 +350,7 @@ bool Network::isAllowed(const Address &peer) const void Network::clean() { - uint64_t now = Utils::now(); + const uint64_t now = RR->node->now(); Mutex::Lock _l(_lock); if (_destroyed) @@ -386,6 +386,20 @@ void Network::clean() } } +bool Network::updateAndCheckMulticastBalance(const MulticastGroup &mg,unsigned int bytes) +{ + const uint64_t now = RR->node->now(); + Mutex::Lock _l(_lock); + if (!_config) + return false; + std::map< MulticastGroup,BandwidthAccount >::iterator bal(_multicastRateAccounts.find(mg)); + if (bal == _multicastRateAccounts.end()) { + NetworkConfig::MulticastRate r(_config->multicastRate(mg)); + bal = _multicastRateAccounts.insert(std::pair< MulticastGroup,BandwidthAccount >(mg,BandwidthAccount(r.preload,r.maxBalance,r.accrual,now))).first; + } + return bal->second.deduct(bytes,now); +} + void Network::learnBridgeRoute(const MAC &mac,const Address &addr) { Mutex::Lock _l(_lock); @@ -488,7 +502,7 @@ class _AnnounceMulticastGroupsToPeersWithActiveDirectPaths public: _AnnounceMulticastGroupsToPeersWithActiveDirectPaths(const RuntimeEnvironment *renv,Network *nw) : RR(renv), - _now(Utils::now()), + _now(renv->node->now()), _network(nw), _supernodeAddresses(renv->topology->supernodeAddresses()) {} -- cgit v1.2.3