@@ -737,16 +737,28 @@ UniValue revokebeacon(const UniValue& params, bool fHelp)
737737
738738UniValue beaconreport (const UniValue& params, bool fHelp )
739739{
740- if (fHelp || params.size () > 0 )
740+ if (fHelp || params.size () > 1 )
741741 throw runtime_error (
742- " beaconreport\n "
742+ " beaconreport <active only>\n "
743+ " \n "
744+ " <active only> Boolean specifying whether only active beacons should be \n "
745+ " returned. Defaults to false which also includes expired beacons."
743746 " \n "
744747 " Displays list of valid beacons in the network\n " );
745748
749+ bool active_only = false ;
750+
751+ if (params.size () == 1 )
752+ {
753+ active_only = params[0 ].getBool ();
754+ }
755+
746756 UniValue results (UniValue::VARR);
747757
748758 std::vector<std::pair<GRC::Cpid, GRC::Beacon_ptr>> active_beacon_ptrs;
749759
760+ int64_t now = GetAdjustedTime ();
761+
750762 // Minimize the lock on cs_main.
751763 {
752764 LOCK (cs_main);
@@ -761,6 +773,8 @@ UniValue beaconreport(const UniValue& params, bool fHelp)
761773 {
762774 UniValue entry (UniValue::VOBJ);
763775
776+ if (active_only && beacon_pair.second ->Expired (now)) continue ;
777+
764778 entry.pushKV (" cpid" , beacon_pair.first .ToString ());
765779 entry.pushKV (" address" , beacon_pair.second ->GetAddress ().ToString ());
766780 entry.pushKV (" timestamp" , beacon_pair.second ->m_timestamp );
0 commit comments