Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dunitrust
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
Container registry
Model registry
Operate
Environments
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
rust
Dunitrust
Commits
6b182239
Commit
6b182239
authored
5 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[style] bc-db-reader: use transpose()
parent
3f5bb49a
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
lib/modules-lib/bc-db-reader/src/blocks.rs
+3
-7
3 additions, 7 deletions
lib/modules-lib/bc-db-reader/src/blocks.rs
lib/modules-lib/bc-db-reader/src/indexes/identities.rs
+12
-18
12 additions, 18 deletions
lib/modules-lib/bc-db-reader/src/indexes/identities.rs
with
15 additions
and
25 deletions
lib/modules-lib/bc-db-reader/src/blocks.rs
+
3
−
7
View file @
6b182239
...
@@ -117,15 +117,11 @@ pub fn get_fork_block<DB: BcDbInReadTx>(
...
@@ -117,15 +117,11 @@ pub fn get_fork_block<DB: BcDbInReadTx>(
blockstamp
:
Blockstamp
,
blockstamp
:
Blockstamp
,
)
->
Result
<
Option
<
BlockDb
>
,
DbError
>
{
)
->
Result
<
Option
<
BlockDb
>
,
DbError
>
{
let
blockstamp_bytes
:
Vec
<
u8
>
=
blockstamp
.into
();
let
blockstamp_bytes
:
Vec
<
u8
>
=
blockstamp
.into
();
if
let
Some
(
v
)
=
db
db
.db
()
.db
()
.get_store
(
FORK_BLOCKS
)
.get_store
(
FORK_BLOCKS
)
.get
(
db
.r
(),
&
blockstamp_bytes
)
?
.get
(
db
.r
(),
&
blockstamp_bytes
)
?
{
.map
(
from_db_value
)
Ok
(
Some
(
from_db_value
(
v
)
?
))
.transpose
()
}
else
{
Ok
(
None
)
}
}
}
/// Get block hash
/// Get block hash
...
...
This diff is collapsed.
Click to expand it.
lib/modules-lib/bc-db-reader/src/indexes/identities.rs
+
12
−
18
View file @
6b182239
...
@@ -153,15 +153,11 @@ pub fn get_identity_by_wot_id<DB: BcDbInReadTx>(
...
@@ -153,15 +153,11 @@ pub fn get_identity_by_wot_id<DB: BcDbInReadTx>(
db
:
&
DB
,
db
:
&
DB
,
wot_id
:
WotId
,
wot_id
:
WotId
,
)
->
Result
<
Option
<
IdentityDb
>
,
DbError
>
{
)
->
Result
<
Option
<
IdentityDb
>
,
DbError
>
{
if
let
Some
(
v
)
=
db
db
.db
()
.db
()
.get_int_store
(
IDENTITIES
)
.get_int_store
(
IDENTITIES
)
.get
(
db
.r
(),
wot_id
.0
as
u32
)
?
.get
(
db
.r
(),
wot_id
.0
as
u32
)
?
{
.map
(
from_db_value
)
Ok
(
Some
(
from_db_value
(
v
)
?
))
.transpose
()
}
else
{
Ok
(
None
)
}
}
}
/// Get identity state from pubkey
/// Get identity state from pubkey
...
@@ -194,19 +190,17 @@ pub fn get_wot_id_from_uid<DB: BcDbInReadTx>(db: &DB, uid: &str) -> Result<Optio
...
@@ -194,19 +190,17 @@ pub fn get_wot_id_from_uid<DB: BcDbInReadTx>(db: &DB, uid: &str) -> Result<Optio
/// Get identity wot_id
/// Get identity wot_id
#[inline]
#[inline]
pub
fn
get_wot_id
<
DB
:
BcDbInReadTx
>
(
db
:
&
DB
,
pubkey
:
&
PubKey
)
->
Result
<
Option
<
WotId
>
,
DbError
>
{
pub
fn
get_wot_id
<
DB
:
BcDbInReadTx
>
(
db
:
&
DB
,
pubkey
:
&
PubKey
)
->
Result
<
Option
<
WotId
>
,
DbError
>
{
if
let
Some
(
v
)
=
db
db
.db
()
.db
()
.get_store
(
WOT_ID_INDEX
)
.get_store
(
WOT_ID_INDEX
)
.get
(
db
.r
(),
&
pubkey
.to_bytes_vector
())
?
.get
(
db
.r
(),
&
pubkey
.to_bytes_vector
())
?
{
.map
(|
v
|
{
if
let
DbValue
::
U64
(
wot_id
)
=
v
{
if
let
DbValue
::
U64
(
wot_id
)
=
v
{
Ok
(
Some
(
WotId
(
wot_id
as
usize
))
)
Ok
(
WotId
(
wot_id
as
usize
))
}
else
{
}
else
{
Err
(
DbError
::
DBCorrupted
)
Err
(
DbError
::
DBCorrupted
)
}
}
}
else
{
})
Ok
(
None
)
.transpose
()
}
}
}
/// Get wot_id index
/// Get wot_id index
pub
fn
get_wot_index
<
DB
:
BcDbInReadTx
>
(
db
:
&
DB
)
->
Result
<
HashMap
<
PubKey
,
WotId
>
,
DbError
>
{
pub
fn
get_wot_index
<
DB
:
BcDbInReadTx
>
(
db
:
&
DB
)
->
Result
<
HashMap
<
PubKey
,
WotId
>
,
DbError
>
{
...
...
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