Skip to content

Commit

Permalink
Merge pull request #20 from 0glabs/update-socket
Browse files Browse the repository at this point in the history
feat: update socket
  • Loading branch information
MiniFrenchBread authored Oct 16, 2024
2 parents faeed84 + aec5302 commit 8514e32
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
54 changes: 52 additions & 2 deletions chain-state/src/signers_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,66 @@ impl ChainState {
Ok(success) => {
if success {
info!("signer registered");
return Ok(());
sleep(Duration::from_secs(10)).await;
} else {
bail!(anyhow!("register signer failed"));
}
bail!(anyhow!("register signer failed"));
}
Err(e) => {
bail!(anyhow!(e));
}
}
}
}
match self
.da_signers
.get_signer(vec![self.signer_address])
.call()
.await?
.get(0)
{
Some(signer_detail) => {
if signer_detail.socket != socket {
info!(
"change socket of signer from {:?} to {:?}",
signer_detail.socket, socket
);
let input_data = self
.da_signers
.update_socket(socket.clone())
.calldata()
.unwrap();
let tx_request = TransactionRequest::new()
.to(self.da_signers.address())
.data(input_data);

match self
.transactor
.lock()
.await
.send(
tx_request,
TransactionInfo::UpdateSocket(self.signer_address, socket.clone()),
)
.await
{
Ok(success) => {
if success {
info!("socket updated to {:?}", socket.clone());
return Ok(());
}
bail!(anyhow!("update socket failed"));
}
Err(e) => {
bail!(anyhow!(e));
}
}
}
}
None => {
bail!("cannot get signer from precompile!")
}
}
Ok(())
}

Expand Down
1 change: 1 addition & 0 deletions chain-state/src/transactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use ethers::{
pub enum TransactionInfo {
RegisterSigner(H160),
RegisterEpoch(H160, u64),
UpdateSocket(H160, String),
}

pub struct Transactor {
Expand Down

0 comments on commit 8514e32

Please sign in to comment.