pub struct ChainSyncInterfaceHandle<B: BlockT> { /* private fields */ }
Expand description

Handle for communicating with ChainSync asynchronously

Implementations§

Create new handle

Examples found in repository?
src/lib.rs (line 1499)
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
	pub fn new(
		mode: SyncMode,
		client: Arc<Client>,
		protocol_id: ProtocolId,
		fork_id: &Option<String>,
		roles: Roles,
		block_announce_validator: Box<dyn BlockAnnounceValidator<B> + Send>,
		max_parallel_downloads: u32,
		warp_sync_provider: Option<Arc<dyn WarpSyncProvider<B>>>,
		metrics_registry: Option<&Registry>,
		network_service: service::network::NetworkServiceHandle,
		import_queue: Box<dyn ImportQueueService<B>>,
		block_request_protocol_name: ProtocolName,
		state_request_protocol_name: ProtocolName,
		warp_sync_protocol_name: Option<ProtocolName>,
	) -> Result<(Self, ChainSyncInterfaceHandle<B>, NonDefaultSetConfig), ClientError> {
		let (tx, service_rx) = tracing_unbounded("mpsc_chain_sync");
		let block_announce_config = Self::get_block_announce_proto_config(
			protocol_id,
			fork_id,
			roles,
			client.info().best_number,
			client.info().best_hash,
			client
				.block_hash(Zero::zero())
				.ok()
				.flatten()
				.expect("Genesis block exists; qed"),
		);

		let mut sync = Self {
			client,
			peers: HashMap::new(),
			blocks: BlockCollection::new(),
			best_queued_hash: Default::default(),
			best_queued_number: Zero::zero(),
			extra_justifications: ExtraRequests::new("justification"),
			mode,
			queue_blocks: Default::default(),
			fork_targets: Default::default(),
			allowed_requests: Default::default(),
			block_announce_validator,
			max_parallel_downloads,
			downloaded_blocks: 0,
			block_announce_validation: Default::default(),
			block_announce_validation_per_peer_stats: Default::default(),
			state_sync: None,
			warp_sync: None,
			warp_sync_provider,
			import_existing: false,
			gap_sync: None,
			service_rx,
			network_service,
			block_request_protocol_name,
			state_request_protocol_name,
			warp_sync_protocol_name,
			block_announce_protocol_name: block_announce_config
				.notifications_protocol
				.clone()
				.into(),
			pending_responses: Default::default(),
			import_queue,
			metrics: if let Some(r) = &metrics_registry {
				match SyncingMetrics::register(r) {
					Ok(metrics) => Some(metrics),
					Err(err) => {
						error!(target: "sync", "Failed to register metrics for ChainSync: {err:?}");
						None
					},
				}
			} else {
				None
			},
		};

		sync.reset_sync_start_point()?;
		Ok((sync, ChainSyncInterfaceHandle::new(tx), block_announce_config))
	}

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Request a justification for the given block from the network.

On success, the justification will be passed to the import queue that was part at initialization as part of the configuration.

Clear all pending justification requests.
Batch of blocks imported, with or without error.
Justification import result.
Request a justification for the given block.

Configure an explicit fork sync request.

Note that this function should not be used for recent blocks. Sync should be able to download all the recent forks normally. set_sync_fork_request should only be used if external code detects that there’s a stale fork missing.

Passing empty peers set effectively removes the sync request.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Convert from a value of T into an equivalent instance of Option<Self>. Read more
Consume self to return Some equivalent value of Option<T>. Read more
Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Get a reference to the inner from the outer.

Get a mutable reference to the inner from the outer.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
Convert from a value of T into an equivalent instance of Self. Read more
Consume self to return an equivalent value of T. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
The counterpart to unchecked_from.
Consume self to return an equivalent value of T.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more