mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-10-14 00:59:33 +00:00
Disconnect from RPC client after finishing the simple sync test (#1641)
This commit is contained in:
parent
2854d91688
commit
088e2114c2
@ -49,6 +49,7 @@ func realMain() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "error connecting to RPC server")
|
return errors.Wrap(err, "error connecting to RPC server")
|
||||||
}
|
}
|
||||||
|
defer syncerRPCClient.Disconnect()
|
||||||
|
|
||||||
syncedRPCClient, err := rpc.ConnectToRPC(&rpc.Config{
|
syncedRPCClient, err := rpc.ConnectToRPC(&rpc.Config{
|
||||||
RPCServer: syncedRPCAddress,
|
RPCServer: syncedRPCAddress,
|
||||||
@ -56,6 +57,7 @@ func realMain() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "error connecting to RPC server")
|
return errors.Wrap(err, "error connecting to RPC server")
|
||||||
}
|
}
|
||||||
|
defer syncedRPCClient.Disconnect()
|
||||||
|
|
||||||
err = syncedRPCClient.RegisterForBlockAddedNotifications()
|
err = syncedRPCClient.RegisterForBlockAddedNotifications()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -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)
|
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()
|
syncerBlockCountAfter, err := syncerRPCClient.GetBlockCount()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Infof("Getting syncee block count")
|
||||||
syncedBlockCountAfter, err := syncedRPCClient.GetBlockCount()
|
syncedBlockCountAfter, err := syncedRPCClient.GetBlockCount()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -70,6 +76,8 @@ func mineLoop(syncerRPCClient, syncedRPCClient *rpc.Client) error {
|
|||||||
if syncedBlockCountAfter.BlockCount-syncedBlockCountBefore.BlockCount != activeConfig().NumberOfBlocks {
|
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)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user