Beispiel #1
0
   oWalletContactEntry WalletDb::lookup_contact( const string& label )const
   { try {
       FC_ASSERT( is_open() ,"Wallet not open!");
       FC_ASSERT( !label.empty() );

       const auto iter = label_to_account_or_contact.find( label );
       if( iter != label_to_account_or_contact.end() ) return lookup_contact( variant( iter->second ) );

       return oWalletContactEntry();
   } FC_CAPTURE_AND_RETHROW( (label) ) }
Beispiel #2
0
   oWalletContactEntry WalletDb::remove_contact( const string& label )
   { try {
       FC_ASSERT( is_open() ,"Wallet not open!");
       FC_ASSERT( !label.empty() );

       oWalletContactEntry entry = lookup_contact( label );
       if( entry.valid() )
           return remove_contact( entry->data );

       return entry;
   } FC_CAPTURE_AND_RETHROW( (label) ) }
Beispiel #3
0
   owallet_contact_record wallet_db::remove_contact( const string& label )
   { try {
       FC_ASSERT( is_open() );
       FC_ASSERT( !label.empty() );

       owallet_contact_record record = lookup_contact( label );
       if( record.valid() )
           return remove_contact( record->data );

       return record;
   } FC_CAPTURE_AND_RETHROW( (label) ) }
Beispiel #4
0
   WalletContactEntry WalletDb::store_contact( const ContactData& contact )
   { try {
       FC_ASSERT( is_open() ,"Wallet not open!");
       FC_ASSERT( !contact.data.is_null() );
       FC_ASSERT( !contact.label.empty() );

       // Check for label collision
       oWalletContactEntry contact_entry = lookup_contact( contact.label );
       if( contact_entry.valid() && contact_entry->data.as_string() != contact.data.as_string() )
           FC_CAPTURE_AND_THROW( label_already_in_use, );

       contact_entry = lookup_contact( contact.data );
       if( !contact_entry.valid() )
           contact_entry = WalletContactEntry();
       else if( contact_entry->label != contact.label )
           label_to_account_or_contact.erase( contact_entry->label );

       ContactData& temp = *contact_entry;
       temp = contact;

       store_and_reload_entry( *contact_entry );
       return *contact_entry;
   } FC_CAPTURE_AND_RETHROW( (contact) ) }
Beispiel #5
0
   wallet_contact_record wallet_db::store_contact( const contact_data& contact )
   { try {
       FC_ASSERT( is_open() );
       FC_ASSERT( !contact.data.is_null() );
       FC_ASSERT( !contact.label.empty() );

       // Check for label collision
       owallet_contact_record contact_record = lookup_contact( contact.label );
       if( contact_record.valid() && contact_record->data.as_string() != contact.data.as_string() )
           FC_CAPTURE_AND_THROW( label_already_in_use, );

       contact_record = lookup_contact( contact.data );
       if( !contact_record.valid() )
           contact_record = wallet_contact_record();
       else if( contact_record->label != contact.label )
           label_to_account_or_contact.erase( contact_record->label );

       contact_data& temp = *contact_record;
       temp = contact;

       store_and_reload_record( *contact_record );
       return *contact_record;
   } FC_CAPTURE_AND_RETHROW( (contact) ) }
Beispiel #6
0
   oWalletContactEntry WalletDb::remove_contact( const variant& data )
   { try {
       FC_ASSERT( is_open() ,"Wallet not open!");
       FC_ASSERT( !data.is_null() );

       oWalletContactEntry entry = lookup_contact( data );
       if( entry.valid() )
       {
           label_to_account_or_contact.erase( entry->label );
           contacts.erase( data.as_string() );
           remove_item( entry->wallet_entry_index );
       }

       return entry;
   } FC_CAPTURE_AND_RETHROW( (data) ) }
Beispiel #7
0
   owallet_contact_record wallet_db::remove_contact( const variant& data )
   { try {
       FC_ASSERT( is_open() );
       FC_ASSERT( !data.is_null() );

       owallet_contact_record record = lookup_contact( data );
       if( record.valid() )
       {
           label_to_account_or_contact.erase( record->label );
           contacts.erase( data.as_string() );
           remove_item( record->wallet_record_index );
       }

       return record;
   } FC_CAPTURE_AND_RETHROW( (data) ) }