Compare commits

...

1 commit

Author SHA1 Message Date
Koneru Satyanarayana
a52d4051bc SON118 - Add tx sign metrics for SON rewards 2020-03-04 23:41:52 +11:00
5 changed files with 17 additions and 0 deletions

View file

@ -153,6 +153,7 @@ void database::pay_sons()
//Reset the tx counter in each son statistics object //Reset the tx counter in each son statistics object
modify( s, [&]( son_statistics_object& _s) modify( s, [&]( son_statistics_object& _s)
{ {
_s.total_txs_signed += _s.txs_signed;
_s.txs_signed = 0; _s.txs_signed = 0;
}); });
} }

View file

@ -30,6 +30,8 @@ namespace graphene { namespace chain {
static const uint8_t type_id = impl_son_statistics_object_type; static const uint8_t type_id = impl_son_statistics_object_type;
son_id_type owner; son_id_type owner;
// Lifetime total transactions signed
uint64_t total_txs_signed = 0;
// Transactions signed since the last son payouts // Transactions signed since the last son payouts
uint64_t txs_signed = 0; uint64_t txs_signed = 0;
// Total Downtime barring the current down time in seconds, used for stats to present to user // Total Downtime barring the current down time in seconds, used for stats to present to user
@ -103,6 +105,7 @@ FC_REFLECT_DERIVED( graphene::chain::son_object, (graphene::db::object),
FC_REFLECT_DERIVED( graphene::chain::son_statistics_object, FC_REFLECT_DERIVED( graphene::chain::son_statistics_object,
(graphene::db::object), (graphene::db::object),
(owner) (owner)
(total_txs_signed)
(txs_signed) (txs_signed)
(total_downtime) (total_downtime)
(current_interval_downtime) (current_interval_downtime)

View file

@ -75,6 +75,10 @@ object_id_type bitcoin_transaction_sign_evaluator::do_apply(const bitcoin_transa
po.proposed_transaction.operations[0] = bitcoin_transaction_send_op; po.proposed_transaction.operations[0] = bitcoin_transaction_send_op;
}); });
db().modify( son_obj->statistics( db() ), [&]( son_statistics_object& sso ) {
sso.txs_signed += 1;
} );
update_proposal(op); update_proposal(op);
} }
FC_CAPTURE_AND_RETHROW((op)) FC_CAPTURE_AND_RETHROW((op))

View file

@ -296,6 +296,12 @@ BOOST_AUTO_TEST_CASE(bitcoin_transaction_send_test)
BOOST_REQUIRE(btobj->processed == false); BOOST_REQUIRE(btobj->processed == false);
auto stats1 = son_obj1->statistics( db );
auto stats2 = son_obj2->statistics( db );
BOOST_REQUIRE(stats1.txs_signed == 1);
BOOST_REQUIRE(stats2.txs_signed == 1);
auto sigs = btobj->signatures; auto sigs = btobj->signatures;
BOOST_REQUIRE(sigs[son_obj1->id][0] == a1); BOOST_REQUIRE(sigs[son_obj1->id][0] == a1);

View file

@ -513,6 +513,9 @@ BOOST_AUTO_TEST_CASE( son_pay_test )
// Check if the signed transaction statistics are reset for both SONs // Check if the signed transaction statistics are reset for both SONs
BOOST_REQUIRE_EQUAL(son_stats_obj1->txs_signed, 0); BOOST_REQUIRE_EQUAL(son_stats_obj1->txs_signed, 0);
BOOST_REQUIRE_EQUAL(son_stats_obj2->txs_signed, 0); BOOST_REQUIRE_EQUAL(son_stats_obj2->txs_signed, 0);
BOOST_REQUIRE_EQUAL(son_stats_obj1->total_txs_signed, 2);
BOOST_REQUIRE_EQUAL(son_stats_obj2->total_txs_signed, 3);
// Check that Alice and Bob are paid for signing the transactions in the previous day/cycle // Check that Alice and Bob are paid for signing the transactions in the previous day/cycle
BOOST_REQUIRE_EQUAL(db.get_balance(obj1->son_account, asset_id_type()).amount.value, 80+obj1_balance); BOOST_REQUIRE_EQUAL(db.get_balance(obj1->son_account, asset_id_type()).amount.value, 80+obj1_balance);
BOOST_REQUIRE_EQUAL(db.get_balance(obj2->son_account, asset_id_type()).amount.value, 120+obj2_balance); BOOST_REQUIRE_EQUAL(db.get_balance(obj2->son_account, asset_id_type()).amount.value, 120+obj2_balance);