Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2e22b79
dont use String for creating connections
krzysztofziobro Dec 27, 2022
20aafa6
do not wrap client
krzysztofziobro Dec 27, 2022
1f10b03
wip
krzysztofziobro Dec 28, 2022
2f5cda9
should work as old one
krzysztofziobro Dec 28, 2022
f5b769f
hide connection
krzysztofziobro Dec 28, 2022
44a4e9a
hide the rest
krzysztofziobro Dec 28, 2022
1472fd7
Don not hide clone
krzysztofziobro Dec 28, 2022
40225ca
Merge branch 'main' into A0-1613-improve-connection
krzysztofziobro Dec 29, 2022
168ce19
bump
krzysztofziobro Dec 29, 2022
0247e81
wip
krzysztofziobro Dec 30, 2022
4c1a6eb
wrap client
krzysztofziobro Dec 30, 2022
e41d124
rename client
krzysztofziobro Dec 30, 2022
7968aea
add Clone
krzysztofziobro Dec 30, 2022
9a979f6
Merge branch 'main' into A0-1613-improve-connection
krzysztofziobro Dec 30, 2022
50d7071
more general adder
krzysztofziobro Dec 30, 2022
dba9561
Add AsSigned
krzysztofziobro Dec 30, 2022
d700129
add impls for references
krzysztofziobro Dec 30, 2022
e45f361
wip
krzysztofziobro Jan 2, 2023
e6839b8
change TreasurySudoApi
krzysztofziobro Jan 2, 2023
8ec4625
Merge branch 'main' into A0-1613-improve-connection
krzysztofziobro Jan 2, 2023
3bf05d5
add methods to SignedConnectionApi
krzysztofziobro Jan 2, 2023
6b259b2
Merge branch 'A0-1613-improve-connection' of github.com:Cardinal-Cryp…
krzysztofziobro Jan 2, 2023
23d5a58
remove unnecessary casts
krzysztofziobro Jan 2, 2023
5600e11
Merge branch 'main' into A0-1613-improve-connection
krzysztofziobro Jan 2, 2023
b7ad771
review part 1
krzysztofziobro Jan 2, 2023
d156320
Merge branch 'A0-1613-improve-connection' of github.com:Cardinal-Cryp…
krzysztofziobro Jan 2, 2023
ef5625d
review part 2
krzysztofziobro Jan 2, 2023
af4d737
Make AsConnection visible only in crate
krzysztofziobro Jan 3, 2023
d15be1b
Merge branch 'main' into A0-1613-improve-connection
krzysztofziobro Jan 3, 2023
70db49a
Remove unnecessary dependencies on ConnectionApi
krzysztofziobro Jan 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add impls for references
  • Loading branch information
krzysztofziobro committed Dec 30, 2022
commit d700129fe9f0646cb557b1fb5e1a6d7b6c555b1f
57 changes: 37 additions & 20 deletions aleph-client/src/connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub trait AsConnection: Sync {
}

pub trait AsSigned: Sync {
fn as_signed(&self) -> SignedConnection;
fn as_signed(&self) -> &SignedConnection;
}

#[async_trait::async_trait]
Expand Down Expand Up @@ -74,9 +74,9 @@ pub struct SignedConnection {
signer: KeyPair,
}

#[derive(Clone)]
pub struct RootConnection {
connection: Connection,
root: KeyPair,
connection: SignedConnection,
}

#[async_trait::async_trait]
Expand Down Expand Up @@ -117,16 +117,13 @@ impl Clone for SignedConnection {
}
}

impl Clone for RootConnection {
fn clone(&self) -> Self {
RootConnection {
connection: self.connection.clone(),
root: KeyPair::new(self.root.signer().clone()),
}
impl AsConnection for Connection {
fn as_connection(&self) -> &Connection {
self
}
}

impl AsConnection for Connection {
impl AsConnection for &Connection {
fn as_connection(&self) -> &Connection {
self
}
Expand All @@ -138,24 +135,45 @@ impl AsConnection for SignedConnection {
}
}

impl AsConnection for RootConnection {
impl AsConnection for &SignedConnection {
fn as_connection(&self) -> &Connection {
&self.connection
}
}

impl AsConnection for RootConnection {
fn as_connection(&self) -> &Connection {
self.connection.as_connection()
}
}

impl AsConnection for &RootConnection {
fn as_connection(&self) -> &Connection {
self.connection.as_connection()
}
}

impl AsSigned for SignedConnection {
fn as_signed(&self) -> SignedConnection {
self.clone()
fn as_signed(&self) -> &SignedConnection {
self
}
}

impl AsSigned for &SignedConnection {
fn as_signed(&self) -> &SignedConnection {
self
}
}

impl AsSigned for RootConnection {
fn as_signed(&self) -> SignedConnection {
SignedConnection {
connection: self.connection.clone(),
signer: KeyPair::new(self.root.signer().clone()),
}
fn as_signed(&self) -> &SignedConnection {
&self.connection
}
}

impl AsSigned for &RootConnection {
fn as_signed(&self) -> &SignedConnection {
&self.connection
}
}

Expand Down Expand Up @@ -297,8 +315,7 @@ impl RootConnection {
}

Ok(Self {
connection,
root: signer,
connection: SignedConnection { connection, signer },
})
}
}
2 changes: 1 addition & 1 deletion benches/payout-stakers/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async fn setup_test_validators_and_nominator_stashes(
for (validator_index, validator) in validators.into_iter().enumerate() {
let (nominator_controller_accounts, nominator_stash_accounts) =
generate_nominator_accounts_with_minimal_bond(
&connection.as_signed(),
connection.as_signed(),
validator_index as u32,
validators_len as u32,
)
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/src/test/electing_validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pub async fn authorities_are_staking() -> anyhow::Result<()> {

let desired_validator_count = reserved_seats + non_reserved_seats;
let accounts = setup_accounts(desired_validator_count);
prepare_validators(&root_connection.as_signed(), node, &accounts).await?;
prepare_validators(root_connection.as_signed(), node, &accounts).await?;
info!("New validators are set up");

let reserved_validators = accounts.get_stash_accounts()[..reserved_seats as usize].to_vec();
Expand Down