mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-19 02:25:52 +00:00
Tidy up Resource::Manager APIs
This commit is contained in:
@@ -39,7 +39,7 @@ public:
|
||||
Consumer& operator= (Consumer const& other);
|
||||
|
||||
/** Return a human readable string uniquely identifying this consumer. */
|
||||
std::string label ();
|
||||
std::string to_string () const;
|
||||
|
||||
/** Returns `true` if this is a privileged endpoint. */
|
||||
bool admin () const;
|
||||
@@ -77,6 +77,8 @@ private:
|
||||
Entry* m_entry;
|
||||
};
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, Consumer const& v);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,12 +77,12 @@ Consumer& Consumer::operator= (Consumer const& other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::string Consumer::label ()
|
||||
std::string Consumer::to_string () const
|
||||
{
|
||||
if (m_logic == nullptr)
|
||||
return "(none)";
|
||||
|
||||
return m_entry->label();
|
||||
return m_entry->to_string();
|
||||
}
|
||||
|
||||
bool Consumer::admin () const
|
||||
@@ -125,5 +125,11 @@ Entry& Consumer::entry()
|
||||
return *m_entry;
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, Consumer const& v)
|
||||
{
|
||||
os << v.to_string();
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ struct Entry : public List <Entry>::Node
|
||||
{
|
||||
}
|
||||
|
||||
std::string label() const
|
||||
std::string to_string() const
|
||||
{
|
||||
switch (key->kind)
|
||||
{
|
||||
@@ -91,6 +91,12 @@ struct Entry : public List <Entry>::Node
|
||||
DiscreteTime whenExpires;
|
||||
};
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, Entry const& v)
|
||||
{
|
||||
os << v.to_string();
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
m_journal.debug << "New inbound endpoint " << entry->label();
|
||||
m_journal.debug << "New inbound endpoint " << entry;
|
||||
|
||||
return Consumer (*this, *entry);
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
m_journal.debug << "New outbound endpoint " << entry->label();
|
||||
m_journal.debug << "New outbound endpoint " << entry;
|
||||
|
||||
return Consumer (*this, *entry);
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
m_journal.debug << "New admin endpoint " << entry->label();
|
||||
m_journal.debug << "New admin endpoint " << entry;
|
||||
|
||||
return Consumer (*this, *entry);
|
||||
}
|
||||
@@ -184,7 +184,7 @@ public:
|
||||
key.kind = kindAdmin;
|
||||
key.name = name;
|
||||
|
||||
m_journal.info << "Elevate " << prior.label() << " to " << name;
|
||||
m_journal.info << "Elevate " << prior << " to " << name;
|
||||
|
||||
Entry* entry (nullptr);
|
||||
|
||||
@@ -315,7 +315,7 @@ public:
|
||||
{
|
||||
if (iter->whenExpires <= now)
|
||||
{
|
||||
m_journal.debug << "Expired " << iter->label();
|
||||
m_journal.debug << "Expired " << *iter;
|
||||
Table::iterator table_iter (
|
||||
state->table.find (*iter->key));
|
||||
++iter;
|
||||
@@ -367,7 +367,7 @@ public:
|
||||
{
|
||||
if (--entry.refcount == 0)
|
||||
{
|
||||
m_journal.debug << "Inactive " << entry.label();
|
||||
m_journal.debug << "Inactive " << entry;
|
||||
switch (entry.key->kind)
|
||||
{
|
||||
case kindInbound:
|
||||
@@ -404,7 +404,7 @@ public:
|
||||
{
|
||||
DiscreteTime const now (m_clock());
|
||||
int const balance (entry.add (fee.cost(), now));
|
||||
m_journal.info << "Charging " << entry.label() << " for " << fee;
|
||||
m_journal.info << "Charging " << entry << " for " << fee;
|
||||
return disposition (balance);
|
||||
}
|
||||
|
||||
@@ -420,7 +420,7 @@ public:
|
||||
}
|
||||
|
||||
if (notify)
|
||||
m_journal.info << "Load warning: " << entry.label();
|
||||
m_journal.info << "Load warning: " << entry;
|
||||
|
||||
return notify;
|
||||
}
|
||||
@@ -499,7 +499,7 @@ public:
|
||||
PropertyStream::Map item (items);
|
||||
if (iter->refcount != 0)
|
||||
item ["count"] = iter->refcount;
|
||||
item ["name"] = iter->label();
|
||||
item ["name"] = iter->to_string();
|
||||
item ["balance"] = iter->balance(now);
|
||||
if (iter->remote_balance != 0)
|
||||
item ["remote_balance"] = iter->remote_balance;
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
{
|
||||
IPAddress address (IPAddress::from_string ("207.127.82.1"));
|
||||
Consumer c (logic.newInboundEndpoint (address));
|
||||
logMessage ("Charging " + c.label() + " 10,000 units");
|
||||
logMessage ("Charging " + c.to_string() + " 10,000 units");
|
||||
c.charge (10000);
|
||||
for (int i = 0; i < 128; ++i)
|
||||
{
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
{
|
||||
IPAddress address (IPAddress::from_string ("207.127.82.2"));
|
||||
Consumer c (logic.newInboundEndpoint (address));
|
||||
logMessage ("Charging " + c.label() + " 1000 units per second");
|
||||
logMessage ("Charging " + c.to_string() + " 1000 units per second");
|
||||
for (int i = 0; i < 128; ++i)
|
||||
{
|
||||
c.charge (1000);
|
||||
|
||||
Reference in New Issue
Block a user