@@ -116,8 +116,8 @@ class Adapter : public Node::IObserver, public IAdapter {
116116
117117private:
118118 void init_helper_fragments () {
119- static const char * s = " [,]" ;
120- io::SharedBuffer buf (s, 3 );
119+ static const char * s = " [,]\" " ;
120+ io::SharedBuffer buf (s, 4 );
121121 _leftBrace = buf;
122122 _leftBrace.size = 1 ;
123123 _comma = buf;
@@ -126,6 +126,9 @@ class Adapter : public Node::IObserver, public IAdapter {
126126 _rightBrace = buf;
127127 _rightBrace.size = 1 ;
128128 _rightBrace.data += 2 ;
129+ _quote = buf;
130+ _quote.size = 1 ;
131+ _quote.data += 3 ;
129132 }
130133
131134 // / Returns body for /status request
@@ -174,7 +177,8 @@ class Adapter : public Node::IObserver, public IAdapter {
174177 { " height" , _cache.currentHeight },
175178 { " low_horizon" , _nodeBackend.m_Extra .m_LoHorizon },
176179 { " hash" , hash_to_hex (buf, cursor.m_ID .m_Hash ) },
177- { " chainwork" , uint256_to_hex (buf, cursor.m_Full .m_ChainWork ) }
180+ { " chainwork" , uint256_to_hex (buf, cursor.m_Full .m_ChainWork ) },
181+ { " peers_count" , _node.get_AcessiblePeerCount () }
178182 }
179183 )) {
180184 return false ;
@@ -389,14 +393,42 @@ class Adapter : public Node::IObserver, public IAdapter {
389393 return true ;
390394 }
391395
396+ bool get_peers (io::SerializedMsg& out) override
397+ {
398+ auto & peers = _node.get_AcessiblePeerAddrs ();
399+
400+ out.push_back (_leftBrace);
401+
402+ for (auto & peer : peers)
403+ {
404+ auto addr = peer.get_ParentObj ().m_Addr .m_Value .str ();
405+
406+ {
407+ out.push_back (_quote);
408+ out.push_back ({ addr.data (), addr.size () });
409+ out.push_back (_quote);
410+ }
411+
412+ out.push_back (_comma);
413+ }
414+
415+ // remove last comma
416+ if (!peers.empty ())
417+ out.pop_back ();
418+
419+ out.push_back (_rightBrace);
420+
421+ return true ;
422+ }
423+
392424 HttpMsgCreator _packer;
393425
394426 // node db interface
395427 Node& _node;
396428 NodeProcessor& _nodeBackend;
397429
398430 // helper fragments
399- io::SharedBuffer _leftBrace, _comma, _rightBrace;
431+ io::SharedBuffer _leftBrace, _comma, _rightBrace, _quote ;
400432
401433 // If true then status boby needs to be refreshed
402434 bool _statusDirty;
@@ -418,4 +450,3 @@ IAdapter::Ptr create_adapter(Node& node) {
418450}
419451
420452}} // namespaces
421-
0 commit comments