Single sidechain transaction signature per block allowed only
This commit is contained in:
parent
23d5779798
commit
09d7337cd3
4 changed files with 10 additions and 0 deletions
|
|
@ -30,6 +30,7 @@ namespace graphene { namespace chain {
|
||||||
|
|
||||||
sidechain_transaction_id_type sidechain_transaction_id;
|
sidechain_transaction_id_type sidechain_transaction_id;
|
||||||
std::string transaction;
|
std::string transaction;
|
||||||
|
block_id_type block;
|
||||||
bool complete;
|
bool complete;
|
||||||
|
|
||||||
account_id_type fee_payer()const { return payer; }
|
account_id_type fee_payer()const { return payer; }
|
||||||
|
|
@ -62,6 +63,7 @@ FC_REFLECT( graphene::chain::sidechain_transaction_sign_operation::fee_parameter
|
||||||
FC_REFLECT( graphene::chain::sidechain_transaction_sign_operation, (fee)(payer)
|
FC_REFLECT( graphene::chain::sidechain_transaction_sign_operation, (fee)(payer)
|
||||||
(sidechain_transaction_id)
|
(sidechain_transaction_id)
|
||||||
(transaction)
|
(transaction)
|
||||||
|
(block)
|
||||||
(complete) )
|
(complete) )
|
||||||
|
|
||||||
FC_REFLECT( graphene::chain::sidechain_transaction_send_operation::fee_parameters_type, (fee) )
|
FC_REFLECT( graphene::chain::sidechain_transaction_send_operation::fee_parameters_type, (fee) )
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ namespace graphene { namespace chain {
|
||||||
std::string transaction;
|
std::string transaction;
|
||||||
std::vector<std::pair<son_id_type, bool>> signers;
|
std::vector<std::pair<son_id_type, bool>> signers;
|
||||||
|
|
||||||
|
block_id_type block;
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
bool complete = false;
|
bool complete = false;
|
||||||
bool sent = false;
|
bool sent = false;
|
||||||
|
|
@ -62,6 +63,7 @@ FC_REFLECT_DERIVED( graphene::chain::sidechain_transaction_object, (graphene::db
|
||||||
(object_id)
|
(object_id)
|
||||||
(transaction)
|
(transaction)
|
||||||
(signers)
|
(signers)
|
||||||
|
(block)
|
||||||
(valid)
|
(valid)
|
||||||
(complete)
|
(complete)
|
||||||
(sent) )
|
(sent) )
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ object_id_type sidechain_transaction_create_evaluator::do_apply(const sidechain_
|
||||||
std::transform(op.signers.begin(), op.signers.end(), std::inserter(sto.signers, sto.signers.end()), [](const son_id_type son_id) {
|
std::transform(op.signers.begin(), op.signers.end(), std::inserter(sto.signers, sto.signers.end()), [](const son_id_type son_id) {
|
||||||
return std::make_pair(son_id, false);
|
return std::make_pair(son_id, false);
|
||||||
});
|
});
|
||||||
|
sto.block = db().head_block_id();
|
||||||
sto.valid = true;
|
sto.valid = true;
|
||||||
sto.complete = false;
|
sto.complete = false;
|
||||||
sto.sent = false;
|
sto.sent = false;
|
||||||
|
|
@ -60,6 +61,8 @@ void_result sidechain_transaction_sign_evaluator::do_evaluate(const sidechain_tr
|
||||||
}
|
}
|
||||||
FC_ASSERT(expected, "Signer not expected");
|
FC_ASSERT(expected, "Signer not expected");
|
||||||
|
|
||||||
|
FC_ASSERT(sto_obj->block == op.block, "Sidechain transaction already signed in this block");
|
||||||
|
|
||||||
FC_ASSERT(sto_obj->valid, "Transaction not valid");
|
FC_ASSERT(sto_obj->valid, "Transaction not valid");
|
||||||
FC_ASSERT(!sto_obj->complete, "Transaction signing completed");
|
FC_ASSERT(!sto_obj->complete, "Transaction signing completed");
|
||||||
FC_ASSERT(!sto_obj->sent, "Transaction already sent");
|
FC_ASSERT(!sto_obj->sent, "Transaction already sent");
|
||||||
|
|
@ -77,6 +80,7 @@ object_id_type sidechain_transaction_sign_evaluator::do_apply(const sidechain_tr
|
||||||
|
|
||||||
db().modify(*sto_obj, [&](sidechain_transaction_object &sto) {
|
db().modify(*sto_obj, [&](sidechain_transaction_object &sto) {
|
||||||
sto.transaction = op.transaction;
|
sto.transaction = op.transaction;
|
||||||
|
sto.block = db().head_block_id();
|
||||||
sto.complete = op.complete;
|
sto.complete = op.complete;
|
||||||
for (size_t i = 0; i < sto.signers.size(); i++) {
|
for (size_t i = 0; i < sto.signers.size(); i++) {
|
||||||
if (sto.signers.at(i).first == son_obj->id) {
|
if (sto.signers.at(i).first == son_obj->id) {
|
||||||
|
|
@ -113,6 +117,7 @@ object_id_type sidechain_transaction_send_evaluator::do_apply(const sidechain_tr
|
||||||
auto sto_obj = sto_idx.find(op.sidechain_transaction_id);
|
auto sto_obj = sto_idx.find(op.sidechain_transaction_id);
|
||||||
|
|
||||||
db().modify(*sto_obj, [&](sidechain_transaction_object &sto) {
|
db().modify(*sto_obj, [&](sidechain_transaction_object &sto) {
|
||||||
|
sto.block = db().head_block_id();
|
||||||
sto.sent = true;
|
sto.sent = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -258,6 +258,7 @@ void sidechain_net_handler::process_sidechain_transactions() {
|
||||||
sts_op.payer = plugin.get_current_son_object().son_account;
|
sts_op.payer = plugin.get_current_son_object().son_account;
|
||||||
sts_op.sidechain_transaction_id = sto.id;
|
sts_op.sidechain_transaction_id = sto.id;
|
||||||
sts_op.transaction = processed_sidechain_tx;
|
sts_op.transaction = processed_sidechain_tx;
|
||||||
|
sts_op.block = sto.block;
|
||||||
sts_op.complete = complete;
|
sts_op.complete = complete;
|
||||||
|
|
||||||
signed_transaction trx = database.create_signed_transaction(plugin.get_private_key(plugin.get_current_son_id()), sts_op);
|
signed_transaction trx = database.create_signed_transaction(plugin.get_private_key(plugin.get_current_son_id()), sts_op);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue