From 63db2eafd9be157192ae19657c9efcf856bafd86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= Date: Mon, 7 May 2018 17:39:53 -0400 Subject: [PATCH] dht: print detailed request state in search log --- src/dht.cpp | 5 +---- src/request.h | 9 +++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/dht.cpp b/src/dht.cpp index a80c9ef6..5c07d4c6 100644 --- a/src/dht.cpp +++ b/src/dht.cpp @@ -1540,10 +1540,7 @@ Dht::dumpSearch(const Search& sr, std::ostream& out) const if (ack == n.acked.end() or not ack->second.first) { out << ' '; } else { - if (ack->second.first->completed()) - out << 'a'; - else if (ack->second.first->pending()) - out << 'f'; + out << ack->second.first->getStateChar(); } } out << "] "; diff --git a/src/request.h b/src/request.h index 3c04cd34..9044b596 100644 --- a/src/request.h +++ b/src/request.h @@ -57,6 +57,15 @@ struct Request { bool pending() const { return state_ == State::PENDING; } bool over() const { return not pending(); } State getState() const { return state_; } + char getStateChar() const { + switch (state_) { + case State::PENDING: return 'f'; + case State::CANCELLED: return 'c'; + case State::EXPIRED: return 'e'; + case State::COMPLETED: return 'a'; + default: return '?'; + } + } Request(State state = State::PENDING) : state_(state) {} Request(MessageType type, Tid tid,