Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
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
Monitor
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
nodes
rust
Duniter v2S
Commits
df2a0f54
Commit
df2a0f54
authored
3 months ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
review: add --public-endpoints option
parent
b120850f
No related branches found
No related tags found
1 merge request
!316
Resolve "Add RPC method to list peers"
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
node/src/cli.rs
+15
-0
15 additions, 0 deletions
node/src/cli.rs
node/src/endpoint_gossip/mod.rs
+1
-1
1 addition, 1 deletion
node/src/endpoint_gossip/mod.rs
node/src/service.rs
+32
-17
32 additions, 17 deletions
node/src/service.rs
with
48 additions
and
18 deletions
node/src/cli.rs
+
15
−
0
View file @
df2a0f54
...
@@ -44,6 +44,21 @@ pub struct DuniterConfigExtension {
...
@@ -44,6 +44,21 @@ pub struct DuniterConfigExtension {
/// Public Squid graphql endpoint to gossip on the network and make available in the apps.
/// Public Squid graphql endpoint to gossip on the network and make available in the apps.
#[arg(long)]
#[arg(long)]
pub
public_squid
:
Option
<
String
>
,
pub
public_squid
:
Option
<
String
>
,
/// Public endpoints from a JSON file, using following format where `protocol` and `address` are
/// strings (value is free) :
///
/// ```json
/// {
/// "endpoints": [
/// { "protocol": "rpc", "address": "wss://gdev.example.com" },
/// { "protocol": "squid", "address": "gdev.example.com/graphql/v1" },
/// { "protocol": "other", "address": "gdev.example.com/other" }
/// ]
/// }
/// ```
#[arg(long,
value_name
=
"JSON_FILE_PATH"
)]
pub
public_endpoints
:
Option
<
String
>
,
}
}
#[derive(Debug,
clap::Subcommand)]
#[derive(Debug,
clap::Subcommand)]
...
...
This diff is collapsed.
Click to expand it.
node/src/endpoint_gossip/mod.rs
+
1
−
1
View file @
df2a0f54
...
@@ -102,5 +102,5 @@ pub type DuniterEndpoints = BoundedVec<DuniterEndpoint, ConstU32<10>>;
...
@@ -102,5 +102,5 @@ pub type DuniterEndpoints = BoundedVec<DuniterEndpoint, ConstU32<10>>;
#[derive(Encode,
Decode,
Serialize,
Deserialize,
Clone,
Debug,
PartialEq,
Eq)]
#[derive(Encode,
Decode,
Serialize,
Deserialize,
Clone,
Debug,
PartialEq,
Eq)]
pub
struct
Peering
{
pub
struct
Peering
{
endpoints
:
DuniterEndpoints
,
pub
endpoints
:
DuniterEndpoints
,
}
}
This diff is collapsed.
Click to expand it.
node/src/service.rs
+
32
−
17
View file @
df2a0f54
...
@@ -23,13 +23,14 @@ use crate::{
...
@@ -23,13 +23,14 @@ use crate::{
endpoint_gossip
::{
endpoint_gossip
::{
rpc
::
state
::
DuniterPeeringsState
,
rpc
::
state
::
DuniterPeeringsState
,
well_known_endpoint_types
::{
RPC
,
SQUID
},
well_known_endpoint_types
::{
RPC
,
SQUID
},
DuniterEndpoint
,
DuniterEndpoint
,
DuniterEndpoints
,
Peering
,
},
},
rpc
::
DuniterPeeringRpcModuleDeps
,
rpc
::
DuniterPeeringRpcModuleDeps
,
};
};
use
async_io
::
Timer
;
use
async_io
::
Timer
;
use
common_runtime
::
Block
;
use
common_runtime
::
Block
;
use
futures
::{
Stream
,
StreamExt
};
use
futures
::{
Stream
,
StreamExt
};
use
log
::
error
;
use
sc_client_api
::{
client
::
BlockBackend
,
Backend
};
use
sc_client_api
::{
client
::
BlockBackend
,
Backend
};
use
sc_consensus_grandpa
::{
FinalityProofProvider
,
SharedVoterState
};
use
sc_consensus_grandpa
::{
FinalityProofProvider
,
SharedVoterState
};
use
sc_consensus_manual_seal
::{
run_manual_seal
,
EngineCommand
,
ManualSealParams
};
use
sc_consensus_manual_seal
::{
run_manual_seal
,
EngineCommand
,
ManualSealParams
};
...
@@ -42,7 +43,7 @@ use sc_transaction_pool_api::TransactionPool;
...
@@ -42,7 +43,7 @@ use sc_transaction_pool_api::TransactionPool;
use
sp_consensus_babe
::
inherents
::
InherentDataProvider
;
use
sp_consensus_babe
::
inherents
::
InherentDataProvider
;
use
sp_core
::
H256
;
use
sp_core
::
H256
;
use
sp_runtime
::
traits
::
BlakeTwo256
;
use
sp_runtime
::
traits
::
BlakeTwo256
;
use
std
::{
sync
::
Arc
,
time
::
Duration
};
use
std
::{
fs
,
sync
::
Arc
,
time
::
Duration
};
#[cfg(not(feature
=
"runtime-benchmarks"
))]
#[cfg(not(feature
=
"runtime-benchmarks"
))]
type
HostFunctions
=
sp_io
::
SubstrateHostFunctions
;
type
HostFunctions
=
sp_io
::
SubstrateHostFunctions
;
...
@@ -729,26 +730,40 @@ where
...
@@ -729,26 +730,40 @@ where
);
);
}
}
let
mut
duniter_endpoints
=
vec!
[];
// Get the endpoint list from file first
let
mut
duniter_endpoints
:
DuniterEndpoints
=
match
duniter_options
.public_endpoints
{
None
=>
DuniterEndpoints
::
truncate_from
(
vec!
[]),
Some
(
path
)
=>
fs
::
read_to_string
(
path
)
.map
(|
s
|
{
serde_json
::
from_str
::
<
Peering
>
(
&
s
)
.expect
(
"Failed to parse Duniter endpoints"
)
})
.map
(|
p
|
p
.endpoints
)
.expect
(
"Failed to read Duniter endpoints"
),
};
// Then add through the specific options
if
let
Some
(
rpc_endoint
)
=
duniter_options
.public_rpc
{
if
let
Some
(
rpc_endoint
)
=
duniter_options
.public_rpc
{
duniter_endpoints
.push
(
DuniterEndpoint
{
if
duniter_endpoints
.try_push
(
DuniterEndpoint
{
protocol
:
RPC
.into
(),
protocol
:
RPC
.into
(),
address
:
rpc_endoint
,
address
:
rpc_endoint
,
});
})
.is_err
()
{
error!
(
"Could not add RPC endpoint, too much endpoints already"
);
}
}
}
if
let
Some
(
squid_endoint
)
=
duniter_options
.public_squid
{
if
let
Some
(
squid_endoint
)
=
duniter_options
.public_squid
{
duniter_endpoints
.push
(
DuniterEndpoint
{
if
duniter_endpoints
.try_push
(
DuniterEndpoint
{
protocol
:
SQUID
.into
(),
protocol
:
SQUID
.into
(),
address
:
squid_endoint
,
address
:
squid_endoint
,
});
})
.is_err
()
{
error!
(
"Could not add SQUID endpoint, too much endpoints already"
);
}
}
let
duniter_endpoints
=
match
duniter_endpoints
.try_into
()
{
Ok
(
endpoints
)
=>
endpoints
,
Err
(
_
)
=>
{
return
Err
(
"Too much Duniter endpoints"
.into
());
}
}
};
task_manager
.spawn_handle
()
.spawn_blocking
(
task_manager
.spawn_handle
()
.spawn_blocking
(
"duniter-endpoint-gossip-handler"
,
"duniter-endpoint-gossip-handler"
,
Some
(
"networking"
),
Some
(
"networking"
),
...
...
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