No longer extract public keys before pushing a trx
and removed unused new added constructor and _get_signature_keys() function from signed_transaction struct
This commit is contained in:
parent
62f81ee092
commit
f31782a59a
5 changed files with 16 additions and 47 deletions
|
|
@ -172,14 +172,9 @@ namespace graphene { namespace app {
|
|||
void network_broadcast_api::broadcast_transaction(const signed_transaction& trx)
|
||||
{
|
||||
trx.validate();
|
||||
|
||||
auto& chain_db = *_app.chain_database();
|
||||
chain_db.check_tansaction_for_duplicated_operations(trx);
|
||||
trx.get_signature_keys( chain_db.get_chain_id() ); // Extract public keys from signatures
|
||||
chain_db.push_transaction( trx );
|
||||
|
||||
if( _app.p2p_node() != nullptr )
|
||||
_app.p2p_node()->broadcast_transaction(trx);
|
||||
_app.chain_database()->check_tansaction_for_duplicated_operations(trx);
|
||||
_app.chain_database()->push_transaction(trx);
|
||||
_app.p2p_node()->broadcast_transaction(trx);
|
||||
}
|
||||
|
||||
fc::variant network_broadcast_api::broadcast_transaction_synchronous(const signed_transaction& trx)
|
||||
|
|
@ -205,13 +200,8 @@ namespace graphene { namespace app {
|
|||
{
|
||||
trx.validate();
|
||||
_callbacks[trx.id()] = cb;
|
||||
|
||||
auto& chain_db = *_app.chain_database();
|
||||
trx.get_signature_keys( chain_db.get_chain_id() ); // Extract public keys from signatures
|
||||
chain_db.push_transaction( trx );
|
||||
|
||||
if( _app.p2p_node() != nullptr )
|
||||
_app.p2p_node()->broadcast_transaction(trx);
|
||||
_app.chain_database()->push_transaction(trx);
|
||||
_app.p2p_node()->broadcast_transaction(trx);
|
||||
}
|
||||
|
||||
network_node_api::network_node_api( application& a ) : _app( a )
|
||||
|
|
|
|||
|
|
@ -535,9 +535,6 @@ namespace detail {
|
|||
}
|
||||
}
|
||||
|
||||
transaction_message.trx.get_signature_keys( get_chain_id() ); // Extract public keys from signatures
|
||||
|
||||
_chain_db->push_transaction( transaction_message.trx );
|
||||
return result;
|
||||
} catch ( const graphene::chain::unlinkable_block_exception& e ) {
|
||||
// translate to a graphene::net exception
|
||||
|
|
|
|||
|
|
@ -123,13 +123,6 @@ namespace graphene { namespace chain {
|
|||
signed_transaction( const transaction& trx = transaction() )
|
||||
: transaction(trx){}
|
||||
|
||||
/** Extract public keys from signatures when initializing with another signed transaction and a chain ID */
|
||||
signed_transaction( const signed_transaction& trx, const chain_id_type& chain_id )
|
||||
: signed_transaction(trx)
|
||||
{
|
||||
signees = _get_signature_keys( chain_id );
|
||||
}
|
||||
|
||||
/** signs and appends to signatures */
|
||||
const signature_type& sign( const private_key_type& key, const chain_id_type& chain_id );
|
||||
|
||||
|
|
@ -196,10 +189,6 @@ namespace graphene { namespace chain {
|
|||
|
||||
/// Removes all signatures and signees
|
||||
void clear_signatures() { signatures.clear(); signees.clear(); }
|
||||
|
||||
private:
|
||||
/// To be used by constructor and get_signature_keys() function
|
||||
flat_set<public_key_type> _get_signature_keys( const chain_id_type& chain_id )const;
|
||||
};
|
||||
|
||||
void verify_authority( const vector<operation>& ops, const flat_set<public_key_type>& sigs,
|
||||
|
|
|
|||
|
|
@ -299,32 +299,26 @@ void verify_authority( const vector<operation>& ops, const flat_set<public_key_t
|
|||
|
||||
|
||||
const flat_set<public_key_type>& signed_transaction::get_signature_keys( const chain_id_type& chain_id )const
|
||||
{
|
||||
{ try {
|
||||
// Strictly we should check whether the given chain ID is same as the one used to initialize the `signees` field.
|
||||
// However, we don't pass in another chain ID so far, for better performance, we skip the check.
|
||||
if( signees.empty() && !signatures.empty() )
|
||||
{
|
||||
signees = _get_signature_keys( chain_id );
|
||||
auto d = sig_digest( chain_id );
|
||||
flat_set<public_key_type> result;
|
||||
for( const auto& sig : signatures )
|
||||
{
|
||||
GRAPHENE_ASSERT(
|
||||
result.insert( fc::ecc::public_key(sig,d) ).second,
|
||||
tx_duplicate_sig,
|
||||
"Duplicate Signature detected" );
|
||||
}
|
||||
signees = std::move( result );
|
||||
}
|
||||
return signees;
|
||||
}
|
||||
|
||||
flat_set<public_key_type> signed_transaction::_get_signature_keys( const chain_id_type& chain_id )const
|
||||
{ try {
|
||||
auto d = sig_digest( chain_id );
|
||||
flat_set<public_key_type> result;
|
||||
for( const auto& sig : signatures )
|
||||
{
|
||||
GRAPHENE_ASSERT(
|
||||
result.insert( fc::ecc::public_key(sig,d) ).second,
|
||||
tx_duplicate_sig,
|
||||
"Duplicate Signature detected" );
|
||||
}
|
||||
return result;
|
||||
} FC_CAPTURE_AND_RETHROW() }
|
||||
|
||||
|
||||
|
||||
set<public_key_type> signed_transaction::get_required_signatures(
|
||||
const chain_id_type& chain_id,
|
||||
const flat_set<public_key_type>& available_keys,
|
||||
|
|
|
|||
|
|
@ -1561,7 +1561,6 @@ bool _push_block( database& db, const signed_block& b, uint32_t skip_flags /* =
|
|||
|
||||
processed_transaction _push_transaction( database& db, const signed_transaction& tx, uint32_t skip_flags /* = 0 */ )
|
||||
{ try {
|
||||
tx.get_signature_keys( db.get_chain_id() ); // Extract public keys from signatures
|
||||
auto pt = db.push_transaction( tx, skip_flags );
|
||||
database_fixture::verify_asset_supplies(db);
|
||||
return pt;
|
||||
|
|
|
|||
Loading…
Reference in a new issue