Skip to content
Snippets Groups Projects
Commit da08c18b authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

rework the closeout of client so that it waits for the network followers to...

rework the closeout of client so that it waits for the network followers to stop and also explicitly wait for the channel confirmations
parent b6704dc8
No related branches found
No related tags found
No related merge requests found
...@@ -65,15 +65,24 @@ var rootCmd = &cobra.Command{ ...@@ -65,15 +65,24 @@ var rootCmd = &cobra.Command{
authMgr.AddGeneralRequestCallback(printChanRequest) authMgr.AddGeneralRequestCallback(printChanRequest)
// If unsafe channels, add auto-acceptor // If unsafe channels, add auto-acceptor
num_channels_confirmed := 0
authMgr.AddGeneralConfirmCallback(func(
partner contact.Contact) {
jww.INFO.Printf("Channel Confirmed: %s",
partner.ID)
num_channels_confirmed++
})
if viper.GetBool("unsafe-channel-creation") { if viper.GetBool("unsafe-channel-creation") {
authMgr.AddGeneralRequestCallback(func( authMgr.AddGeneralRequestCallback(func(
requestor contact.Contact, message string) { requestor contact.Contact, message string) {
jww.INFO.Printf("Got Request: %s", requestor.ID) jww.INFO.Printf("Channel Request: %s",
requestor.ID)
err := client.ConfirmAuthenticatedChannel( err := client.ConfirmAuthenticatedChannel(
requestor) requestor)
if err != nil { if err != nil {
jww.FATAL.Panicf("%+v", err) jww.FATAL.Panicf("%+v", err)
} }
num_channels_confirmed++
}) })
} }
...@@ -169,7 +178,8 @@ var rootCmd = &cobra.Command{ ...@@ -169,7 +178,8 @@ var rootCmd = &cobra.Command{
// TODO: Actually check for how many messages we've received // TODO: Actually check for how many messages we've received
expectedCnt := viper.GetUint("receiveCount") expectedCnt := viper.GetUint("receiveCount")
receiveCnt := uint(0) receiveCnt := uint(0)
waitTimeout := time.Duration(viper.GetUint("waitTimeout")) waitSecs := viper.GetUint("waitTimeout")
waitTimeout := time.Duration(waitSecs)
timeoutTimer := time.NewTimer(waitTimeout * time.Second) timeoutTimer := time.NewTimer(waitTimeout * time.Second)
done := false done := false
for !done && expectedCnt != 0 { for !done && expectedCnt != 0 {
...@@ -190,11 +200,19 @@ var rootCmd = &cobra.Command{ ...@@ -190,11 +200,19 @@ var rootCmd = &cobra.Command{
} }
} }
fmt.Printf("Received %d\n", receiveCnt) fmt.Printf("Received %d\n", receiveCnt)
// client.StopNetworkFollower(1 * time.Second) if receiveCnt == 0 && sendCnt == 0 {
/*if err!=nil{ scnt := uint(0)
fmt.Printf("Failed to cleanly close threads: %+v\n", err) for num_channels_confirmed == 0 && scnt < waitSecs {
}*/ time.Sleep(1 * time.Second)
time.Sleep(10 * time.Second) scnt++
}
}
err = client.StopNetworkFollower(5 * time.Second)
if err != nil {
jww.WARN.Printf(
"Failed to cleanly close threads: %+v\n",
err)
}
}, },
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment