Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
duniter-gva
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
modules
duniter-gva
Commits
1b65c83c
Commit
1b65c83c
authored
4 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
feat(db): add cols blocks_chunk_hash & compressed_blocks_chunk
parent
7fe98256
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
db/src/lib.rs
+5
-0
5 additions, 0 deletions
db/src/lib.rs
db/src/values.rs
+40
-0
40 additions, 0 deletions
db/src/values.rs
db/src/values/gva_block_db.rs
+57
-0
57 additions, 0 deletions
db/src/values/gva_block_db.rs
with
102 additions
and
0 deletions
db/src/lib.rs
+
5
−
0
View file @
1b65c83c
...
@@ -27,9 +27,11 @@ mod values;
...
@@ -27,9 +27,11 @@ mod values;
pub
use
keys
::
gva_utxo_id
::
GvaUtxoIdDbV1
;
pub
use
keys
::
gva_utxo_id
::
GvaUtxoIdDbV1
;
pub
use
keys
::
wallet_hash_with_bn
::
WalletHashWithBnV1Db
;
pub
use
keys
::
wallet_hash_with_bn
::
WalletHashWithBnV1Db
;
pub
use
values
::
gva_block_db
::
GvaBlockDbV1
;
pub
use
values
::
gva_idty_db
::
GvaIdtyDbV1
;
pub
use
values
::
gva_idty_db
::
GvaIdtyDbV1
;
pub
use
values
::
gva_tx
::
GvaTxDbV1
;
pub
use
values
::
gva_tx
::
GvaTxDbV1
;
pub
use
values
::
wallet_script_array
::
WalletScriptArrayV2
;
pub
use
values
::
wallet_script_array
::
WalletScriptArrayV2
;
pub
use
values
::
HashDb
;
pub
(
crate
)
use
dubp
::
common
::
prelude
::
*
;
pub
(
crate
)
use
dubp
::
common
::
prelude
::
*
;
pub
(
crate
)
use
dubp
::
crypto
::
hashs
::
Hash
;
pub
(
crate
)
use
dubp
::
crypto
::
hashs
::
Hash
;
...
@@ -50,6 +52,9 @@ db_schema!(
...
@@ -50,6 +52,9 @@ db_schema!(
[
"blocks_by_common_time"
,
BlocksByCommonTime
,
U64BE
,
u32
],
[
"blocks_by_common_time"
,
BlocksByCommonTime
,
U64BE
,
u32
],
[
"blocks_with_ud"
,
BlocksWithUd
,
U32BE
,
()],
[
"blocks_with_ud"
,
BlocksWithUd
,
U32BE
,
()],
[
"blockchain_time"
,
BlockchainTime
,
U32BE
,
u64
],
[
"blockchain_time"
,
BlockchainTime
,
U32BE
,
u64
],
[
"blocks_chunk_hash"
,
BlocksChunkHash
,
U32BE
,
HashDb
],
[
"compressed_blocks_chunk"
,
CompressedBlocksChunk
,
U32BE
,
Vec
<
u8
>
],
[
"current_blocks_chunk"
,
CurrentBlocksChunk
,
U32BE
,
GvaBlockDbV1
],
[
"txs"
,
Txs
,
HashKeyV2
,
GvaTxDbV1
],
[
"txs"
,
Txs
,
HashKeyV2
,
GvaTxDbV1
],
[
"txs_by_block"
,
TxsByBlock
,
U32BE
,
Vec
<
Hash
>
],
[
"txs_by_block"
,
TxsByBlock
,
U32BE
,
Vec
<
Hash
>
],
[
"txs_by_issuer"
,
TxsByIssuer
,
WalletHashWithBnV1Db
,
BTreeSet
<
Hash
>
],
[
"txs_by_issuer"
,
TxsByIssuer
,
WalletHashWithBnV1Db
,
BTreeSet
<
Hash
>
],
...
...
This diff is collapsed.
Click to expand it.
db/src/values.rs
+
40
−
0
View file @
1b65c83c
...
@@ -13,6 +13,46 @@
...
@@ -13,6 +13,46 @@
// You should have received a copy of the GNU Affero General Public License
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use
crate
::
*
;
pub
mod
gva_block_db
;
pub
mod
gva_idty_db
;
pub
mod
gva_idty_db
;
pub
mod
gva_tx
;
pub
mod
gva_tx
;
pub
mod
wallet_script_array
;
pub
mod
wallet_script_array
;
#[derive(Clone,
Copy,
Debug,
Default,
PartialEq,
Serialize,
Deserialize)]
pub
struct
HashDb
(
pub
Hash
);
impl
AsBytes
for
HashDb
{
fn
as_bytes
<
T
,
F
:
FnMut
(
&
[
u8
])
->
T
>
(
&
self
,
mut
f
:
F
)
->
T
{
f
(
self
.0
.as_ref
())
}
}
impl
kv_typed
::
prelude
::
FromBytes
for
HashDb
{
type
Err
=
bincode
::
Error
;
fn
from_bytes
(
bytes
:
&
[
u8
])
->
std
::
result
::
Result
<
Self
,
Self
::
Err
>
{
let
mut
hash_bytes
=
[
0
;
32
];
hash_bytes
.copy_from_slice
(
bytes
);
Ok
(
Self
(
Hash
(
hash_bytes
)))
}
}
impl
ToDumpString
for
HashDb
{
fn
to_dump_string
(
&
self
)
->
String
{
todo!
()
}
}
#[cfg(feature
=
"explorer"
)]
impl
ExplorableValue
for
HashDb
{
fn
from_explorer_str
(
source
:
&
str
)
->
Result
<
Self
,
FromExplorerValueErr
>
{
Ok
(
Self
(
Hash
::
from_hex
(
source
)
.map_err
(|
e
|
FromExplorerValueErr
(
e
.into
()))
?
,
))
}
fn
to_explorer_json
(
&
self
)
->
KvResult
<
serde_json
::
Value
>
{
Ok
(
serde_json
::
Value
::
String
(
self
.0
.to_hex
()))
}
}
This diff is collapsed.
Click to expand it.
db/src/values/gva_block_db.rs
0 → 100644
+
57
−
0
View file @
1b65c83c
// Copyright (C) 2020 Éloïs SANCHEZ.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use
crate
::
*
;
use
dubp
::
block
::{
DubpBlock
,
DubpBlockV10
};
#[derive(Clone,
Debug,
PartialEq,
Serialize,
Deserialize)]
#[repr(transparent)]
pub
struct
GvaBlockDbV1
(
pub
DubpBlock
);
impl
Default
for
GvaBlockDbV1
{
fn
default
()
->
Self
{
Self
(
DubpBlock
::
V10
(
DubpBlockV10
::
default
()))
}
}
impl
AsBytes
for
GvaBlockDbV1
{
fn
as_bytes
<
T
,
F
:
FnMut
(
&
[
u8
])
->
T
>
(
&
self
,
mut
f
:
F
)
->
T
{
f
(
&
bincode
::
serialize
(
&
self
)
.unwrap_or_else
(|
_
|
unreachable!
()))
}
}
impl
kv_typed
::
prelude
::
FromBytes
for
GvaBlockDbV1
{
type
Err
=
bincode
::
Error
;
fn
from_bytes
(
bytes
:
&
[
u8
])
->
std
::
result
::
Result
<
Self
,
Self
::
Err
>
{
bincode
::
deserialize
(
bytes
)
}
}
impl
ToDumpString
for
GvaBlockDbV1
{
fn
to_dump_string
(
&
self
)
->
String
{
todo!
()
}
}
#[cfg(feature
=
"explorer"
)]
impl
ExplorableValue
for
GvaBlockDbV1
{
fn
from_explorer_str
(
source
:
&
str
)
->
Result
<
Self
,
FromExplorerValueErr
>
{
serde_json
::
from_str
(
source
)
.map_err
(|
e
|
FromExplorerValueErr
(
e
.into
()))
}
fn
to_explorer_json
(
&
self
)
->
KvResult
<
serde_json
::
Value
>
{
serde_json
::
to_value
(
&
self
)
.map_err
(|
e
|
KvError
::
DeserError
(
e
.into
()))
}
}
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