github.com/prysmaticlabs/prysm@v1.4.4/slasher/db/types/types.go (about)

     1  // Package types includes important database-related types for
     2  // slasher-specific logic.
     3  package types
     4  
     5  // SlashingStatus enum like structure.
     6  type SlashingStatus uint8
     7  
     8  //noinspection GoUnusedConst
     9  const (
    10  	// Unknown default status in case it is not set
    11  	Unknown = iota
    12  	// Active slashing proof hasn't been included yet.
    13  	Active
    14  	// Included slashing proof that has been included in a block.
    15  	Included
    16  	// Reverted slashing proof that has been reverted and therefore is relevant again.
    17  	Reverted //relevant again
    18  )
    19  
    20  const (
    21  	// UseCache is used to mark when calling a DB function, to save it to the cache.
    22  	UseCache = true
    23  	// UseDB is used to mark when calling a DB function, to save it to the DB.
    24  	UseDB = false
    25  )
    26  
    27  func (s SlashingStatus) String() string {
    28  	names := [...]string{
    29  		"Unknown",
    30  		"Active",
    31  		"Included",
    32  		"Reverted"}
    33  
    34  	if s < Active || s > Reverted {
    35  		return "Unknown"
    36  	}
    37  	// return the name of a SlashingStatus
    38  	// constant from the names array
    39  	// above.
    40  	return names[s]
    41  }
    42  
    43  // SlashingType enum like type of slashing proof.
    44  type SlashingType uint8
    45  
    46  const (
    47  	// Proposal enum value.
    48  	Proposal = iota
    49  	// Attestation enum value.
    50  	Attestation
    51  )
    52  
    53  // String returns the string representation of the status SlashingType.
    54  func (t SlashingType) String() string {
    55  	names := [...]string{
    56  		"Proposal",
    57  		"Attestation",
    58  	}
    59  
    60  	if t < Active || t > Reverted {
    61  		return "Unknown"
    62  	}
    63  	return names[t]
    64  }