Skip to content

Commit

Permalink
update var names
Browse files Browse the repository at this point in the history
  • Loading branch information
kc1116 committed Oct 1, 2021
1 parent 2d8b4c2 commit e925198
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions cmd/collection/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func main() {

// epoch qc contract client
machineAccountInfo *bootstrap.NodeMachineAccountInfo
flowClientOpts []*common.FlowClientOpt
flowClientOpts []*common.FlowClientConfig
insecureAccessAPI bool
accessNodeIDS []string
)
Expand Down Expand Up @@ -209,7 +209,7 @@ func main() {
return fmt.Errorf("invalid flag --access-node-ids atleast %d IDs must be provided", common.DefaultAccessNodeIDSMinimum)
}

flowClientOpts, err = common.PrepareFlowClientOpts(accessNodeIDS, insecureAccessAPI, node.State.Sealed())
flowClientOpts, err = common.FlowClientConfigs(accessNodeIDS, insecureAccessAPI, node.State.Sealed())
if err != nil {
return fmt.Errorf("failed to prepare flow client connection options for each access node id %w", err)
}
Expand Down Expand Up @@ -535,7 +535,7 @@ func createQCContractClient(node *cmd.NodeConfig, machineAccountInfo *bootstrap.
}

// createQCContractClients creates priority ordered array of QCContractClient
func createQCContractClients(node *cmd.NodeConfig, machineAccountInfo *bootstrap.NodeMachineAccountInfo, flowClientOpts []*common.FlowClientOpt) ([]module.QCContractClient, error) {
func createQCContractClients(node *cmd.NodeConfig, machineAccountInfo *bootstrap.NodeMachineAccountInfo, flowClientOpts []*common.FlowClientConfig) ([]module.QCContractClient, error) {
qcClients := make([]module.QCContractClient, 0)

for _, opt := range flowClientOpts {
Expand Down
6 changes: 3 additions & 3 deletions cmd/consensus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func main() {

// DKG contract client
machineAccountInfo *bootstrap.NodeMachineAccountInfo
flowClientOpts []*common.FlowClientOpt
flowClientOpts []*common.FlowClientConfig
insecureAccessAPI bool
accessNodeIDS []string

Expand Down Expand Up @@ -370,7 +370,7 @@ func main() {
return fmt.Errorf("invalid flag --access-node-ids atleast %d IDs must be provided", common.DefaultAccessNodeIDSMinimum)
}

flowClientOpts, err = common.PrepareFlowClientOpts(accessNodeIDS, insecureAccessAPI, node.State.Sealed())
flowClientOpts, err = common.FlowClientConfigs(accessNodeIDS, insecureAccessAPI, node.State.Sealed())
if err != nil {
return fmt.Errorf("failed to prepare flow client connection options for each access node id %w", err)
}
Expand Down Expand Up @@ -805,7 +805,7 @@ func createDKGContractClient(node *cmd.NodeConfig, machineAccountInfo *bootstrap
}

// createDKGContractClients creates an array dkgContractClient that is sorted by retry fallback priority
func createDKGContractClients(node *cmd.NodeConfig, machineAccountInfo *bootstrap.NodeMachineAccountInfo, flowClientOpts []*common.FlowClientOpt) ([]module.DKGContractClient, error) {
func createDKGContractClients(node *cmd.NodeConfig, machineAccountInfo *bootstrap.NodeMachineAccountInfo, flowClientOpts []*common.FlowClientConfig) ([]module.DKGContractClient, error) {
dkgClients := make([]module.DKGContractClient, 0)

for _, opt := range flowClientOpts {
Expand Down
30 changes: 15 additions & 15 deletions cmd/util/cmd/common/flow_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ const (
DefaultAccessAPISecurePort = "9001"
)

type FlowClientOpt struct {
type FlowClientConfig struct {
AccessAddress string
AccessNodePubKey string
Insecure bool
}

func (f *FlowClientOpt) String() string {
func (f *FlowClientConfig) String() string {
return fmt.Sprintf("AccessAddress: %s, AccessNodePubKey: %s, Insecure: %v", f.AccessAddress, f.AccessNodePubKey, f.Insecure)
}

// NewFlowClientOpt returns *FlowClientOpt
func NewFlowClientOpt(accessAddress, accessApiNodePubKey string, insecure bool) (*FlowClientOpt, error) {
// NewFlowClientConfig returns *FlowClientConfig
func NewFlowClientConfig(accessAddress, accessApiNodePubKey string, insecure bool) (*FlowClientConfig, error) {
if accessAddress == "" {
return nil, fmt.Errorf("failed to create flow client connection option invalid access address: %s", accessAddress)
}
Expand All @@ -42,11 +42,11 @@ func NewFlowClientOpt(accessAddress, accessApiNodePubKey string, insecure bool)
}
}

return &FlowClientOpt{accessAddress, accessApiNodePubKey, insecure}, nil
return &FlowClientConfig{accessAddress, accessApiNodePubKey, insecure}, nil
}

// FlowClient will return a secure or insecure flow client depending on *FlowClientOpt.Insecure
func FlowClient(opt *FlowClientOpt) (*client.Client, error) {
// FlowClient will return a secure or insecure flow client depending on *FlowClientConfig.Insecure
func FlowClient(opt *FlowClientConfig) (*client.Client, error) {
if opt.Insecure {
return insecureFlowClient(opt.AccessAddress)
}
Expand Down Expand Up @@ -81,9 +81,9 @@ func insecureFlowClient(accessAddress string) (*client.Client, error) {
return flowClient, nil
}

// PrepareFlowClientOpts will assemble connection options for the flow client for each access node id
func PrepareFlowClientOpts(accessNodeIDS []string, insecureAccessAPI bool, snapshot protocol.Snapshot) ([]*FlowClientOpt, error) {
flowClientOpts := make([]*FlowClientOpt, 0)
// FlowClientConfigs will assemble connection options for the flow client for each access node id
func FlowClientConfigs(accessNodeIDS []string, insecureAccessAPI bool, snapshot protocol.Snapshot) ([]*FlowClientConfig, error) {
flowClientOpts := make([]*FlowClientConfig, 0)

// convert all IDS to flow.Identifier type, fail early if ID is invalid
anIDS := make([]flow.Identifier, 0)
Expand All @@ -107,14 +107,14 @@ func PrepareFlowClientOpts(accessNodeIDS []string, insecureAccessAPI bool, snaps
return nil, fmt.Errorf("failed to get identity for all the access node IDs provided: %v, got %v", accessNodeIDS, identities.NodeIDs())
}

// build a FlowClientOpt for each access node identity, these will be used to manage multiple flow client connections
// build a FlowClientConfig for each access node identity, these will be used to manage multiple flow client connections
for i, identity := range identities {
accessAddress := ConvertAccessAddrFromState(identity.Address, insecureAccessAPI)
accessAddress := convertAccessAddrFromState(identity.Address, insecureAccessAPI)

// remove the 0x prefix from network public keys
networkingPubKey := identity.NetworkPubKey.String()[2:]

opt, err := NewFlowClientOpt(accessAddress, networkingPubKey, insecureAccessAPI)
opt, err := NewFlowClientConfig(accessAddress, networkingPubKey, insecureAccessAPI)
if err != nil {
return nil, fmt.Errorf("failed to get flow client connection option for access node ID (%d): %s %w", i, identity, err)
}
Expand All @@ -124,9 +124,9 @@ func PrepareFlowClientOpts(accessNodeIDS []string, insecureAccessAPI bool, snaps
return flowClientOpts, nil
}

// ConvertAccessAddrFromState takes raw network address from the protocol state in the for of [DNS/IP]:PORT, removes the port and applies the appropriate
// convertAccessAddrFromState takes raw network address from the protocol state in the for of [DNS/IP]:PORT, removes the port and applies the appropriate
// port number depending on the insecureAccessAPI arg.
func ConvertAccessAddrFromState(address string, insecureAccessAPI bool) string {
func convertAccessAddrFromState(address string, insecureAccessAPI bool) string {
// remove gossip port from access address and add respective secure or insecure port
var accessAddress strings.Builder
accessAddress.WriteString(strings.Split(address, ":")[0])
Expand Down

0 comments on commit e925198

Please sign in to comment.