示例#1
0
 private static bool NoteIsHealthy(IIotaNodeRepository node)
 {
     try
     {
         var nodeInfo = node.GetNodeInfo();
         return(nodeInfo.LatestMilestoneIndex == nodeInfo.LatestSolidSubtangleMilestoneIndex);
     }
     catch
     {
         return(false);
     }
 }
示例#2
0
        /// <summary>
        /// The node is healthy.
        /// </summary>
        /// <param name="node">
        /// The node.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public static bool NodeIsHealthy(IIotaNodeRepository node)
        {
            try
            {
                // Timeout after 5 seconds
                var task = Task.Run(() => node.GetNodeInfo());
                if (task.Wait(TimeSpan.FromSeconds(WaitSeconds)))
                {
                    var nodeInfo = task.Result;
                    return(nodeInfo.LatestMilestoneIndex == nodeInfo.LatestSolidSubtangleMilestoneIndex);
                }
            }
            catch
            {
                // ignored
            }

            return(false);
        }