diff --git a/sharding/listener.go b/sharding/collator.go similarity index 73% rename from sharding/listener.go rename to sharding/collator.go index 8d3a85e5c..addd46f46 100644 --- a/sharding/listener.go +++ b/sharding/collator.go @@ -27,6 +27,15 @@ func subscribeBlockHeaders(c *Client) error { case head := <-headerChan: // Query the current state to see if we are an eligible proposer log.Info(fmt.Sprintf("received new header %v", head.Number.String())) + // TODO: Only run this code on certain periods? + watchShards(head) } } } + +// watchShards checks if we are an eligible proposer for collation for +// the available shards in the VMC. The function calls getEligibleProposer from +// the VMC and proposes a collation if conditions are met +func watchShards(head types.Header) { + +} diff --git a/sharding/vmc.go b/sharding/vmc.go index b380c6362..22007056f 100644 --- a/sharding/vmc.go +++ b/sharding/vmc.go @@ -71,9 +71,10 @@ func initVMC(c *Client) error { // the account is not in the set, it will deposit 100ETH into contract. func initVMCValidator(c *Client) error { - // TODO: Check if account is already in validator set. Do we need to implement - // a func in solidity to do this? + // TODO: Check if account is already in validator set. Fetch this From + // the VMC contract's validator set. + // Unlocks the current account from the keystore accounts := c.keystore.Accounts() if len(accounts) == 0 { return fmt.Errorf("no accounts found") @@ -96,10 +97,11 @@ func initVMCValidator(c *Client) error { }, } - tx, err := c.vmc.VMCTransactor.Deposit(&ops, /* validatorcodeaddr */, accounts[0].Address) + _, err := c.vmc.VMCTransactor.Deposit(&ops, accounts[0].Address) if err != nil { return fmt.Errorf("unable to deposit eth and become a validator: %v", err) } + log.Info(fmt.Sprintf("deposited 100ETH into contract")) return nil }