Skip to content

Commit 710a880

Browse files
author
Jayash Satolia
committed
Infinite register validator
1 parent 5358f9c commit 710a880

File tree

1 file changed

+7
-10
lines changed
  • code/go/0chain.net/validator

1 file changed

+7
-10
lines changed

code/go/0chain.net/validator/main.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,11 @@ func main() {
148148

149149
chain.SetServerChain(serverChain)
150150

151-
if err := SetupValidatorOnBC(*logDir); err != nil {
152-
Logger.Info("error setting up validator on blockchain", zap.Any("err", err))
153-
}
151+
go func() {
152+
if err := SetupValidatorOnBC(*logDir); err != nil {
153+
Logger.Info("error setting up validator on blockchain", zap.Any("err", err))
154+
}
155+
}()
154156

155157
fmt.Printf("[+] %-24s %s\n", "register on chain", "[OK]")
156158

@@ -191,9 +193,6 @@ func main() {
191193
}
192194

193195
func RegisterValidator() {
194-
registrationRetries := 0
195-
//ctx := badgerdbstore.GetStorageProvider().WithConnection(common.GetRootContext())
196-
197196
_, err := sdk.GetValidator(node.Self.ID)
198197

199198
if err == nil {
@@ -202,11 +201,10 @@ func RegisterValidator() {
202201
return
203202
}
204203

205-
for registrationRetries < 10 {
204+
for {
206205
txn, err := storage.GetProtocolImpl().RegisterValidator(common.GetRootContext())
207206
if err != nil {
208207
Logger.Error("Error registering validator", zap.Any("err", err))
209-
registrationRetries++
210208
continue
211209
}
212210
time.Sleep(transaction.SLEEP_FOR_TXN_CONFIRMATION * time.Second)
@@ -226,7 +224,6 @@ func RegisterValidator() {
226224
if !txnVerified {
227225
Logger.Error("Add validator transaction could not be verified", zap.Any("err", err), zap.String("txn.Hash", txn.Hash))
228226
}
229-
registrationRetries++
230227
}
231228

232229
}
@@ -291,4 +288,4 @@ func readKeysFromFile(keysFile *string) error {
291288
defer reader.Close()
292289
publicKey, privateKey, _, _ = encryption.ReadKeys(reader)
293290
return nil
294-
}
291+
}

0 commit comments

Comments
 (0)