Exemple #1
0
void bithorded::router::ForwardedAsset::onUpstreamStatus(const string& peername, const bithorde::AssetStatus& status)
{
	if (status.status() == bithorde::Status::SUCCESS) {
		if (status.size() > (static_cast<uint64_t>(1)<<60)) {
			BOOST_LOG_SEV(assetLogger, bithorded::warning) << idsToString(_requestedIds) << ':' << peername << ": new state with suspiciously large size" << status.size() << ", " << status.has_size() ;
		}
		if ( overlaps(_reqParameters->requesters, status.servers().begin(), status.servers().end()) ) {
			BOOST_LOG_SEV(assetLogger, bithorded::debug) << idsToString(_requestedIds) << " Loop detected " << peername;
			dropUpstream(peername);
		} else {
			BOOST_LOG_SEV(assetLogger, bithorded::debug) << idsToString(_requestedIds) << " Found upstream " << peername;
			if (status.has_size()) {
				if (_size == -1) {
					_size = status.size();
				} else if (_size != (int64_t)status.size()) {
					BOOST_LOG_SEV(assetLogger, bithorded::warning) << peername << " " << idsToString(_requestedIds) << " responded with mismatching size, ignoring...";
					dropUpstream(peername);
				}
			} else if (status.ids().size()) {
				BOOST_LOG_SEV(assetLogger, bithorded::warning) << peername << " " << idsToString(_requestedIds) << " SUCCESS response not accompanied with asset-size.";
			}
		}
	} else {
		BOOST_LOG_SEV(assetLogger, bithorded::debug) << idsToString(_requestedIds) << " Failed upstream " << peername;
		dropUpstream(peername);
	}
	updateStatus();
}
Exemple #2
0
bool operator==(const bithorde::AssetStatus& a, const bithorde::AssetStatus& b)
{
	if (a.status() != b.status())
		return false;
	if (a.size() != b.size())
		return false;
	if (a.availability() != b.availability())
		return false;

	if (a.ids() != b.ids()) {
		return false;
	}
	if (a.servers() != b.servers()) {
		return false;
	}

	return true;
}