dht: print detailed request state in search log

This commit is contained in:
Adrien Béraud committed 2018-05-07 17:43:31 -04:00
1 parent 68f52a815d
commit 63db2eafd9
2 files changed
+10 -4

No files matched your search

+1 -4
View File
@@ -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 << "] ";
+9
View File
@@ -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,