Function ibc_test_framework::bootstrap::binary::chain::spawn_chain_handle
source · pub fn spawn_chain_handle<Seed>(
_: Seed,
registry: &SharedRegistry<impl ChainHandle>,
node: &FullNode
) -> Result<impl ChainHandle, Report>
Expand description
Spawn a new chain handle using the given SharedRegistry
and
FullNode
.
The function accepts a proxy type Seed
that should be unique
accross multiple calls so that the returned ChainHandle
have a unique type.
For example, the following test should fail to compile:
ⓘ
fn same<T>(_: T, _: T) {}
let chain_a = spawn_chain_handle(|| {}, todo!(), todo!()).unwrap();
let chain_b = spawn_chain_handle(|| {}, todo!(), todo!()).unwrap();
same(chain_a, chain_b); // error: chain_a and chain_b have different types
The reason is that Rust would give each closure expression ||{}
a
unique anonymous type.
When we instantiate two chains with different closure types,
the resulting values would be considered by Rust to have different types.
With this we can treat chain_a
and chain_b
having different types
so that we do not accidentally mix them up later in the code.