• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bmresearch / Solnet / 15458437619

05 Jun 2025 04:27AM UTC coverage: 66.061% (-4.7%) from 70.792%
15458437619

Pull #497

github

web-flow
Merge da1be547c into 632c6bef2
Pull Request #497: Stakepool program

1161 of 2022 branches covered (57.42%)

Branch coverage included in aggregate %.

705 of 1521 new or added lines in 12 files covered. (46.35%)

5823 of 8550 relevant lines covered (68.11%)

987890.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Solnet.Programs/StakePool/Models/PodStakeStatus.cs
1
using System;
2

3
namespace Solnet.Programs.StakePool.Models
4
{
5
    /// <summary>
6
    /// Wrapper struct that can be used as a Pod, containing a byte that should be a valid StakeStatus underneath.
7
    /// </summary>
8
    public struct PodStakeStatus : IEquatable<PodStakeStatus>
9
    {
10
        public byte Value;
11

12
        /// <summary>
13
        /// Represents the status of a pod's stake as a byte value.
14
        /// </summary>
15
        /// <param name="value">The byte value representing the pod's stake status.</param>
16
        public PodStakeStatus(byte value)
17
        {
NEW
18
            Value = value;
×
NEW
19
        }
×
20

21
        /// <summary>
22
        /// Creates a new instance of <see cref="PodStakeStatus"/> from a <see cref="StakeStatus"/> value.
23
        /// </summary>
24
        /// <param name="status"></param>
25
        /// <returns></returns>
NEW
26
        public static PodStakeStatus FromStakeStatus(StakeStatus status) => new PodStakeStatus((byte)status);
×
27

28
        /// <summary>
29
        /// Converts the current value to a <see cref="StakeStatus"/> enumeration.
30
        /// </summary>
31
        /// <returns>A <see cref="StakeStatus"/> value that corresponds to the current value.</returns>
32
        /// <exception cref="InvalidOperationException">Thrown if the current value does not correspond to a valid <see cref="StakeStatus"/> enumeration value.</exception>
33
        public StakeStatus ToStakeStatus()
34
        {
NEW
35
            if (Enum.IsDefined(typeof(StakeStatus), Value))
×
NEW
36
                return (StakeStatus)Value;
×
NEW
37
            throw new InvalidOperationException("Invalid StakeStatus value.");
×
38
        }
39

40
        /// <summary>
41
        /// Downgrade the status towards ready for removal by removing the validator stake.
42
        /// </summary>
43
        public void RemoveValidatorStake()
44
        {
NEW
45
            var status = ToStakeStatus();
×
NEW
46
            StakeStatus newStatus = status switch
×
NEW
47
            {
×
NEW
48
                StakeStatus.Active or StakeStatus.DeactivatingTransient or StakeStatus.ReadyForRemoval => status,
×
NEW
49
                StakeStatus.DeactivatingAll => StakeStatus.DeactivatingTransient,
×
NEW
50
                StakeStatus.DeactivatingValidator => StakeStatus.ReadyForRemoval,
×
NEW
51
                _ => throw new InvalidOperationException("Invalid StakeStatus value.")
×
NEW
52
            };
×
NEW
53
            Value = (byte)newStatus;
×
NEW
54
        }
×
55

56
        /// <summary>
57
        /// Downgrade the status towards ready for removal by removing the transient stake.
58
        /// </summary>
59
        public void RemoveTransientStake()
60
        {
NEW
61
            var status = ToStakeStatus();
×
NEW
62
            StakeStatus newStatus = status switch
×
NEW
63
            {
×
NEW
64
                StakeStatus.Active or StakeStatus.DeactivatingValidator or StakeStatus.ReadyForRemoval => status,
×
NEW
65
                StakeStatus.DeactivatingAll => StakeStatus.DeactivatingValidator,
×
NEW
66
                StakeStatus.DeactivatingTransient => StakeStatus.ReadyForRemoval,
×
NEW
67
                _ => throw new InvalidOperationException("Invalid StakeStatus value.")
×
NEW
68
            };
×
NEW
69
            Value = (byte)newStatus;
×
NEW
70
        }
×
71

72
        /// <summary>
73
        /// Converts a <see cref="StakeStatus"/> instance to a <see cref="PodStakeStatus"/> instance.
74
        /// </summary>
75
        /// <param name="status">The <see cref="StakeStatus"/> instance to convert.</param>
NEW
76
        public static explicit operator PodStakeStatus(StakeStatus status) => FromStakeStatus(status);
×
77

78
        /// <summary>
79
        /// Converts a <see cref="PodStakeStatus"/> instance to a <see cref="StakeStatus"/> instance.
80
        /// </summary>
81
        /// <param name="pod">The <see cref="PodStakeStatus"/> instance to convert.</param>
82
        public static explicit operator StakeStatus(PodStakeStatus pod)
83
        {
NEW
84
            return pod.ToStakeStatus();
×
85
        }
86

87
        /// <summary>
88
        /// Determines whether the specified object is equal to the current instance.
89
        /// </summary>
90
        /// <param name="obj">The object to compare with the current instance.</param>
91
        /// <returns><see langword="true"/> if the specified object is of type <c>PodStakeStatus</c> and is equal to the current
92
        /// instance; otherwise, <see langword="false"/>.</returns>
NEW
93
        public override bool Equals(object obj) => obj is PodStakeStatus other && Equals(other);
×
94

95
        /// <summary>
96
        /// Determines whether the current instance is equal to another <see cref="PodStakeStatus"/> instance.
97
        /// </summary>
98
        /// <param name="other">The <see cref="PodStakeStatus"/> instance to compare with the current instance.</param>
99
        /// <returns><see langword="true"/> if the <see cref="Value"/> of the current instance is equal to the <see
100
        /// cref="Value"/> of the specified instance; otherwise, <see langword="false"/>.</returns>
NEW
101
        public bool Equals(PodStakeStatus other) => Value == other.Value;
×
102

103
        /// <summary>
104
        /// Returns a hash code for the current object.
105
        /// </summary>
106
        /// <remarks>The hash code is derived from the <see cref="Value"/> property.  It is suitable for
107
        /// use in hashing algorithms and data structures such as hash tables.</remarks>
108
        /// <returns>An integer that represents the hash code for the current object.</returns>
NEW
109
        public override int GetHashCode() => Value.GetHashCode();
×
110

NEW
111
        public static bool operator ==(PodStakeStatus left, PodStakeStatus right) => left.Equals(right);
×
112

NEW
113
        public static bool operator !=(PodStakeStatus left, PodStakeStatus right) => !(left == right);
×
114
    }
115
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc