@@ -93,38 +93,31 @@ func (vcm *validatorCommitterManager) run(ctx context.Context) error {
9393 return nil
9494 })
9595
96- commonDial , dialErr := connection .NewLoadBalancedDialConfig (* c .clientConfig )
97- if dialErr != nil {
98- return fmt .Errorf ("failed to create connection to validator persisters: %w" , dialErr )
99- }
100- commonConn , err := connection .Connect (commonDial )
96+ commonConn , err := connection .NewLoadBalancedConnection (c .clientConfig )
10197 if err != nil {
10298 return fmt .Errorf ("failed to create connection to validator persisters: %w" , err )
10399 }
100+ defer connection .CloseConnectionsLog (commonConn )
104101 vcm .commonClient = protovcservice .NewValidationAndCommitServiceClient (commonConn )
105102 _ , setupErr := vcm .commonClient .SetupSystemTablesAndNamespaces (ctx , nil )
106103 if setupErr != nil {
107104 return errors .Wrap (setupErr , "failed to setup system tables and namespaces" )
108105 }
109106
110- dialConfigs , dialErr := connection .NewDialConfigPerEndpoint (c .clientConfig )
111- if dialErr != nil {
112- return dialErr
107+ connections , connErr := connection .NewConnectionPerEndpoint (c .clientConfig )
108+ if connErr != nil {
109+ return fmt . Errorf ( "failed to create connection to validator persister: %w" , connErr )
113110 }
114- for i , d := range dialConfigs {
115- logger .Debugf ("vc manager creates client to vc [%d] listening on %s" , i , d .Address )
116- conn , connErr := connection .Connect (d )
117- if connErr != nil {
118- return fmt .Errorf ("failed to create connection to validator persister running at %s" , d .Address )
119- }
120- logger .Infof ("validator persister manager connected to validator persister at %s" , d .Address )
121- vc := newValidatorCommitter (conn , c .metrics , c .policyMgr )
111+ defer connection .CloseConnectionsLog (connections ... )
112+ for i , conn := range connections {
113+ label := conn .CanonicalTarget ()
114+ c .metrics .vcservicesConnection .Disconnected (label )
122115
123- logger . Debugf ( "Client [%d] successfully created and connected to vc" , i )
116+ vc := newValidatorCommitter ( conn , c . metrics , c . policyMgr )
124117 vcm .validatorCommitter [i ] = vc
118+ logger .Infof ("Client [%d] successfully created and connected to vc at %s" , i , label )
125119
126120 g .Go (func () error {
127- defer connection .CloseConnectionsLog (vc .conn )
128121 return connection .Sustain (eCtx , func () (err error ) {
129122 defer vc .recoverPendingTransactions (txBatchQueue )
130123 return vc .sendTransactionsAndForwardStatus (
@@ -198,12 +191,9 @@ func (vcm *validatorCommitterManager) recoverPolicyManagerFromStateDB(ctx contex
198191}
199192
200193func newValidatorCommitter (conn * grpc.ClientConn , metrics * perfMetrics , policyMgr * policyManager ) * validatorCommitter {
201- label := conn .CanonicalTarget ()
202- metrics .vcservicesConnection .Disconnected (label )
203- client := protovcservice .NewValidationAndCommitServiceClient (conn )
204194 return & validatorCommitter {
205195 conn : conn ,
206- client : client ,
196+ client : protovcservice . NewValidationAndCommitServiceClient ( conn ) ,
207197 metrics : metrics ,
208198 policyMgr : policyMgr ,
209199 }
0 commit comments