Skip to content

Commit

Permalink
Polkadot companion for paritytech#8143 (paritytech#2535)
Browse files Browse the repository at this point in the history
Companion for paritytech#8143
  • Loading branch information
cecton authored Mar 11, 2021
1 parent c0474d2 commit c8649e5
Show file tree
Hide file tree
Showing 8 changed files with 245 additions and 185 deletions.
297 changes: 147 additions & 150 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions cli/src/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.

use browser_utils::{browser_configuration, init_logging_and_telemetry, set_console_error_panic_hook, Client};
use browser_utils::{browser_configuration, init_logging, set_console_error_panic_hook, Client};
use log::info;
use wasm_bindgen::prelude::*;

Expand All @@ -26,12 +26,11 @@ pub async fn start_client(chain_spec: String, log_level: String) -> Result<Clien

async fn start_inner(chain_spec: String, log_directives: String) -> Result<Client, Box<dyn std::error::Error>> {
set_console_error_panic_hook();
let telemetry_worker = init_logging_and_telemetry(&log_directives)?;
init_logging(&log_directives)?;

let chain_spec =
service::PolkadotChainSpec::from_json_bytes(chain_spec.as_bytes().to_vec()).map_err(|e| format!("{:?}", e))?;
let telemetry_handle = telemetry_worker.handle();
let config = browser_configuration(chain_spec, Some(telemetry_handle)).await?;
let config = browser_configuration(chain_spec).await?;

info!("Polkadot browser node");
info!(" version {}", config.impl_version);
Expand All @@ -41,9 +40,7 @@ async fn start_inner(chain_spec: String, log_directives: String) -> Result<Clien
info!("👤 Role: {}", config.display_role());

// Create the service. This is the most heavy initialization step.
let (task_manager, rpc_handlers, _) = service::build_light(config).map_err(|e| format!("{:?}", e))?;

task_manager.spawn_handle().spawn("telemetry", telemetry_worker.run());
let (task_manager, rpc_handlers) = service::build_light(config).map_err(|e| format!("{:?}", e))?;

Ok(browser_utils::start_client(task_manager, rpc_handlers))
}
3 changes: 2 additions & 1 deletion cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,13 @@ pub fn run() -> Result<()> {
let role = config.role.clone();

let task_manager = match role {
Role::Light => service::build_light(config).map(|(task_manager, _, _)| task_manager),
Role::Light => service::build_light(config).map(|(task_manager, _)| task_manager),
_ => service::build_full(
config,
service::IsCollator::No,
grandpa_pause,
jaeger_agent,
None,
).map(|full| full.task_manager)
}?;
Ok::<_, Error>(task_manager)
Expand Down
1 change: 1 addition & 0 deletions node/core/proposer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ polkadot-primitives = { path = "../../../primitives" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
3 changes: 3 additions & 0 deletions node/core/proposer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use polkadot_primitives::v1::{
Block, Hash, Header,
};
use sc_block_builder::{BlockBuilderApi, BlockBuilderProvider};
use sc_telemetry::TelemetryHandle;
use sp_core::traits::SpawnNamed;
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_blockchain::HeaderBackend;
Expand All @@ -55,13 +56,15 @@ impl<TxPool, Backend, Client> ProposerFactory<TxPool, Backend, Client> {
transaction_pool: Arc<TxPool>,
overseer: OverseerHandler,
prometheus: Option<&PrometheusRegistry>,
telemetry: Option<TelemetryHandle>,
) -> Self {
ProposerFactory {
inner: sc_basic_authorship::ProposerFactory::new(
spawn_handle,
client,
transaction_pool,
prometheus,
telemetry,
),
overseer,
}
Expand Down
Loading

0 comments on commit c8649e5

Please sign in to comment.