Quick fixes (#141)

Sharding:

* Sharding: add actor flag to sharding group for app help

* Sharding: ensure rpcClient is not nil before calling Close()

* Sharding: revert shardingcmd.go comments

* Sharding: more address Str() fixes

Former-commit-id: 0b3d8b73ac1b20eb5c018a71be1d935a1fb860ef [formerly 6cd1df472713e95f6b9f8a0a7b6bbd88a5dd2ca2]
Former-commit-id: 90c7e1a70d46c1f889576a7f2f253a02414c3654
This commit is contained in:
Preston Van Loon 2018-05-28 20:32:10 -04:00 committed by GitHub
parent 25eb11f30e
commit 689800d065
3 changed files with 8 additions and 4 deletions

View File

@ -86,6 +86,7 @@ var AppHelpFlagGroups = []flagGroup{
{
Name: "SHARDING",
Flags: []cli.Flag{
utils.ActorFlag,
utils.DepositFlag,
},
},

View File

@ -162,7 +162,10 @@ func (n *shardingNode) Register(constructor sharding.ServiceConstructor) error {
// Close the RPC client connection.
func (n *shardingNode) Close() {
n.rpcClient.Close()
// rpcClient could be nil if the connection failed.
if n.rpcClient != nil {
n.rpcClient.Close()
}
}
// CreateTXOpts creates a *TransactOpts with a signer using the default account on the keystore.

View File

@ -26,14 +26,14 @@ func dialRPC(endpoint string) (*rpc.Client, error) {
func initSMC(n *shardingNode) (*contracts.SMC, error) {
b, err := n.client.CodeAt(context.Background(), sharding.ShardingManagerAddress, nil)
if err != nil {
return nil, fmt.Errorf("unable to get contract code at %s: %v", sharding.ShardingManagerAddress, err)
return nil, fmt.Errorf("unable to get contract code at %s: %v", sharding.ShardingManagerAddress.Str(), err)
}
// Deploy SMC for development only.
// TODO: Separate contract deployment from the sharding node. It would only need to be deployed
// once on the mainnet, so this code would not need to ship with the node.
if len(b) == 0 {
log.Info(fmt.Sprintf("No sharding manager contract found at %s. Deploying new contract.", sharding.ShardingManagerAddress))
log.Info(fmt.Sprintf("No sharding manager contract found at %s. Deploying new contract.", sharding.ShardingManagerAddress.Str()))
txOps, err := n.CreateTXOpts(big.NewInt(0))
if err != nil {
@ -52,7 +52,7 @@ func initSMC(n *shardingNode) (*contracts.SMC, error) {
time.Sleep(1 * time.Second)
}
log.Info(fmt.Sprintf("New contract deployed at %s", addr))
log.Info(fmt.Sprintf("New contract deployed at %s", addr.Str()))
return contract, nil
}