Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Pascal Engélibert
duniter
Commits
d1e1c139
Commit
d1e1c139
authored
4 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[fix]gva:txs_history:received: revert ord must revert txs on same block
parent
7c5ab533
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
rust-libs/modules/gva/dbs-reader/src/pagination.rs
+0
-2
0 additions, 2 deletions
rust-libs/modules/gva/dbs-reader/src/pagination.rs
rust-libs/modules/gva/dbs-reader/src/txs_history.rs
+115
-5
115 additions, 5 deletions
rust-libs/modules/gva/dbs-reader/src/txs_history.rs
with
115 additions
and
7 deletions
rust-libs/modules/gva/dbs-reader/src/pagination.rs
+
0
−
2
View file @
d1e1c139
...
...
@@ -131,8 +131,6 @@ pub(crate) fn has_previous_page<
}
else
{
page_cursors
.next_back
()
}
{
println!
(
"TMP page_start_cursor={:?}"
,
page_start_cursor
);
println!
(
"TMP first_cursor={:?}"
,
first_cursor
);
page_start_cursor
.as_ref
()
!=
&
first_cursor
}
else
{
page_info
.pos
.unwrap_or_default
()
>
first_cursor
...
...
This diff is collapsed.
Click to expand it.
rust-libs/modules/gva/dbs-reader/src/txs_history.rs
+
115
−
5
View file @
d1e1c139
...
...
@@ -148,7 +148,7 @@ impl DbsReader {
.txs_by_recipient
()
.iter_ref_slice_rev
(
start_k
..=
end_k
,
|
_k
,
hashs
|
{
let
mut
sent
=
SmallVec
::
<
[
GvaTxDbV1
;
8
]
>
::
new
();
for
hash
in
hashs
{
for
hash
in
hashs
.iter
()
.rev
()
{
if
let
Some
(
tx_db
)
=
self
.0
.txs
()
.get
(
HashKeyV2
::
from_ref
(
hash
))
?
{
sent
.push
(
tx_db
);
}
...
...
@@ -239,10 +239,6 @@ impl DbsReader {
None
};
println!
(
"first_hashs_opt={:?}"
,
first_hashs_opt
);
println!
(
"start_k={}"
,
start_k
);
println!
(
"end_k={}"
,
end_k
);
if
page_info
.order
{
let
txs_iter
=
self
.0
...
...
@@ -499,6 +495,120 @@ mod tests {
}
}
#[test]
fn
test_get_txs_history_bc_received
()
->
KvResult
<
()
>
{
let
gva_db
=
duniter_gva_db
::
GvaV1Db
::
<
Mem
>
::
open
(
MemConf
::
default
())
?
;
let
db_reader
=
create_dbs_reader
(
unsafe
{
std
::
mem
::
transmute
(
&
gva_db
.get_ro_handler
())
});
let
s1
=
WalletScriptV10
::
single_sig
(
PublicKey
::
default
());
let
s1_hash
=
Hash
::
compute_str
(
&
s1
.to_string
());
gva_db
.txs_write
()
.upsert
(
HashKeyV2
(
Hash
::
default
()),
gen_tx
(
Hash
::
default
(),
BlockNumber
(
1
)),
)
?
;
gva_db
.txs_write
()
.upsert
(
HashKeyV2
(
Hash
([
1
;
32
])),
gen_tx
(
Hash
([
1
;
32
]),
BlockNumber
(
1
)),
)
?
;
gva_db
.txs_write
()
.upsert
(
HashKeyV2
(
Hash
([
2
;
32
])),
gen_tx
(
Hash
([
2
;
32
]),
BlockNumber
(
1
)),
)
?
;
gva_db
.txs_write
()
.upsert
(
HashKeyV2
(
Hash
([
3
;
32
])),
gen_tx
(
Hash
([
3
;
32
]),
BlockNumber
(
1
)),
)
?
;
gva_db
.txs_by_recipient_write
()
.upsert
(
WalletHashWithBnV1Db
::
new
(
s1_hash
,
BlockNumber
(
1
)),
btreeset!
[
Hash
::
default
(),
Hash
([
1
;
32
]),
Hash
([
2
;
32
]),
Hash
([
3
;
32
])],
)
?
;
gva_db
.txs_write
()
.upsert
(
HashKeyV2
(
Hash
([
4
;
32
])),
gen_tx
(
Hash
([
4
;
32
]),
BlockNumber
(
2
)),
)
?
;
gva_db
.txs_write
()
.upsert
(
HashKeyV2
(
Hash
([
5
;
32
])),
gen_tx
(
Hash
([
5
;
32
]),
BlockNumber
(
2
)),
)
?
;
gva_db
.txs_by_recipient_write
()
.upsert
(
WalletHashWithBnV1Db
::
new
(
s1_hash
,
BlockNumber
(
2
)),
btreeset!
[
Hash
([
4
;
32
]),
Hash
([
5
;
32
])],
)
?
;
/*let received = db_reader.get_txs_history_bc_received(
PageInfo {
order: true,
limit_opt: None,
pos: Some(TxBcCursor {
tx_hash: Hash([1; 32]),
block_number: BlockNumber(1),
}),
},
s1_hash,
)?;
assert_eq!(
received.data
.into_iter()
.map(|tx_db| tx_db.tx.get_hash())
.collect::<Vec<_>>(),
vec![Hash([2; 32]), Hash([3; 32]), Hash([4; 32]), Hash([5; 32])],
);
assert!(!received.has_next_page);
assert!(!received.has_previous_page);
let received = db_reader.get_txs_history_bc_received(
PageInfo {
order: false,
limit_opt: None,
pos: Some(TxBcCursor {
tx_hash: Hash([1; 32]),
block_number: BlockNumber(1),
}),
},
s1_hash,
)?;
assert_eq!(
received.data
.into_iter()
.map(|tx_db| tx_db.tx.get_hash())
.collect::<Vec<_>>(),
vec![Hash([0; 32])],
);
assert!(!received.has_next_page);
assert!(!received.has_previous_page);*/
let
received
=
db_reader
.get_txs_history_bc_received
(
PageInfo
{
order
:
false
,
limit_opt
:
None
,
pos
:
Some
(
TxBcCursor
{
tx_hash
:
Hash
([
5
;
32
]),
block_number
:
BlockNumber
(
2
),
}),
},
s1_hash
,
)
?
;
assert_eq!
(
received
.data
.into_iter
()
.map
(|
tx_db
|
tx_db
.tx
.get_hash
())
.collect
::
<
Vec
<
_
>>
(),
vec!
[
Hash
([
4
;
32
]),
Hash
([
3
;
32
]),
Hash
([
2
;
32
]),
Hash
([
1
;
32
]),
Hash
([
0
;
32
]),
],
);
assert!
(
!
received
.has_next_page
);
assert!
(
!
received
.has_previous_page
);
Ok
(())
}
#[test]
fn
test_get_txs_history_bc_sent
()
->
KvResult
<
()
>
{
let
gva_db
=
duniter_gva_db
::
GvaV1Db
::
<
Mem
>
::
open
(
MemConf
::
default
())
?
;
...
...
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