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
|
||||
*.txt
|
||||
*.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 contact_list = [old, String::from(&f_cid)].join(",");
|
||||
let s_contactlist = bincode::serialize(&contact_list).unwrap_or_default();
|
||||
debug!(
|
||||
"writing contact index {} for key {}",
|
||||
contact_list, list_key
|
||||
);
|
||||
|
||||
db::write_chunks(
|
||||
&db.env,
|
||||
&db.handle,
|
||||
list_key.as_bytes(),
|
||||
&contact_list.as_bytes(),
|
||||
)?;
|
||||
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_contactlist)?;
|
||||
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 dispute_list = [String::from(&s_r), String::from(&f_did)].join(",");
|
||||
let s_dispute_list = bincode::serialize(&dispute_list).unwrap_or_default();
|
||||
debug!(
|
||||
"writing dispute index {} for id: {}",
|
||||
dispute_list, list_key
|
||||
);
|
||||
db::write_chunks(
|
||||
&db.env,
|
||||
&db.handle,
|
||||
list_key.as_bytes(),
|
||||
dispute_list.as_bytes(),
|
||||
)?;
|
||||
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_dispute_list)?;
|
||||
// restart the dispute aut-settle thread
|
||||
let cleared = is_dispute_clear(s_r);
|
||||
if !cleared {
|
||||
|
@ -200,17 +196,13 @@ fn remove_from_auto_settle(did: String) -> Result<(), NevekoError> {
|
|||
})
|
||||
.collect();
|
||||
let dispute_list = v.join(",");
|
||||
let s_dispute_list = bincode::serialize(&dispute_list).unwrap_or_default();
|
||||
debug!(
|
||||
"writing dipsute index {} for id: {}",
|
||||
dispute_list, list_key
|
||||
);
|
||||
db::write_chunks(
|
||||
&db.env,
|
||||
&db.handle,
|
||||
list_key.as_bytes(),
|
||||
dispute_list.as_bytes(),
|
||||
)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_dispute_list)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -90,15 +90,11 @@ pub async fn create(
|
|||
}
|
||||
let d_r: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
||||
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);
|
||||
let db = &DATABASE_LOCK;
|
||||
db::write_chunks(
|
||||
&db.env,
|
||||
&db.handle,
|
||||
list_key.as_bytes(),
|
||||
msg_list.as_bytes(),
|
||||
)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_msg_list)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
info!("attempting to send message");
|
||||
let send = send_message(&new_message, &jwp, m_type).await;
|
||||
send.unwrap();
|
||||
|
@ -144,14 +140,10 @@ pub async fn rx(m: Json<Message>) -> Result<(), NevekoError> {
|
|||
}
|
||||
let old: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
||||
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);
|
||||
db::write_chunks(
|
||||
&db.env,
|
||||
&db.handle,
|
||||
list_key.as_bytes(),
|
||||
msg_list.as_bytes(),
|
||||
)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_msg_list)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -245,19 +237,15 @@ pub async fn rx_multisig(m: Json<Message>) -> Result<(), NevekoError> {
|
|||
}
|
||||
let old: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
||||
let msg_list = [old, String::from(&f_mid)].join(",");
|
||||
let s_msg_list = bincode::serialize(&msg_list).unwrap_or_default();
|
||||
debug!(
|
||||
"writing msig message index {} for id: {}",
|
||||
msg_list, list_key
|
||||
);
|
||||
let db = &DATABASE_LOCK;
|
||||
|
||||
db::write_chunks(
|
||||
&db.env,
|
||||
&db.handle,
|
||||
list_key.as_bytes(),
|
||||
msg_list.as_bytes(),
|
||||
)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_msg_list)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
let data: MultisigMessageData = parse_multisig_message(new_message.mid).await?;
|
||||
debug!(
|
||||
"writing multisig message type {} for order {}",
|
||||
|
@ -436,6 +424,7 @@ async fn send_to_retry(mid: String) -> Result<(), NevekoError> {
|
|||
}
|
||||
let i_r: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
||||
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
|
||||
if String::from(&i_r).contains(&String::from(&mid)) {
|
||||
msg_list = i_r;
|
||||
|
@ -444,13 +433,8 @@ async fn send_to_retry(mid: String) -> Result<(), NevekoError> {
|
|||
"writing fts message index {} for id: {}",
|
||||
msg_list, list_key
|
||||
);
|
||||
db::write_chunks(
|
||||
&db.env,
|
||||
&db.handle,
|
||||
list_key.as_bytes(),
|
||||
msg_list.as_bytes(),
|
||||
)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_msg_list)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
// restart fts if not empty
|
||||
let r = db::DatabaseEnvironment::read(&db.env, &db.handle, &list_key.as_bytes().to_vec())
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
|
@ -489,17 +473,13 @@ fn remove_from_fts(mid: String) -> Result<(), NevekoError> {
|
|||
})
|
||||
.collect();
|
||||
let msg_list = v.join(",");
|
||||
let s_msg_list = bincode::serialize(&msg_list).unwrap_or_default();
|
||||
debug!(
|
||||
"writing fts message index {} for id: {}",
|
||||
msg_list, list_key
|
||||
);
|
||||
db::write_chunks(
|
||||
&db.env,
|
||||
&db.handle,
|
||||
list_key.as_bytes(),
|
||||
msg_list.as_bytes(),
|
||||
)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_msg_list)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -214,11 +214,11 @@ pub fn start_daemon() -> Result<(), NevekoError> {
|
|||
|
||||
/// Start monero-wallet-rpc
|
||||
pub fn start_rpc() {
|
||||
info!("starting monero-wallet-rpc");
|
||||
let cli_args = args::Args::parse();
|
||||
let bin_dir = get_monero_location();
|
||||
let port = get_rpc_port();
|
||||
let login = get_rpc_creds();
|
||||
info!("starting monero-wallet-rpc from {}", &bin_dir);
|
||||
let daemon_address = cli_args.monero_rpc_daemon;
|
||||
let rpc_login = format!("{}:{}", &login.username, &login.credential);
|
||||
let release_env = utils::get_release_env();
|
||||
|
@ -322,8 +322,7 @@ fn get_blockchain_dir() -> String {
|
|||
/// Get monero download location
|
||||
fn get_monero_location() -> String {
|
||||
let args = args::Args::parse();
|
||||
let user = std::env::var("USER").unwrap_or(String::new());
|
||||
format!("/home/{}/{}", &user, &args.monero_location)
|
||||
args.monero_location.to_string()
|
||||
}
|
||||
|
||||
/// Get monero rpc host from the `--monero-rpc-host` cli arg
|
||||
|
|
|
@ -104,14 +104,10 @@ pub async fn create(j_order: Json<reqres::OrderRequest>) -> Result<Order, Neveko
|
|||
}
|
||||
let old: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
||||
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);
|
||||
db::write_chunks(
|
||||
&db.env,
|
||||
&db.handle,
|
||||
list_key.as_bytes(),
|
||||
&order_list.as_bytes(),
|
||||
)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_order_list)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
Ok(new_order)
|
||||
}
|
||||
|
||||
|
@ -136,19 +132,15 @@ pub fn backup(order: &Order) -> Result<(), NevekoError> {
|
|||
}
|
||||
let d_r: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
||||
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
|
||||
if String::from(&d_r).contains(&String::from(&order.orid)) {
|
||||
order_list = d_r;
|
||||
}
|
||||
debug!("writing order index {} for id: {}", order_list, list_key);
|
||||
let db = &DATABASE_LOCK;
|
||||
db::write_chunks(
|
||||
&db.env,
|
||||
&db.handle,
|
||||
list_key.as_bytes(),
|
||||
order_list.as_bytes(),
|
||||
)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_order_list)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -49,17 +49,13 @@ pub fn create(d: Json<Product>) -> Result<Product, NevekoError> {
|
|||
}
|
||||
let old: String = bincode::deserialize(&r[..]).unwrap_or_default();
|
||||
let product_list = [old, String::from(&pid)].join(",");
|
||||
let s_product_list = bincode::serialize(&product_list).unwrap_or_default();
|
||||
debug!(
|
||||
"writing product index {} for id: {}",
|
||||
product_list, list_key
|
||||
);
|
||||
db::write_chunks(
|
||||
&db.env,
|
||||
&db.handle,
|
||||
list_key.as_bytes(),
|
||||
product_list.as_bytes(),
|
||||
)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
db::write_chunks(&db.env, &db.handle, list_key.as_bytes(), &s_product_list)
|
||||
.map_err(|_| NevekoError::Database(MdbError::Panic))?;
|
||||
Ok(new_product)
|
||||
}
|
||||
|
||||
|
|
|
@ -545,7 +545,10 @@ pub async fn start_up() -> Result<(), NevekoError> {
|
|||
}
|
||||
let env: String = get_release_env().value();
|
||||
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
|
||||
{
|
||||
|
|
26
neveko-gui/.gitignore
vendored
26
neveko-gui/.gitignore
vendored
|
@ -3,3 +3,29 @@
|
|||
notes.txt
|
||||
.env
|
||||
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
|
||||
pub const ADD_CONTACT_TIMEOUT_SECS: u64 = 0x5A;
|
||||
/// 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
|
||||
pub const BYTES_IN_GB: u64 = 1000000000;
|
||||
/// Useful flag to keep services running in background
|
||||
|
|
Loading…
Reference in a new issue