Skip to content
Snippets Groups Projects
Commit b349c729 authored by Éloïs's avatar Éloïs
Browse files

[ref] dbs:txs_history: use Vec instead of BTreeSet

parent 1511e466
No related branches found
No related tags found
1 merge request!1335Gva proto 2
......@@ -43,7 +43,7 @@ pub(crate) fn apply_tx<B: Backend>(
// Insert on col `txs_by_issuer`
for pubkey in tx.issuers() {
let mut hashs = txs_by_issuer.get(&PubKeyKeyV2(pubkey))?.unwrap_or_default();
hashs.insert(tx_hash);
hashs.push(tx_hash);
txs_by_issuer.upsert(PubKeyKeyV2(pubkey), hashs);
}
// Insert on col `txs_by_recipient`
......@@ -51,7 +51,7 @@ pub(crate) fn apply_tx<B: Backend>(
let mut hashs = txs_by_recipient
.get(&PubKeyKeyV2(pubkey))?
.unwrap_or_default();
hashs.insert(tx_hash);
hashs.push(tx_hash);
txs_by_recipient.upsert(PubKeyKeyV2(pubkey), hashs);
}
......@@ -243,7 +243,7 @@ fn remove_tx<B: Backend>(
// Remove tx hash in col `txs_by_issuer`
for pubkey in tx_db.tx.issuers() {
let mut hashs_ = txs_by_issuer.get(&PubKeyKeyV2(pubkey))?.unwrap_or_default();
hashs_.remove(&tx_hash);
hashs_.pop();
txs_by_issuer.upsert(PubKeyKeyV2(pubkey), hashs_)
}
// Remove tx hash in col `txs_by_recipient`
......@@ -251,7 +251,7 @@ fn remove_tx<B: Backend>(
let mut hashs_ = txs_by_recipient
.get(&PubKeyKeyV2(pubkey))?
.unwrap_or_default();
hashs_.remove(&tx_hash);
hashs_.pop();
txs_by_recipient.upsert(PubKeyKeyV2(pubkey), hashs_)
}
// Remove tx itself
......
......@@ -19,8 +19,8 @@ db_schema!(
GvaV1,
[
["txs", Txs, HashKeyV2, TxDbV2],
["txs_by_issuer", TxsByIssuer, PubKeyKeyV2, BTreeSet<Hash>],
["txs_by_recipient", TxsByRecipient, PubKeyKeyV2, BTreeSet<Hash>],
["txs_by_issuer", TxsByIssuer, PubKeyKeyV2, Vec<Hash>],
["txs_by_recipient", TxsByRecipient, PubKeyKeyV2, Vec<Hash>],
[
"scripts_by_pubkey",
ScriptsByPubkey,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment