2019-10-16 17:05:24 +02:00
|
|
|
use crate::store;
|
2019-10-18 13:05:28 +02:00
|
|
|
use crate::update::{next_update_id, Update};
|
2019-10-21 12:05:53 +02:00
|
|
|
use heed::Result as ZResult;
|
2019-10-11 15:33:35 +02:00
|
|
|
|
|
|
|
pub fn apply_customs_update(
|
2019-10-21 12:05:53 +02:00
|
|
|
writer: &mut heed::RwTxn,
|
2019-10-11 15:33:35 +02:00
|
|
|
main_store: store::Main,
|
|
|
|
customs: &[u8],
|
2019-10-18 13:05:28 +02:00
|
|
|
) -> ZResult<()> {
|
2019-10-11 15:33:35 +02:00
|
|
|
main_store.put_customs(writer, customs)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn push_customs_update(
|
2019-10-21 12:05:53 +02:00
|
|
|
writer: &mut heed::RwTxn,
|
2019-10-11 15:33:35 +02:00
|
|
|
updates_store: store::Updates,
|
|
|
|
updates_results_store: store::UpdatesResults,
|
|
|
|
customs: Vec<u8>,
|
2019-10-18 13:05:28 +02:00
|
|
|
) -> ZResult<u64> {
|
2019-10-11 15:33:35 +02:00
|
|
|
let last_update_id = next_update_id(writer, updates_store, updates_results_store)?;
|
|
|
|
|
|
|
|
let update = Update::Customs(customs);
|
|
|
|
updates_store.put_update(writer, last_update_id, &update)?;
|
|
|
|
|
|
|
|
Ok(last_update_id)
|
|
|
|
}
|