async fn redis_update_account(
        &self,
        encrypted: &AccountWithEncryptedTokens,
    ) -> Result<(), NodeStoreError> {
        let account = encrypted.account.clone();
        let mut connection = self.connection.clone();
        let routing_table = self.routes.clone();

        // Check to make sure an account with this ID already exists
        // TODO this needs to be atomic with the insertions later,
        // waiting on #186
        // TODO: Do not allow this update to happen if
        // AccountDetails.RoutingRelation == Parent and parent is
        // already set
        let exists: bool = connection
            .exists(accounts_key(&self.db_prefix, account.id))
            .await?;

        if !exists {
            warn!(
                "No account exists with ID {}, cannot update account {:?}",
                account.id, account
            );
            return Err(NodeStoreError::AccountNotFound(account.id.to_string()));
        }
        let mut pipe = redis_crate::pipe();
        pipe.atomic();

        // Add the account key to the list of accounts
        pipe.sadd(
            &*prefixed_key(&self.db_prefix, ACCOUNTS_KEY),
            RedisAccountId(account.id),
        )
        .ignore();

        // Set account details
        pipe.cmd("HMSET")
            .arg(accounts_key(&self.db_prefix, account.id))
            .arg(encrypted)
            .ignore();

        if account.should_send_routes() {
            pipe.sadd(
                &*prefixed_key(&self.db_prefix, SEND_ROUTES_KEY),
                RedisAccountId(account.id),
            )
            .ignore();
        }

        if account.should_receive_routes() {
            pipe.sadd(
                &*prefixed_key(&self.db_prefix, RECEIVE_ROUTES_FROM_KEY),
                RedisAccountId(account.id),
            )
            .ignore();
        }

        if account.ilp_over_btp_url.is_some() {
            pipe.sadd(
                &*prefixed_key(&self.db_prefix, BPT_OUTGOING),
                RedisAccountId(account.id),
            )
            .ignore();
        }

        // Add route to routing table
        pipe.hset(
            &*prefixed_key(&self.db_prefix, ROUTES_KEY),
            account.ilp_address.to_bytes().to_vec(),
            RedisAccountId(account.id),
        )
        .ignore();

        pipe.query_async(&mut connection).await?;
        update_routes(connection, routing_table, &self.db_prefix).await?;
        debug!(
            "Inserted account {} (id: {}, ILP address: {})",
            account.username, account.id, account.ilp_address
        );
        Ok(())
    }
/// Overwrites the account corresponding to the provided `AccountWithEncryptedtokens`
/// in Redis. Returns the provided account (tokens remain encrypted)
Overwrites the account corresponding to the provided `AccountWithEncryptedtokens`
in Redis. Returns the provided account (tokens remain encrypted)
Overwrites the account corresponding to the provided ` AccountWithEncryptedtokens ` in Redis . Returns the provided account ( tokens remain encrypted )
async fn redis_update_account(
        &self,
        encrypted: &AccountWithEncryptedTokens,
    ) -> Result<(), NodeStoreError> {
        let account = encrypted.account.clone();
        let mut connection = self.connection.clone();
        let routing_table = self.routes.clone();
        // Check to make sure an account with this ID already exists
        // TODO this needs to be atomic with the insertions later,
        // waiting on #186
        // TODO: Do not allow this update to happen if
        // AccountDetails.RoutingRelation == Parent and parent is
        // already set
        let exists: bool = connection
            .exists(accounts_key(&self.db_prefix, account.id))
            .await?;
        if !exists {
            warn!(
                "No account exists with ID {}, cannot update account {:?}",
                account.id, account
            );
            return Err(NodeStoreError::AccountNotFound(account.id.to_string()));
        }
        let mut pipe = redis_crate::pipe();
        pipe.atomic();
        // Add the account key to the list of accounts
        pipe.sadd(
            &*prefixed_key(&self.db_prefix, ACCOUNTS_KEY),
            RedisAccountId(account.id),
        )
        .ignore();
        // Set account details
        pipe.cmd("HMSET")
            .arg(accounts_key(&self.db_prefix, account.id))
            .arg(encrypted)
            .ignore();
        if account.should_send_routes() {
            pipe.sadd(
                &*prefixed_key(&self.db_prefix, SEND_ROUTES_KEY),
                RedisAccountId(account.id),
            )
            .ignore();
        }
        if account.should_receive_routes() {
            pipe.sadd(
                &*prefixed_key(&self.db_prefix, RECEIVE_ROUTES_FROM_KEY),
                RedisAccountId(account.id),
            )
            .ignore();
        }
        if account.ilp_over_btp_url.is_some() {
            pipe.sadd(
                &*prefixed_key(&self.db_prefix, BPT_OUTGOING),
                RedisAccountId(account.id),
            )
            .ignore();
        }
        // Add route to routing table
        pipe.hset(
            &*prefixed_key(&self.db_prefix, ROUTES_KEY),
            account.ilp_address.to_bytes().to_vec(),
            RedisAccountId(account.id),
        )
        .ignore();
        pipe.query_async(&mut connection).await?;
        update_routes(connection, routing_table, &self.db_prefix).await?;
        debug!(
            "Inserted account {} (id: {}, ILP address: {})",
            account.username, account.id, account.ilp_address
        );
        Ok(())
    }
async fn redis_update_account ( & self , encrypted : & AccountWithEncryptedTokens , ) -> Result < ( ) , NodeStoreError > { let account = encrypted . account . clone ( ) ; let mut connection = self . connection . clone ( ) ; let routing_table = self . routes . clone ( ) ; // Check to make sure an account with this ID already exists // TODO this needs to be atomic with the insertions later, // waiting on #186 // TODO: Do not allow this update to happen if // AccountDetails.RoutingRelation == Parent and parent is // already set let exists : bool = connection . exists ( accounts_key ( & self . db_prefix , account . id ) ) . await ? ; if ! exists { warn ! ( " " account id account ) ; return Err ( NodeStoreError :: AccountNotFound ( account . id . to_string ( ) ) ) ; } let mut pipe = redis_crate :: pipe ( ) ; pipe . atomic ( ) ; // Add the account key to the list of accounts pipe . sadd ( & * prefixed_key ( & self . db_prefix , ACCOUNTS_KEY ) , RedisAccountId ( account . id ) , ) . ignore ( ) ; // Set account details pipe . cmd ( " " ) . arg ( accounts_key ( & self . db_prefix , account . id ) ) . arg ( encrypted ) . ignore ( ) ; if account . should_send_routes ( ) { pipe . sadd ( & * prefixed_key ( & self . db_prefix , SEND_ROUTES_KEY ) , RedisAccountId ( account . id ) , ) . ignore ( ) ; } if account . should_receive_routes ( ) { pipe . sadd ( & * prefixed_key ( & self . db_prefix , RECEIVE_ROUTES_FROM_KEY ) , RedisAccountId ( account . id ) , ) . ignore ( ) ; } if account . ilp_over_btp_url . is_some ( ) { pipe . sadd ( & * prefixed_key ( & self . db_prefix , BPT_OUTGOING ) , RedisAccountId ( account . id ) , ) . ignore ( ) ; } // Add route to routing table pipe . hset ( & * prefixed_key ( & self . db_prefix , ROUTES_KEY ) , account . ilp_address . to_bytes ( ) . to_vec ( ) , RedisAccountId ( account . id ) , ) . ignore ( ) ; pipe . query_async ( & mut connection ) . await ? ; update_routes ( connection , routing_table , & self . db_prefix ) . await ? ; debug ! ( " " account username account id account ilp_address ) ; Ok ( ( ) ) }
Overwrites the account corresponding to the provided `AccountWithEncryptedtokens`
in Redis.
Overwrites the account corresponding to the provided ` AccountWithEncryptedtokens ` in Redis .
&self
encrypted
&AccountWithEncryptedTokens
&self
encrypted
&AccountWithEncryptedTokens