summaryrefslogtreecommitdiff
path: root/src/PeerSessionResource.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2015-12-27 18:39:47 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2015-12-27 18:40:08 +0900
commitb1132d6b10cd3791b9529d7031d723fd0e2d8215 (patch)
tree9ce465b42bf09372118335c7c619bb2b41869eaf /src/PeerSessionResource.cc
parent4abad2f64c9ff80144a61c5a9c2bea144852b883 (diff)
make clang-format using clang-format-3.6
Diffstat (limited to 'src/PeerSessionResource.cc')
-rw-r--r--src/PeerSessionResource.cc90
1 files changed, 35 insertions, 55 deletions
diff --git a/src/PeerSessionResource.cc b/src/PeerSessionResource.cc
index 1a2fec9a..75c5ed9a 100644
--- a/src/PeerSessionResource.cc
+++ b/src/PeerSessionResource.cc
@@ -45,63 +45,48 @@
namespace aria2 {
-PeerSessionResource::PeerSessionResource(int32_t pieceLength, int64_t totalLength)
- :
- bitfieldMan_(make_unique<BitfieldMan>(pieceLength, totalLength)),
- lastDownloadUpdate_(Timer::zero()),
- lastAmUnchoking_(Timer::zero()),
- dispatcher_(nullptr),
- amChoking_(true),
- amInterested_(false),
- peerChoking_(true),
- peerInterested_(false),
- chokingRequired_(true),
- optUnchoking_(false),
- snubbing_(false),
- fastExtensionEnabled_(false),
- extendedMessagingEnabled_(false),
- dhtEnabled_(false)
-{}
-
-PeerSessionResource::~PeerSessionResource()
-{}
+PeerSessionResource::PeerSessionResource(int32_t pieceLength,
+ int64_t totalLength)
+ : bitfieldMan_(make_unique<BitfieldMan>(pieceLength, totalLength)),
+ lastDownloadUpdate_(Timer::zero()),
+ lastAmUnchoking_(Timer::zero()),
+ dispatcher_(nullptr),
+ amChoking_(true),
+ amInterested_(false),
+ peerChoking_(true),
+ peerInterested_(false),
+ chokingRequired_(true),
+ optUnchoking_(false),
+ snubbing_(false),
+ fastExtensionEnabled_(false),
+ extendedMessagingEnabled_(false),
+ dhtEnabled_(false)
+{
+}
+
+PeerSessionResource::~PeerSessionResource() {}
void PeerSessionResource::amChoking(bool b)
{
amChoking_ = b;
- if(!b) {
+ if (!b) {
lastAmUnchoking_ = global::wallclock();
}
}
-void PeerSessionResource::amInterested(bool b)
-{
- amInterested_ = b;
-}
+void PeerSessionResource::amInterested(bool b) { amInterested_ = b; }
-void PeerSessionResource::peerChoking(bool b)
-{
- peerChoking_ = b;
-}
+void PeerSessionResource::peerChoking(bool b) { peerChoking_ = b; }
-void PeerSessionResource::peerInterested(bool b)
-{
- peerInterested_ = b;
-}
+void PeerSessionResource::peerInterested(bool b) { peerInterested_ = b; }
-void PeerSessionResource::chokingRequired(bool b)
-{
- chokingRequired_ = b;
-}
+void PeerSessionResource::chokingRequired(bool b) { chokingRequired_ = b; }
-void PeerSessionResource::optUnchoking(bool b)
-{
- optUnchoking_ = b;
-}
+void PeerSessionResource::optUnchoking(bool b) { optUnchoking_ = b; }
bool PeerSessionResource::shouldBeChoking() const
{
- if(optUnchoking_) {
+ if (optUnchoking_) {
return false;
}
return chokingRequired_;
@@ -110,7 +95,7 @@ bool PeerSessionResource::shouldBeChoking() const
void PeerSessionResource::snubbing(bool b)
{
snubbing_ = b;
- if(snubbing_) {
+ if (snubbing_) {
chokingRequired(true);
optUnchoking(false);
}
@@ -123,15 +108,16 @@ bool PeerSessionResource::hasAllPieces() const
void PeerSessionResource::updateBitfield(size_t index, int operation)
{
- if(operation == 1) {
+ if (operation == 1) {
bitfieldMan_->setBit(index);
- } else if(operation == 0) {
+ }
+ else if (operation == 0) {
bitfieldMan_->unsetBit(index);
}
}
-void PeerSessionResource::setBitfield
-(const unsigned char* bitfield, size_t bitfieldLength)
+void PeerSessionResource::setBitfield(const unsigned char* bitfield,
+ size_t bitfieldLength)
{
bitfieldMan_->setBitfield(bitfield, bitfieldLength);
}
@@ -151,10 +137,7 @@ bool PeerSessionResource::hasPiece(size_t index) const
return bitfieldMan_->isBitSet(index);
}
-void PeerSessionResource::markSeeder()
-{
- bitfieldMan_->setAllBit();
-}
+void PeerSessionResource::markSeeder() { bitfieldMan_->setAllBit(); }
void PeerSessionResource::fastExtensionEnabled(bool b)
{
@@ -206,10 +189,7 @@ void PeerSessionResource::addExtension(int key, uint8_t id)
extreg_.setExtensionMessageID(key, id);
}
-void PeerSessionResource::dhtEnabled(bool b)
-{
- dhtEnabled_ = b;
-}
+void PeerSessionResource::dhtEnabled(bool b) { dhtEnabled_ = b; }
int64_t PeerSessionResource::uploadLength() const
{