mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-10 11:41:21 +00:00
13789b6e63
Former-commit-id: 9d452ada62e9afe7295d07b2e7650736e640b39a [formerly ef6fcf4365cff18f14e9bfbd43d6b9d362abfbe4] Former-commit-id: ede05e77ef22b10fd7d12ac635d2879165416904
31 lines
922 B
Go
31 lines
922 B
Go
package collator
|
|
|
|
import (
|
|
"fmt"
|
|
"math/big"
|
|
|
|
"github.com/ethereum/go-ethereum/log"
|
|
"github.com/ethereum/go-ethereum/params"
|
|
"github.com/ethereum/go-ethereum/sharding"
|
|
"github.com/ethereum/go-ethereum/sharding/client"
|
|
)
|
|
|
|
// joinCollatorPool checks if the account is a collator in the SMC. If
|
|
// the account is not in the set, it will deposit 100ETH into contract.
|
|
func joinCollatorPool(c client.Client) error {
|
|
|
|
log.Info("Joining collator pool")
|
|
txOps, err := c.CreateTXOps(sharding.DepositSize)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to intiate the deposit transaction: %v", err)
|
|
}
|
|
|
|
tx, err := c.SMCTransactor().Deposit(txOps)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to deposit eth and become a collator: %v", err)
|
|
}
|
|
log.Info(fmt.Sprintf("Deposited %dETH into contract with transaction hash: %s", new(big.Int).Div(sharding.DepositSize, big.NewInt(params.Ether)), tx.Hash().String()))
|
|
|
|
return nil
|
|
}
|