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
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
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
typescript
duniter
Commits
949b2a3f
Commit
949b2a3f
authored
4 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[feat] gva:bca: add server meta data in BcaExecutor
parent
02a24c84
No related branches found
No related tags found
1 merge request
!1364
Bca
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
neon/native/src/server.rs
+2
-2
2 additions, 2 deletions
neon/native/src/server.rs
rust-libs/modules/gva/bca/src/lib.rs
+24
-5
24 additions, 5 deletions
rust-libs/modules/gva/bca/src/lib.rs
rust-libs/modules/gva/src/lib.rs
+13
-6
13 additions, 6 deletions
rust-libs/modules/gva/src/lib.rs
with
39 additions
and
13 deletions
neon/native/src/server.rs
+
2
−
2
View file @
949b2a3f
...
@@ -41,7 +41,7 @@ declare_types! {
...
@@ -41,7 +41,7 @@ declare_types! {
let
gva_conf
=
rust_server_conf_stringified
.gva
;
let
gva_conf
=
rust_server_conf_stringified
.gva
;
let
currency
=
rust_server_conf_stringified
.currency
;
let
currency
=
rust_server_conf_stringified
.currency
;
let
se
rver_pubkey
=
if
let
Some
(
self_keypair_str
)
=
rust_server_conf_stringified
.self_keypair
{
let
se
lf_key_pair
=
if
let
Some
(
self_keypair_str
)
=
rust_server_conf_stringified
.self_keypair
{
into_neon_res
(
&
mut
cx
,
crate
::
crypto
::
keypair_from_expanded_base58_secret_key
(
&
self_keypair_str
))
?
into_neon_res
(
&
mut
cx
,
crate
::
crypto
::
keypair_from_expanded_base58_secret_key
(
&
self_keypair_str
))
?
}
else
{
}
else
{
Ed25519KeyPair
::
generate_random
()
.expect
(
"fail to gen random keyypair"
)
Ed25519KeyPair
::
generate_random
()
.expect
(
"fail to gen random keyypair"
)
...
@@ -49,7 +49,7 @@ declare_types! {
...
@@ -49,7 +49,7 @@ declare_types! {
let
txs_mempool_size
=
rust_server_conf_stringified
.txs_mempool_size
as
usize
;
let
txs_mempool_size
=
rust_server_conf_stringified
.txs_mempool_size
as
usize
;
let
conf
=
DuniterConf
{
let
conf
=
DuniterConf
{
gva
:
gva_conf
,
gva
:
gva_conf
,
self_key_pair
:
server_pubkey
,
self_key_pair
,
txs_mempool_size
txs_mempool_size
};
};
...
...
This diff is collapsed.
Click to expand it.
rust-libs/modules/gva/bca/src/lib.rs
+
24
−
5
View file @
949b2a3f
...
@@ -32,6 +32,7 @@ use crate::exec_req_type::ExecReqTypeError;
...
@@ -32,6 +32,7 @@ use crate::exec_req_type::ExecReqTypeError;
use
crate
::
utils
::
AsyncReader
;
use
crate
::
utils
::
AsyncReader
;
use
async_bincode
::
AsyncBincodeReader
;
use
async_bincode
::
AsyncBincodeReader
;
use
bincode
::
Options
as
_
;
use
bincode
::
Options
as
_
;
use
dubp
::
crypto
::
keys
::
ed25519
::
Ed25519KeyPair
;
use
duniter_bca_types
::{
BcaReq
,
BcaReqTypeV0
,
BcaResp
,
BcaRespTypeV0
,
BcaRespV0
,
ReqExecError
};
use
duniter_bca_types
::{
BcaReq
,
BcaReqTypeV0
,
BcaResp
,
BcaRespTypeV0
,
BcaRespV0
,
ReqExecError
};
use
duniter_dbs
::{
FileBackend
,
SharedDbs
};
use
duniter_dbs
::{
FileBackend
,
SharedDbs
};
use
futures
::{
prelude
::
stream
::
FuturesUnordered
,
StreamExt
,
TryStream
,
TryStreamExt
};
use
futures
::{
prelude
::
stream
::
FuturesUnordered
,
StreamExt
,
TryStream
,
TryStreamExt
};
...
@@ -47,13 +48,19 @@ use duniter_gva_dbs_reader::DbsReader;
...
@@ -47,13 +48,19 @@ use duniter_gva_dbs_reader::DbsReader;
static
BCA_EXECUTOR
:
OnceCell
<
BcaExecutor
>
=
OnceCell
::
new
();
static
BCA_EXECUTOR
:
OnceCell
<
BcaExecutor
>
=
OnceCell
::
new
();
pub
fn
set_bca_executor
(
pub
fn
set_bca_executor
(
currency
:
String
,
dbs_pool
:
fast_threadpool
::
ThreadPoolAsyncHandler
<
SharedDbs
<
FileBackend
>>
,
dbs_pool
:
fast_threadpool
::
ThreadPoolAsyncHandler
<
SharedDbs
<
FileBackend
>>
,
dbs_reader
:
DbsReader
,
dbs_reader
:
DbsReader
,
self_keypair
:
Ed25519KeyPair
,
software_version
:
&
'static
str
,
)
{
)
{
BCA_EXECUTOR
BCA_EXECUTOR
.set
(
BcaExecutor
{
.set
(
BcaExecutor
{
currency
,
dbs_pool
,
dbs_pool
,
dbs_reader
,
dbs_reader
,
self_keypair
,
software_version
,
})
})
.unwrap_or_else
(|
_
|
panic!
(
"BCA_EXECUTOR already set !"
))
.unwrap_or_else
(|
_
|
panic!
(
"BCA_EXECUTOR already set !"
))
}
}
...
@@ -73,8 +80,11 @@ pub async fn execute<R: 'static + futures::AsyncRead + Send + Unpin>(
...
@@ -73,8 +80,11 @@ pub async fn execute<R: 'static + futures::AsyncRead + Send + Unpin>(
#[derive(Clone)]
#[derive(Clone)]
struct
BcaExecutor
{
struct
BcaExecutor
{
currency
:
String
,
dbs_pool
:
fast_threadpool
::
ThreadPoolAsyncHandler
<
SharedDbs
<
FileBackend
>>
,
dbs_pool
:
fast_threadpool
::
ThreadPoolAsyncHandler
<
SharedDbs
<
FileBackend
>>
,
dbs_reader
:
DbsReader
,
dbs_reader
:
DbsReader
,
self_keypair
:
Ed25519KeyPair
,
software_version
:
&
'static
str
,
}
}
use
uninit
::
extension_traits
::
VecCapacity
;
use
uninit
::
extension_traits
::
VecCapacity
;
impl
BcaExecutor
{
impl
BcaExecutor
{
...
@@ -200,11 +210,15 @@ pub(crate) fn bincode_opts() -> impl bincode::Options {
...
@@ -200,11 +210,15 @@ pub(crate) fn bincode_opts() -> impl bincode::Options {
#[cfg(test)]
#[cfg(test)]
mod
tests
{
mod
tests
{
use
super
::
*
;
use
super
::
*
;
pub
use
dubp
::
block
::
prelude
::
*
;
pub
use
dubp
::{
pub
use
dubp
::
crypto
::
hashs
::
Hash
;
block
::
prelude
::
*
,
pub
use
dubp
::
crypto
::
keys
::
ed25519
::
PublicKey
;
crypto
::{
pub
use
dubp
::
documents
::
transaction
::
TransactionInputV10
;
hashs
::
Hash
,
pub
use
dubp
::
wallet
::
prelude
::
*
;
keys
::{
ed25519
::
PublicKey
,
KeyPair
,
Seed32
},
},
documents
::
transaction
::
TransactionInputV10
,
wallet
::
prelude
::
*
,
};
pub
use
duniter_bca_types
::
BcaReqV0
;
pub
use
duniter_bca_types
::
BcaReqV0
;
pub
use
duniter_dbs
::
databases
::
bc_v2
::{
BcV2DbReadable
,
BcV2DbRo
};
pub
use
duniter_dbs
::
databases
::
bc_v2
::{
BcV2DbReadable
,
BcV2DbRo
};
pub
use
duniter_dbs
::
databases
::
cm_v1
::{
CmV1Db
,
CmV1DbReadable
};
pub
use
duniter_dbs
::
databases
::
cm_v1
::{
CmV1Db
,
CmV1DbReadable
};
...
@@ -248,8 +262,13 @@ mod tests {
...
@@ -248,8 +262,13 @@ mod tests {
let
threadpool
=
let
threadpool
=
fast_threadpool
::
ThreadPool
::
start
(
fast_threadpool
::
ThreadPoolConfig
::
low
(),
dbs
);
fast_threadpool
::
ThreadPool
::
start
(
fast_threadpool
::
ThreadPoolConfig
::
low
(),
dbs
);
Ok
(
BcaExecutor
{
Ok
(
BcaExecutor
{
currency
:
"g1"
.to_owned
(),
dbs_pool
:
threadpool
.into_async_handler
(),
dbs_pool
:
threadpool
.into_async_handler
(),
dbs_reader
:
duniter_dbs
::
kv_typed
::
prelude
::
Arc
::
new
(
mock_dbs_reader
),
dbs_reader
:
duniter_dbs
::
kv_typed
::
prelude
::
Arc
::
new
(
mock_dbs_reader
),
self_keypair
:
Ed25519KeyPair
::
from_seed
(
Seed32
::
random
()
.expect
(
"fail to gen random seed"
),
),
software_version
:
"test"
,
})
})
}
}
...
...
This diff is collapsed.
Click to expand it.
rust-libs/modules/gva/src/lib.rs
+
13
−
6
View file @
949b2a3f
...
@@ -28,10 +28,13 @@ mod warp_;
...
@@ -28,10 +28,13 @@ mod warp_;
pub
use
duniter_conf
::
gva_conf
::
GvaConf
;
pub
use
duniter_conf
::
gva_conf
::
GvaConf
;
use
async_graphql
::
http
::
GraphQLPlaygroundConfig
;
use
async_graphql
::
http
::
GraphQLPlaygroundConfig
;
use
dubp
::
common
::
crypto
::
keys
::{
ed25519
::
PublicKey
,
KeyPair
as
_
};
use
dubp
::
common
::
prelude
::
*
;
use
dubp
::
common
::
prelude
::
*
;
use
dubp
::
documents
::
transaction
::
TransactionDocumentV10
;
use
dubp
::
documents
::
transaction
::
TransactionDocumentV10
;
use
dubp
::{
block
::
DubpBlockV10
,
crypto
::
hashs
::
Hash
};
use
dubp
::{
block
::
DubpBlockV10
,
crypto
::
hashs
::
Hash
};
use
dubp
::{
common
::
crypto
::
keys
::{
ed25519
::
PublicKey
,
KeyPair
as
_
},
crypto
::
keys
::
ed25519
::
Ed25519KeyPair
,
};
use
duniter_conf
::
DuniterMode
;
use
duniter_conf
::
DuniterMode
;
use
duniter_dbs
::
databases
::
txs_mp_v2
::
TxsMpV2DbReadable
;
use
duniter_dbs
::
databases
::
txs_mp_v2
::
TxsMpV2DbReadable
;
use
duniter_dbs
::
prelude
::
*
;
use
duniter_dbs
::
prelude
::
*
;
...
@@ -52,7 +55,7 @@ pub struct GvaModule {
...
@@ -52,7 +55,7 @@ pub struct GvaModule {
gva_db_ro
:
&
'static
GvaV1DbRo
<
FileBackend
>
,
gva_db_ro
:
&
'static
GvaV1DbRo
<
FileBackend
>
,
mempools
:
Mempools
,
mempools
:
Mempools
,
mode
:
DuniterMode
,
mode
:
DuniterMode
,
self_
pubkey
:
PublicKey
,
self_
keypair
:
Ed25519KeyPair
,
software_version
:
&
'static
str
,
software_version
:
&
'static
str
,
}
}
...
@@ -119,7 +122,7 @@ impl duniter_module::DuniterModule for GvaModule {
...
@@ -119,7 +122,7 @@ impl duniter_module::DuniterModule for GvaModule {
gva_db_ro
:
get_gva_db_ro
(
profile_path_opt
),
gva_db_ro
:
get_gva_db_ro
(
profile_path_opt
),
mempools
,
mempools
,
mode
,
mode
,
self_
pub
key
:
conf
.self_key_pair
.
public_key
(),
self_key
pair
:
conf
.self_key_pair
.
clone
(),
software_version
,
software_version
,
},
},
endpoints
,
endpoints
,
...
@@ -136,7 +139,7 @@ impl duniter_module::DuniterModule for GvaModule {
...
@@ -136,7 +139,7 @@ impl duniter_module::DuniterModule for GvaModule {
gva_db_ro
,
gva_db_ro
,
mempools
,
mempools
,
mode
,
mode
,
self_
pub
key
,
self_key
pair
,
software_version
,
software_version
,
}
=
self
;
}
=
self
;
...
@@ -148,7 +151,7 @@ impl duniter_module::DuniterModule for GvaModule {
...
@@ -148,7 +151,7 @@ impl duniter_module::DuniterModule for GvaModule {
dbs_pool
,
dbs_pool
,
gva_db_ro
,
gva_db_ro
,
mempools
,
mempools
,
self_
pub
key
,
self_key
pair
,
software_version
,
software_version
,
)
)
.await
.await
...
@@ -231,13 +234,17 @@ impl GvaModule {
...
@@ -231,13 +234,17 @@ impl GvaModule {
dbs_pool
:
fast_threadpool
::
ThreadPoolAsyncHandler
<
SharedDbs
<
FileBackend
>>
,
dbs_pool
:
fast_threadpool
::
ThreadPoolAsyncHandler
<
SharedDbs
<
FileBackend
>>
,
gva_db_ro
:
&
'static
GvaV1DbRo
<
FileBackend
>
,
gva_db_ro
:
&
'static
GvaV1DbRo
<
FileBackend
>
,
mempools
:
Mempools
,
mempools
:
Mempools
,
self_
pubkey
:
PublicKey
,
self_
keypair
:
Ed25519KeyPair
,
software_version
:
&
'static
str
,
software_version
:
&
'static
str
,
)
{
)
{
log
::
info!
(
"GvaServer::start: conf={:?}"
,
conf
);
log
::
info!
(
"GvaServer::start: conf={:?}"
,
conf
);
let
self_pubkey
=
self_keypair
.public_key
();
duniter_bca
::
set_bca_executor
(
duniter_bca
::
set_bca_executor
(
currency
.clone
(),
dbs_pool
.clone
(),
dbs_pool
.clone
(),
duniter_gva_dbs_reader
::
create_dbs_reader
(
gva_db_ro
),
duniter_gva_dbs_reader
::
create_dbs_reader
(
gva_db_ro
),
self_keypair
,
software_version
,
);
);
let
gva_schema
=
duniter_gva_gql
::
build_schema_with_data
(
let
gva_schema
=
duniter_gva_gql
::
build_schema_with_data
(
duniter_gva_gql
::
GvaSchemaData
{
duniter_gva_gql
::
GvaSchemaData
{
...
...
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