mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 00:27:38 +00:00
proper error handling in collator.go
Former-commit-id: b2b5a4602f2767dfdd8b3de3b2a9cf4994f8e2fa [formerly 1b764bc06d5d5eff79ffc197d89c3614313d7bb3] Former-commit-id: ec5a587e262d81211ba525afaf603a89fc1916f6
This commit is contained in:
parent
6314e30738
commit
ad2a5a655b
@ -75,9 +75,9 @@ func (c *Client) Start() error {
|
||||
// Deposit 100ETH into the validator set in the VMC. Checks if account
|
||||
// is already a validator in the VMC (in the case the client restarted).
|
||||
// Once that's done we can subscribe to block headers
|
||||
// if err := initVMCValidator(c); err != nil {
|
||||
// return err
|
||||
// }
|
||||
if err := initVMCValidator(c); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Listens to block headers from the geth node and if we are an eligible
|
||||
// proposer, we fetch pending transactions and propose a collation
|
||||
|
@ -18,7 +18,7 @@ func subscribeBlockHeaders(c *Client) error {
|
||||
|
||||
_, err := c.client.SubscribeNewHead(context.Background(), headerChan)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("unable to subscribe to incoming headers. %v", err)
|
||||
}
|
||||
|
||||
log.Info("listening for new headers...")
|
||||
@ -31,7 +31,7 @@ func subscribeBlockHeaders(c *Client) error {
|
||||
// TODO: Only run this code on certain periods?
|
||||
err := watchShards(c, head)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("unable to watch shards. %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -48,13 +48,13 @@ func watchShards(c *Client, head *types.Header) error {
|
||||
}
|
||||
|
||||
if err := c.unlockAccount(accounts[0]); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("cannot unlock account. %v", err)
|
||||
}
|
||||
|
||||
ops := bind.CallOpts{}
|
||||
count, err := c.vmc.VMCCaller.ShardCount(&ops)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("unable to fetch shard count. %v", err)
|
||||
}
|
||||
|
||||
s := 0
|
||||
@ -62,12 +62,15 @@ func watchShards(c *Client, head *types.Header) error {
|
||||
// Checks if we are an eligible proposer according to the VMC
|
||||
addr, err := c.vmc.VMCCaller.GetEligibleProposer(&ops, big.NewInt(s))
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("cannot fetch eligible collation proposer. %v", err)
|
||||
}
|
||||
// if the address is the coinbase addr (current node running the sharding
|
||||
// clint, then we propose a new collation)
|
||||
if addr == accounts[0].Address {
|
||||
proposeCollation()
|
||||
err := proposeCollation()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not propose collation. %v", err)
|
||||
}
|
||||
}
|
||||
s++
|
||||
}
|
||||
@ -75,6 +78,6 @@ func watchShards(c *Client, head *types.Header) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func proposeCollation() {
|
||||
func proposeCollation() error {
|
||||
return nil
|
||||
}
|
||||
|
0
sharding/collator_test.go
Normal file
0
sharding/collator_test.go
Normal file
@ -72,7 +72,7 @@ func initVMC(c *Client) error {
|
||||
func initVMCValidator(c *Client) error {
|
||||
|
||||
// TODO: Check if account is already in validator set. Fetch this From
|
||||
// the VMC contract's validator set.
|
||||
// the VMC contract's validator set
|
||||
|
||||
// Unlocks the current account from the keystore
|
||||
accounts := c.keystore.Accounts()
|
||||
|
Loading…
Reference in New Issue
Block a user