mtx fix
This commit is contained in:
parent
fdee5e3a0f
commit
b5d129c7de
@ -55,16 +55,17 @@ pub struct Mtx {
|
|||||||
variant: MtxVariant,
|
variant: MtxVariant,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply(tx: &mut Transaction, variant: MtxVariant, construct_id: Uuid, account: Uuid) -> Result<Account, Error> {
|
pub fn apply(tx: &mut Transaction, account: &Account, variant: MtxVariant, construct_id: Uuid) -> Result<Vec<Construct>, Error> {
|
||||||
let mtx = select(tx, variant, account)?;
|
let mtx = select(tx, variant, account.id)?;
|
||||||
let construct = construct_select(tx, construct_id, account)?;
|
let construct = construct_select(tx, construct_id, account.id)?;
|
||||||
|
|
||||||
match mtx.variant {
|
match mtx.variant {
|
||||||
MtxVariant::Reimage => reimage(tx, construct)?,
|
MtxVariant::Reimage => reimage(tx, construct)?,
|
||||||
_ => unimplemented!(),
|
_ => unimplemented!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
return account::debit(tx, account, 1);
|
account::debit(tx, account.id, 1)?;
|
||||||
|
account::account_constructs(tx, account)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reimage(tx: &mut Transaction, mut construct: Construct) -> Result<Construct, Error> {
|
pub fn reimage(tx: &mut Transaction, mut construct: Construct) -> Result<Construct, Error> {
|
||||||
|
|||||||
@ -143,7 +143,9 @@ pub fn receive(data: Vec<u8>, db: &Db, _client: &mut MnmlWs, begin: Instant, acc
|
|||||||
RpcRequest::VboxUnequip { instance_id, construct_id, target } =>
|
RpcRequest::VboxUnequip { instance_id, construct_id, target } =>
|
||||||
Ok(RpcResult::InstanceState(vbox_unequip(&mut tx, account, instance_id, construct_id, target)?)),
|
Ok(RpcResult::InstanceState(vbox_unequip(&mut tx, account, instance_id, construct_id, target)?)),
|
||||||
|
|
||||||
// "mtx_apply" => handle_mtx_apply(data, &mut tx, account),
|
|
||||||
|
RpcRequest::MtxConstructApply { mtx, construct_id } =>
|
||||||
|
Ok(RpcResult::AccountConstructs(mtx::apply(&mut tx, account, mtx, construct_id)?)),
|
||||||
|
|
||||||
_ => Err(format_err!("unknown request request={:?}", request)),
|
_ => Err(format_err!("unknown request request={:?}", request)),
|
||||||
};
|
};
|
||||||
@ -165,7 +167,6 @@ pub fn receive(data: Vec<u8>, db: &Db, _client: &mut MnmlWs, begin: Instant, acc
|
|||||||
// let msg = from_slice::<MtxApplyMsg>(&data).or(Err(err_msg("invalid params")))?;
|
// let msg = from_slice::<MtxApplyMsg>(&data).or(Err(err_msg("invalid params")))?;
|
||||||
// match msg.params {
|
// match msg.params {
|
||||||
// MtxApplyParams::ConstructApply { construct_id, mtx } =>
|
// MtxApplyParams::ConstructApply { construct_id, mtx } =>
|
||||||
// mtx::apply(tx, mtx, construct_id, account.id)?,
|
|
||||||
// _ => unimplemented!(),
|
// _ => unimplemented!(),
|
||||||
// };
|
// };
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user