mirror of
https://github.com/creating2morrow/neveko.git
synced 2024-12-22 11:39:22 +00:00
patch serialization on list indexes
This commit is contained in:
parent
7bd22c8e92
commit
acd729ceb5
11 changed files with 67 additions and 82 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -27,3 +27,4 @@ peerProfiles/*
|
||||||
*.dat
|
*.dat
|
||||||
*.txt
|
*.txt
|
||||||
*.txt.gz
|
*.txt.gz
|
||||||
|
opt-backup/j4-i2p-rs/jassets/addressbook.war
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit e21f15f9366a8079ec0be61a96c1285db2d7d0e4
|
Subproject commit 35874a836a66059fe4d177a8d8e8061c454d9d87
|
|
@ -57,17 +57,13 @@ pub async fn create(c: &Json<Contact>) -> Result<Contact, MdbError> {
|
||||||
}
|
}
|
||||||
let old: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
let old: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
||||||
let contact_list = [old, String::from(&f_cid)].join(",");
|
let contact_list = [old, String::from(&f_cid)].join(",");
|
||||||
|
let s_contactlist = bincode::serialize(&contact_list).unwrap_or_default();
|
||||||
debug!(
|
debug!(
|
||||||
"writing contact index {} for key {}",
|
"writing contact index {} for key {}",
|
||||||
contact_list, list_key
|
contact_list, list_key
|
||||||
);
|
);
|
||||||
|
|
||||||
db::write_chunks(
|
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_contactlist)?;
|
||||||
&db.env,
|
|
||||||
&db.handle,
|
|
||||||
list_key.as_bytes(),
|
|
||||||
&contact_list.as_bytes(),
|
|
||||||
)?;
|
|
||||||
Ok(new_contact)
|
Ok(new_contact)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,16 +43,12 @@ pub fn create(d: Json<Dispute>) -> Result<Dispute, MdbError> {
|
||||||
}
|
}
|
||||||
let s_r: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
let s_r: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
||||||
let dispute_list = [String::from(&s_r), String::from(&f_did)].join(",");
|
let dispute_list = [String::from(&s_r), String::from(&f_did)].join(",");
|
||||||
|
let s_dispute_list = bincode::serialize(&dispute_list).unwrap_or_default();
|
||||||
debug!(
|
debug!(
|
||||||
"writing dispute index {} for id: {}",
|
"writing dispute index {} for id: {}",
|
||||||
dispute_list, list_key
|
dispute_list, list_key
|
||||||
);
|
);
|
||||||
db::write_chunks(
|
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_dispute_list)?;
|
||||||
&db.env,
|
|
||||||
&db.handle,
|
|
||||||
list_key.as_bytes(),
|
|
||||||
dispute_list.as_bytes(),
|
|
||||||
)?;
|
|
||||||
// restart the dispute aut-settle thread
|
// restart the dispute aut-settle thread
|
||||||
let cleared = is_dispute_clear(s_r);
|
let cleared = is_dispute_clear(s_r);
|
||||||
if !cleared {
|
if !cleared {
|
||||||
|
@ -200,16 +196,12 @@ fn remove_from_auto_settle(did: String) -> Result<(), NevekoError> {
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let dispute_list = v.join(",");
|
let dispute_list = v.join(",");
|
||||||
|
let s_dispute_list = bincode::serialize(&dispute_list).unwrap_or_default();
|
||||||
debug!(
|
debug!(
|
||||||
"writing dipsute index {} for id: {}",
|
"writing dipsute index {} for id: {}",
|
||||||
dispute_list, list_key
|
dispute_list, list_key
|
||||||
);
|
);
|
||||||
db::write_chunks(
|
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_dispute_list)
|
||||||
&db.env,
|
|
||||||
&db.handle,
|
|
||||||
list_key.as_bytes(),
|
|
||||||
dispute_list.as_bytes(),
|
|
||||||
)
|
|
||||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,14 +90,10 @@ pub async fn create(
|
||||||
}
|
}
|
||||||
let d_r: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
let d_r: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
||||||
let msg_list = [d_r, String::from(&f_mid)].join(",");
|
let msg_list = [d_r, String::from(&f_mid)].join(",");
|
||||||
|
let s_msg_list = bincode::serialize(&msg_list).unwrap_or_default();
|
||||||
debug!("writing message index {} for id: {}", msg_list, list_key);
|
debug!("writing message index {} for id: {}", msg_list, list_key);
|
||||||
let db = &DATABASE_LOCK;
|
let db = &DATABASE_LOCK;
|
||||||
db::write_chunks(
|
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_msg_list)
|
||||||
&db.env,
|
|
||||||
&db.handle,
|
|
||||||
list_key.as_bytes(),
|
|
||||||
msg_list.as_bytes(),
|
|
||||||
)
|
|
||||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||||
info!("attempting to send message");
|
info!("attempting to send message");
|
||||||
let send = send_message(&new_message, &jwp, m_type).await;
|
let send = send_message(&new_message, &jwp, m_type).await;
|
||||||
|
@ -144,13 +140,9 @@ pub async fn rx(m: Json<Message>) -> Result<(), NevekoError> {
|
||||||
}
|
}
|
||||||
let old: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
let old: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
||||||
let msg_list = [old, String::from(&f_mid)].join(",");
|
let msg_list = [old, String::from(&f_mid)].join(",");
|
||||||
|
let s_msg_list = bincode::serialize(&msg_list).unwrap_or_default();
|
||||||
debug!("writing message index {} for {}", msg_list, list_key);
|
debug!("writing message index {} for {}", msg_list, list_key);
|
||||||
db::write_chunks(
|
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_msg_list)
|
||||||
&db.env,
|
|
||||||
&db.handle,
|
|
||||||
list_key.as_bytes(),
|
|
||||||
msg_list.as_bytes(),
|
|
||||||
)
|
|
||||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -245,18 +237,14 @@ pub async fn rx_multisig(m: Json<Message>) -> Result<(), NevekoError> {
|
||||||
}
|
}
|
||||||
let old: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
let old: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
||||||
let msg_list = [old, String::from(&f_mid)].join(",");
|
let msg_list = [old, String::from(&f_mid)].join(",");
|
||||||
|
let s_msg_list = bincode::serialize(&msg_list).unwrap_or_default();
|
||||||
debug!(
|
debug!(
|
||||||
"writing msig message index {} for id: {}",
|
"writing msig message index {} for id: {}",
|
||||||
msg_list, list_key
|
msg_list, list_key
|
||||||
);
|
);
|
||||||
let db = &DATABASE_LOCK;
|
let db = &DATABASE_LOCK;
|
||||||
|
|
||||||
db::write_chunks(
|
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_msg_list)
|
||||||
&db.env,
|
|
||||||
&db.handle,
|
|
||||||
list_key.as_bytes(),
|
|
||||||
msg_list.as_bytes(),
|
|
||||||
)
|
|
||||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||||
let data: MultisigMessageData = parse_multisig_message(new_message.mid).await?;
|
let data: MultisigMessageData = parse_multisig_message(new_message.mid).await?;
|
||||||
debug!(
|
debug!(
|
||||||
|
@ -436,6 +424,7 @@ async fn send_to_retry(mid: String) -> Result<(), NevekoError> {
|
||||||
}
|
}
|
||||||
let i_r: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
let i_r: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
||||||
let mut msg_list = [String::from(&i_r), String::from(&mid)].join(",");
|
let mut msg_list = [String::from(&i_r), String::from(&mid)].join(",");
|
||||||
|
let s_msg_list = bincode::serialize(&msg_list).unwrap_or_default();
|
||||||
// don't duplicate message ids in fts
|
// don't duplicate message ids in fts
|
||||||
if String::from(&i_r).contains(&String::from(&mid)) {
|
if String::from(&i_r).contains(&String::from(&mid)) {
|
||||||
msg_list = i_r;
|
msg_list = i_r;
|
||||||
|
@ -444,12 +433,7 @@ async fn send_to_retry(mid: String) -> Result<(), NevekoError> {
|
||||||
"writing fts message index {} for id: {}",
|
"writing fts message index {} for id: {}",
|
||||||
msg_list, list_key
|
msg_list, list_key
|
||||||
);
|
);
|
||||||
db::write_chunks(
|
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_msg_list)
|
||||||
&db.env,
|
|
||||||
&db.handle,
|
|
||||||
list_key.as_bytes(),
|
|
||||||
msg_list.as_bytes(),
|
|
||||||
)
|
|
||||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||||
// restart fts if not empty
|
// restart fts if not empty
|
||||||
let r = db::DatabaseEnvironment::read(&db.env, &db.handle, &list_key.as_bytes().to_vec())
|
let r = db::DatabaseEnvironment::read(&db.env, &db.handle, &list_key.as_bytes().to_vec())
|
||||||
|
@ -489,16 +473,12 @@ fn remove_from_fts(mid: String) -> Result<(), NevekoError> {
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let msg_list = v.join(",");
|
let msg_list = v.join(",");
|
||||||
|
let s_msg_list = bincode::serialize(&msg_list).unwrap_or_default();
|
||||||
debug!(
|
debug!(
|
||||||
"writing fts message index {} for id: {}",
|
"writing fts message index {} for id: {}",
|
||||||
msg_list, list_key
|
msg_list, list_key
|
||||||
);
|
);
|
||||||
db::write_chunks(
|
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_msg_list)
|
||||||
&db.env,
|
|
||||||
&db.handle,
|
|
||||||
list_key.as_bytes(),
|
|
||||||
msg_list.as_bytes(),
|
|
||||||
)
|
|
||||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,11 +214,11 @@ pub fn start_daemon() -> Result<(), NevekoError> {
|
||||||
|
|
||||||
/// Start monero-wallet-rpc
|
/// Start monero-wallet-rpc
|
||||||
pub fn start_rpc() {
|
pub fn start_rpc() {
|
||||||
info!("starting monero-wallet-rpc");
|
|
||||||
let cli_args = args::Args::parse();
|
let cli_args = args::Args::parse();
|
||||||
let bin_dir = get_monero_location();
|
let bin_dir = get_monero_location();
|
||||||
let port = get_rpc_port();
|
let port = get_rpc_port();
|
||||||
let login = get_rpc_creds();
|
let login = get_rpc_creds();
|
||||||
|
info!("starting monero-wallet-rpc from {}", &bin_dir);
|
||||||
let daemon_address = cli_args.monero_rpc_daemon;
|
let daemon_address = cli_args.monero_rpc_daemon;
|
||||||
let rpc_login = format!("{}:{}", &login.username, &login.credential);
|
let rpc_login = format!("{}:{}", &login.username, &login.credential);
|
||||||
let release_env = utils::get_release_env();
|
let release_env = utils::get_release_env();
|
||||||
|
@ -322,8 +322,7 @@ fn get_blockchain_dir() -> String {
|
||||||
/// Get monero download location
|
/// Get monero download location
|
||||||
fn get_monero_location() -> String {
|
fn get_monero_location() -> String {
|
||||||
let args = args::Args::parse();
|
let args = args::Args::parse();
|
||||||
let user = std::env::var("USER").unwrap_or(String::new());
|
args.monero_location.to_string()
|
||||||
format!("/home/{}/{}", &user, &args.monero_location)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get monero rpc host from the `--monero-rpc-host` cli arg
|
/// Get monero rpc host from the `--monero-rpc-host` cli arg
|
||||||
|
|
|
@ -104,13 +104,9 @@ pub async fn create(j_order: Json<reqres::OrderRequest>) -> Result<Order, Neveko
|
||||||
}
|
}
|
||||||
let old: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
let old: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
||||||
let order_list = [old, String::from(&orid)].join(",");
|
let order_list = [old, String::from(&orid)].join(",");
|
||||||
|
let s_order_list = bincode::serialize(&order_list).unwrap_or_default();
|
||||||
debug!("writing order index {} for id: {}", order_list, list_key);
|
debug!("writing order index {} for id: {}", order_list, list_key);
|
||||||
db::write_chunks(
|
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_order_list)
|
||||||
&db.env,
|
|
||||||
&db.handle,
|
|
||||||
list_key.as_bytes(),
|
|
||||||
&order_list.as_bytes(),
|
|
||||||
)
|
|
||||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||||
Ok(new_order)
|
Ok(new_order)
|
||||||
}
|
}
|
||||||
|
@ -136,18 +132,14 @@ pub fn backup(order: &Order) -> Result<(), NevekoError> {
|
||||||
}
|
}
|
||||||
let d_r: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
let d_r: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
||||||
let mut order_list = [String::from(&d_r), String::from(&order.orid)].join(",");
|
let mut order_list = [String::from(&d_r), String::from(&order.orid)].join(",");
|
||||||
|
let s_order_list = bincode::serialize(&order_list).unwrap_or_default();
|
||||||
// don't duplicate order ids when backing up updates from vendor
|
// don't duplicate order ids when backing up updates from vendor
|
||||||
if String::from(&d_r).contains(&String::from(&order.orid)) {
|
if String::from(&d_r).contains(&String::from(&order.orid)) {
|
||||||
order_list = d_r;
|
order_list = d_r;
|
||||||
}
|
}
|
||||||
debug!("writing order index {} for id: {}", order_list, list_key);
|
debug!("writing order index {} for id: {}", order_list, list_key);
|
||||||
let db = &DATABASE_LOCK;
|
let db = &DATABASE_LOCK;
|
||||||
db::write_chunks(
|
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_order_list)
|
||||||
&db.env,
|
|
||||||
&db.handle,
|
|
||||||
list_key.as_bytes(),
|
|
||||||
order_list.as_bytes(),
|
|
||||||
)
|
|
||||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,16 +49,12 @@ pub fn create(d: Json<Product>) -> Result<Product, NevekoError> {
|
||||||
}
|
}
|
||||||
let old: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
let old: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
||||||
let product_list = [old, String::from(&pid)].join(",");
|
let product_list = [old, String::from(&pid)].join(",");
|
||||||
|
let s_product_list = bincode::serialize(&product_list).unwrap_or_default();
|
||||||
debug!(
|
debug!(
|
||||||
"writing product index {} for id: {}",
|
"writing product index {} for id: {}",
|
||||||
product_list, list_key
|
product_list, list_key
|
||||||
);
|
);
|
||||||
db::write_chunks(
|
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_product_list)
|
||||||
&db.env,
|
|
||||||
&db.handle,
|
|
||||||
list_key.as_bytes(),
|
|
||||||
product_list.as_bytes(),
|
|
||||||
)
|
|
||||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||||
Ok(new_product)
|
Ok(new_product)
|
||||||
}
|
}
|
||||||
|
|
|
@ -545,7 +545,10 @@ pub async fn start_up() -> Result<(), NevekoError> {
|
||||||
}
|
}
|
||||||
let env: String = get_release_env().value();
|
let env: String = get_release_env().value();
|
||||||
if !args.i2p_advanced {
|
if !args.i2p_advanced {
|
||||||
let _ = i2p::start();
|
let i2p = i2p::start();
|
||||||
|
if i2p.is_err() {
|
||||||
|
panic!("failed to start i2p");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// start async background tasks here
|
// start async background tasks here
|
||||||
{
|
{
|
||||||
|
|
26
neveko-gui/.gitignore
vendored
26
neveko-gui/.gitignore
vendored
|
@ -3,3 +3,29 @@
|
||||||
notes.txt
|
notes.txt
|
||||||
.env
|
.env
|
||||||
neveko
|
neveko
|
||||||
|
*.ping
|
||||||
|
/wallet
|
||||||
|
/.build
|
||||||
|
genkey-batch
|
||||||
|
monero-wallet-rpc.log
|
||||||
|
notes.txt
|
||||||
|
.vscode/settings.json
|
||||||
|
*.bz2
|
||||||
|
*.zip
|
||||||
|
monero-x86_64-linux-gnu-v*/
|
||||||
|
*.jar
|
||||||
|
opt/*
|
||||||
|
*.so
|
||||||
|
*.config
|
||||||
|
*.log
|
||||||
|
*.key
|
||||||
|
router.info
|
||||||
|
router.keys.dat
|
||||||
|
prngseed.rnd
|
||||||
|
hostsdb.blockfile
|
||||||
|
certificates/
|
||||||
|
netDb/*
|
||||||
|
peerProfiles/*
|
||||||
|
*.dat
|
||||||
|
*.txt
|
||||||
|
*.txt.gz
|
|
@ -40,7 +40,7 @@ pub const I2P_PROPAGATION_TIME_IN_SECS_EST: u64 = PROPAGATION_TIME_IN_SECS_EST *
|
||||||
/// time to wait before giving up on adding a contact
|
/// time to wait before giving up on adding a contact
|
||||||
pub const ADD_CONTACT_TIMEOUT_SECS: u64 = 0x5A;
|
pub const ADD_CONTACT_TIMEOUT_SECS: u64 = 0x5A;
|
||||||
/// time to wait before giving up on neveko core
|
/// time to wait before giving up on neveko core
|
||||||
pub const START_CORE_TIMEOUT_SECS: u64 = 0x79;
|
pub const START_CORE_TIMEOUT_SECS: u64 = 0x4B0;
|
||||||
/// bytes in a a GB for calculating space on home page
|
/// bytes in a a GB for calculating space on home page
|
||||||
pub const BYTES_IN_GB: u64 = 1000000000;
|
pub const BYTES_IN_GB: u64 = 1000000000;
|
||||||
/// Useful flag to keep services running in background
|
/// Useful flag to keep services running in background
|
||||||
|
|
Loading…
Reference in a new issue