mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
Use network id from command line
Former-commit-id: 78c94954b281ba8b12802e7b54c0d1ceeda36a30 [formerly 907fdb09efcd3b4cc31aee5d9a2e354dfb84e093] Former-commit-id: a9e66d5a14df26edbb4e2eedc1416e29284677cc
This commit is contained in:
parent
1061ade1f8
commit
9ba9274ea5
@ -13,7 +13,7 @@ var (
|
|||||||
Name: "shard",
|
Name: "shard",
|
||||||
Usage: "Start a sharding client",
|
Usage: "Start a sharding client",
|
||||||
ArgsUsage: "[endpoint]",
|
ArgsUsage: "[endpoint]",
|
||||||
Flags: append(append(consoleFlags, utils.DataDirFlag), utils.PasswordFileFlag),
|
Flags: []cli.Flag{utils.DataDirFlag, utils.PasswordFileFlag, utils.NetworkIdFlag},
|
||||||
Category: "SHARDING COMMANDS",
|
Category: "SHARDING COMMANDS",
|
||||||
Description: "TODO(prestonvanloon)- Add sharding client description",
|
Description: "TODO(prestonvanloon)- Add sharding client description",
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,11 @@ const (
|
|||||||
|
|
||||||
// Client for sharding. Communicates to geth node via JSON RPC.
|
// Client for sharding. Communicates to geth node via JSON RPC.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
endpoint string // Endpoint to JSON RPC
|
endpoint string // Endpoint to JSON RPC
|
||||||
client *ethclient.Client // Ethereum RPC client.
|
client *ethclient.Client // Ethereum RPC client.
|
||||||
keystore *keystore.KeyStore // Keystore containing the single signer
|
keystore *keystore.KeyStore // Keystore containing the single signer
|
||||||
ctx *cli.Context // Command line context
|
ctx *cli.Context // Command line context
|
||||||
|
networkID uint64 // Ethereum network ID
|
||||||
}
|
}
|
||||||
|
|
||||||
// MakeShardingClient for interfacing with geth full node.
|
// MakeShardingClient for interfacing with geth full node.
|
||||||
@ -40,13 +41,18 @@ func MakeShardingClient(ctx *cli.Context) *Client {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err) // TODO(prestonvanloon): handle this
|
panic(err) // TODO(prestonvanloon): handle this
|
||||||
}
|
}
|
||||||
|
|
||||||
ks := keystore.NewKeyStore(keydir, scryptN, scryptP)
|
ks := keystore.NewKeyStore(keydir, scryptN, scryptP)
|
||||||
|
|
||||||
|
networkID := uint64(1)
|
||||||
|
if ctx.GlobalIsSet(utils.NetworkIdFlag.Name) {
|
||||||
|
networkID = ctx.GlobalUint64(utils.NetworkIdFlag.Name)
|
||||||
|
}
|
||||||
|
|
||||||
return &Client{
|
return &Client{
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
keystore: ks,
|
keystore: ks,
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
|
networkID: networkID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
cli "gopkg.in/urfave/cli.v1"
|
cli "gopkg.in/urfave/cli.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FakeEthService based on implementation of internal/ethapi
|
// FakeEthService based on implementation of internal/ethapi.Client
|
||||||
type FakeEthService struct {
|
type FakeEthService struct {
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ func (c *Client) deployVMC() (*common.Address, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tx := types.NewContractCreation(nonce, new(big.Int).SetInt64(0) /*amount*/, contractGasLimit, suggestedGasPrice, abiBytecode)
|
tx := types.NewContractCreation(nonce, new(big.Int).SetInt64(0) /*amount*/, contractGasLimit, suggestedGasPrice, abiBytecode)
|
||||||
signed, err := c.keystore.SignTx(accounts[0], tx, new(big.Int).SetInt64(1000) /*chainId*/) // TODO(prestonvanloon): reference chain ID from flag
|
signed, err := c.keystore.SignTx(accounts[0], tx, new(big.Int).SetUint64(c.networkID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to sign transaction: %v", err)
|
return nil, fmt.Errorf("unable to sign transaction: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user