pub fn new<S: BuildStorage>(
		backend: Arc<B>,
		executor: E,
		build_genesis_storage: S,
		execution_strategies: ExecutionStrategies
	) -> error::Result<Self> {
		if backend.blockchain().header(BlockId::Number(Zero::zero()))?.is_none() {
			let (genesis_storage, children_genesis_storage) = build_genesis_storage.build_storage()?;
			let mut op = backend.begin_operation()?;
			backend.begin_state_operation(&mut op, BlockId::Hash(Default::default()))?;
			let state_root = op.reset_storage(genesis_storage, children_genesis_storage)?;
			let genesis_block = genesis::construct_genesis_block::<Block>(state_root.into());
			info!("Initializing Genesis block/state (state: {}, header-hash: {})", genesis_block.header().state_root(), genesis_block.header().hash());
			op.set_block_data(
				genesis_block.deconstruct().0,
				Some(vec![]),
				None,
				crate::backend::NewBlockState::Final
			)?;
			backend.commit_operation(op)?;
		}

		Ok(Client {
			backend,
			executor,
			storage_notifications: Default::default(),
			import_notification_sinks: Default::default(),
			finality_notification_sinks: Default::default(),
			import_lock: Default::default(),
			importing_block: Default::default(),
			execution_strategies,
			_phantom: Default::default(),
		})
	}
/// Creates new Substrate Client with given blockchain and code executor.
Creates new Substrate Client with given blockchain and code executor.
Creates new Substrate Client with given blockchain and code executor .
pub fn new<S: BuildStorage>(
		backend: Arc<B>,
		executor: E,
		build_genesis_storage: S,
		execution_strategies: ExecutionStrategies
	) -> error::Result<Self> {
		if backend.blockchain().header(BlockId::Number(Zero::zero()))?.is_none() {
			let (genesis_storage, children_genesis_storage) = build_genesis_storage.build_storage()?;
			let mut op = backend.begin_operation()?;
			backend.begin_state_operation(&mut op, BlockId::Hash(Default::default()))?;
			let state_root = op.reset_storage(genesis_storage, children_genesis_storage)?;
			let genesis_block = genesis::construct_genesis_block::<Block>(state_root.into());
			info!("Initializing Genesis block/state (state: {}, header-hash: {})", genesis_block.header().state_root(), genesis_block.header().hash());
			op.set_block_data(
				genesis_block.deconstruct().0,
				Some(vec![]),
				None,
				crate::backend::NewBlockState::Final
			)?;
			backend.commit_operation(op)?;
		}
		Ok(Client {
			backend,
			executor,
			storage_notifications: Default::default(),
			import_notification_sinks: Default::default(),
			finality_notification_sinks: Default::default(),
			import_lock: Default::default(),
			importing_block: Default::default(),
			execution_strategies,
			_phantom: Default::default(),
		})
	}
pub fn new < S : BuildStorage > ( backend : Arc < B > , executor : E , build_genesis_storage : S , execution_strategies : ExecutionStrategies ) -> error :: Result < Self > { if backend . blockchain ( ) . header ( BlockId :: Number ( Zero :: zero ( ) ) ) ? . is_none ( ) { let ( genesis_storage , children_genesis_storage ) = build_genesis_storage . build_storage ( ) ? ; let mut op = backend . begin_operation ( ) ? ; backend . begin_state_operation ( & mut op , BlockId :: Hash ( Default :: default ( ) ) ) ? ; let state_root = op . reset_storage ( genesis_storage , children_genesis_storage ) ? ; let genesis_block = genesis :: construct_genesis_block :: < Block > ( state_root . into ( ) ) ; info ! ( " " genesis_block header ( ) state_root ( ) genesis_block header ( ) hash ( ) ) ; op . set_block_data ( genesis_block . deconstruct ( ) . 0 , Some ( vec ! [ ] ) , None , crate :: backend :: NewBlockState :: Final ) ? ; backend . commit_operation ( op ) ? ; } Ok ( Client { backend , executor , storage_notifications : Default :: default ( ) , import_notification_sinks : Default :: default ( ) , finality_notification_sinks : Default :: default ( ) , import_lock : Default :: default ( ) , importing_block : Default :: default ( ) , execution_strategies , _phantom : Default :: default ( ) , } ) }
Creates new Substrate Client with given blockchain and code executor.
Creates new Substrate Client with given blockchain and code executor .
backend
Arc<B>
executor
E
build_genesis_storage
S
execution_strategies
ExecutionStrategies
backend
Arc<B>
executor
E
build_genesis_storage
S
execution_strategies
ExecutionStrategies