switch the lock type (#165)
This commit is contained in:
parent
4a32ce0a19
commit
cf3d984548
@ -21,6 +21,7 @@ use ethers::abi::AbiEncode;
|
|||||||
use ethers::types::{Address, Block, TransactionReceipt, TxHash, H256};
|
use ethers::types::{Address, Block, TransactionReceipt, TxHash, H256};
|
||||||
use hashbrown::{HashMap, HashSet};
|
use hashbrown::{HashMap, HashSet};
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
|
use migration::LockType;
|
||||||
use migration::sea_orm::prelude::Decimal;
|
use migration::sea_orm::prelude::Decimal;
|
||||||
use migration::sea_orm::{
|
use migration::sea_orm::{
|
||||||
self, ActiveModelTrait, ActiveValue, ColumnTrait, EntityTrait, IntoActiveModel, ModelTrait,
|
self, ActiveModelTrait, ActiveValue, ColumnTrait, EntityTrait, IntoActiveModel, ModelTrait,
|
||||||
@ -236,7 +237,7 @@ pub async fn user_balance_post(
|
|||||||
|
|
||||||
// check for uncles
|
// check for uncles
|
||||||
let mut find_uncles = increase_on_chain_balance_receipt::Entity::find()
|
let mut find_uncles = increase_on_chain_balance_receipt::Entity::find()
|
||||||
// .lock_exclusive()
|
.lock(LockType::Update)
|
||||||
.filter(increase_on_chain_balance_receipt::Column::TxHash.eq(tx_hash.encode_hex()))
|
.filter(increase_on_chain_balance_receipt::Column::TxHash.eq(tx_hash.encode_hex()))
|
||||||
.filter(increase_on_chain_balance_receipt::Column::ChainId.eq(app.config.chain_id));
|
.filter(increase_on_chain_balance_receipt::Column::ChainId.eq(app.config.chain_id));
|
||||||
|
|
||||||
@ -526,7 +527,7 @@ pub async fn handle_uncle_block(
|
|||||||
|
|
||||||
// delete any deposit txids with uncle_hash
|
// delete any deposit txids with uncle_hash
|
||||||
for reversed_deposit in increase_on_chain_balance_receipt::Entity::find()
|
for reversed_deposit in increase_on_chain_balance_receipt::Entity::find()
|
||||||
.lock_exclusive()
|
.lock(LockType::Update)
|
||||||
.filter(increase_on_chain_balance_receipt::Column::BlockHash.eq(uncle_hash.encode_hex()))
|
.filter(increase_on_chain_balance_receipt::Column::BlockHash.eq(uncle_hash.encode_hex()))
|
||||||
.all(&txn)
|
.all(&txn)
|
||||||
.await?
|
.await?
|
||||||
@ -545,7 +546,7 @@ pub async fn handle_uncle_block(
|
|||||||
|
|
||||||
for (user_id, reversed_balance) in reversed_balances.iter() {
|
for (user_id, reversed_balance) in reversed_balances.iter() {
|
||||||
if let Some(user_balance) = balance::Entity::find()
|
if let Some(user_balance) = balance::Entity::find()
|
||||||
.lock_exclusive()
|
.lock(LockType::Update)
|
||||||
.filter(balance::Column::Id.eq(*user_id))
|
.filter(balance::Column::Id.eq(*user_id))
|
||||||
.one(&txn)
|
.one(&txn)
|
||||||
.await?
|
.await?
|
||||||
|
Loading…
Reference in New Issue
Block a user