Disconnect from RPC client after finishing the simple sync test (#1641)

This commit is contained in:
Ori Newman 2021-03-31 13:44:42 +03:00 committed by GitHub
parent 2854d91688
commit 088e2114c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -49,6 +49,7 @@ func realMain() error {
if err != nil {
return errors.Wrap(err, "error connecting to RPC server")
}
defer syncerRPCClient.Disconnect()
syncedRPCClient, err := rpc.ConnectToRPC(&rpc.Config{
RPCServer: syncedRPCAddress,
@ -56,6 +57,7 @@ func realMain() error {
if err != nil {
return errors.Wrap(err, "error connecting to RPC server")
}
defer syncedRPCClient.Disconnect()
err = syncedRPCClient.RegisterForBlockAddedNotifications()
if err != nil {

View File

@ -56,10 +56,16 @@ func mineLoop(syncerRPCClient, syncedRPCClient *rpc.Client) error {
return errors.Errorf("syncer node has tips %s but synced node has tips %s", syncerResult.TipHashes, syncedResult.TipHashes)
}
}
log.Infof("Finished to mine")
log.Infof("Getting syncer block count")
syncerBlockCountAfter, err := syncerRPCClient.GetBlockCount()
if err != nil {
return err
}
log.Infof("Getting syncee block count")
syncedBlockCountAfter, err := syncedRPCClient.GetBlockCount()
if err != nil {
return err
@ -70,6 +76,8 @@ func mineLoop(syncerRPCClient, syncedRPCClient *rpc.Client) error {
if syncedBlockCountAfter.BlockCount-syncedBlockCountBefore.BlockCount != activeConfig().NumberOfBlocks {
return errors.Errorf("Expected syncer to have %d new blocks, instead have: %d", activeConfig().NumberOfBlocks, syncedBlockCountAfter.BlockCount-syncedBlockCountBefore.BlockCount)
}
log.Infof("Finished the mine loop successfully")
return nil
}