Implement estate and marketplace services (#73)
This commit is contained in:
@@ -150,6 +150,38 @@ impl std::fmt::Debug for AssetManager {
|
||||
}
|
||||
|
||||
impl AssetManager {
|
||||
pub(crate) fn native_stage_estate_upload(&self, data: Vec<u8>) -> Result<UUID, Error> {
|
||||
if data.is_empty() || data.len() > crate::asset_models::MAX_ASSET_BYTES {
|
||||
return Err(Error::Argument);
|
||||
}
|
||||
let id = UUID::random()?;
|
||||
let upload = Arc::new(Mutex::new(UploadState {
|
||||
asset_id: id,
|
||||
data,
|
||||
packet_num: 0,
|
||||
transaction_id: id,
|
||||
transferred: 0,
|
||||
type_: AssetType::Unknown,
|
||||
xfer_id: 0,
|
||||
confirmation: None,
|
||||
}));
|
||||
let mut pending = mutex(&self.inner.pending_upload);
|
||||
if pending.is_some() {
|
||||
return Err(Error::InvalidOperation);
|
||||
}
|
||||
*pending = Some(upload);
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
pub(crate) fn native_cancel_staged_estate_upload(&self, id: UUID) {
|
||||
let mut pending = mutex(&self.inner.pending_upload);
|
||||
if pending
|
||||
.as_ref()
|
||||
.is_some_and(|upload| mutex(upload).transaction_id == id)
|
||||
{
|
||||
pending.take();
|
||||
}
|
||||
}
|
||||
pub(crate) fn native_from_inner(inner: Arc<AssetManagerInner>) -> Result<Self, Error> {
|
||||
inner.client.upgrade().ok_or(Error::InvalidOperation)?;
|
||||
Ok(Self {
|
||||
|
||||
Reference in New Issue
Block a user