Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
duniter-core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
duniter-core
Commits
4f26e9e6
Commit
4f26e9e6
authored
4 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
feat(dbs): txs mempool: store received time in each tx
parent
895fee13
No related branches found
No related tags found
No related merge requests found
Pipeline
#12188
passed
4 years ago
Stage: tests
Stage: quality
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
dbs-write-ops/src/txs_mp.rs
+11
-5
11 additions, 5 deletions
dbs-write-ops/src/txs_mp.rs
dbs/src/values/tx_db.rs
+4
-1
4 additions, 1 deletion
dbs/src/values/tx_db.rs
with
15 additions
and
6 deletions
dbs-write-ops/src/txs_mp.rs
+
11
−
5
View file @
4f26e9e6
...
...
@@ -111,7 +111,13 @@ pub fn add_pending_tx<
outputs_by_script
.upsert
(
script
,
script_outputs
);
}
// Insert tx itself
txs
.upsert
(
HashKeyV2
(
tx_hash
),
PendingTxDbV2
(
tx
.into_owned
()));
txs
.upsert
(
HashKeyV2
(
tx_hash
),
PendingTxDbV2
{
doc
:
tx
.into_owned
(),
received_time
,
},
);
Ok
(())
},
)
...
...
@@ -177,7 +183,7 @@ fn remove_one_pending_tx<B: Backend>(txs_mp_db: &TxsMpV2Db<B>, tx_hash: Hash) ->
mut
outputs_by_script
,
)|
{
// Remove tx inputs in cols `uds_ids` and `utxos_ids`
for
input
in
tx
.
0
.get_inputs
()
{
for
input
in
tx
.
doc
.get_inputs
()
{
match
input
.id
{
SourceIdV10
::
Ud
(
UdSourceIdV10
{
issuer
,
...
...
@@ -191,14 +197,14 @@ fn remove_one_pending_tx<B: Backend>(txs_mp_db: &TxsMpV2Db<B>, tx_hash: Hash) ->
}
}
// Remove tx hash in col `txs_by_issuer`
for
pubkey
in
tx
.
0
.issuers
()
{
for
pubkey
in
tx
.
doc
.issuers
()
{
let
mut
hashs_
=
txs_by_issuer
.get
(
&
PubKeyKeyV2
(
pubkey
))
?
.unwrap_or_default
();
hashs_
.remove
(
&
tx_hash
);
txs_by_issuer
.upsert
(
PubKeyKeyV2
(
pubkey
),
hashs_
)
}
// Remove tx hash in col `txs_by_recipient`
for
pubkey
in
tx
.
0
.recipients_keys
()
{
for
pubkey
in
tx
.
doc
.recipients_keys
()
{
let
mut
hashs_
=
txs_by_recipient
.get
(
&
PubKeyKeyV2
(
pubkey
))
?
.unwrap_or_default
();
...
...
@@ -206,7 +212,7 @@ fn remove_one_pending_tx<B: Backend>(txs_mp_db: &TxsMpV2Db<B>, tx_hash: Hash) ->
txs_by_recipient
.upsert
(
PubKeyKeyV2
(
pubkey
),
hashs_
)
}
// Remove tx outputs in col `outputs`
for
(
output_index
,
output
)
in
tx
.
0
.get_outputs
()
.iter
()
.enumerate
()
{
for
(
output_index
,
output
)
in
tx
.
doc
.get_outputs
()
.iter
()
.enumerate
()
{
let
script
=
WalletConditionsV2
(
output
.conditions.script
.to_owned
());
let
utxo
=
UtxoValV2
::
new
(
output
.amount
,
tx_hash
,
output_index
as
u32
);
let
mut
script_outputs
=
...
...
This diff is collapsed.
Click to expand it.
dbs/src/values/tx_db.rs
+
4
−
1
View file @
4f26e9e6
...
...
@@ -17,7 +17,10 @@ use crate::*;
use
dubp
::
documents
::
transaction
::
TransactionDocumentV10
;
#[derive(Clone,
Debug,
Default,
Deserialize,
PartialEq,
Serialize)]
pub
struct
PendingTxDbV2
(
pub
TransactionDocumentV10
);
pub
struct
PendingTxDbV2
{
pub
doc
:
TransactionDocumentV10
,
pub
received_time
:
i64
,
}
impl
AsBytes
for
PendingTxDbV2
{
fn
as_bytes
<
T
,
F
:
FnMut
(
&
[
u8
])
->
T
>
(
&
self
,
mut
f
:
F
)
->
T
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment