Documentation ¶
Index ¶
- Constants
- func FmtBitsetEntry(s uint8) string
- func LessByID(vNodeID, oNodeID node.ShortNodeID) bool
- func SortingPowerRole(role PrimaryRole, pw Power, mode OpMode) uint16
- type BitsetEntry
- type FullRank
- type Index
- type InterimRank
- type OpMode
- func (v OpMode) AsUnit32() uint32
- func (v OpMode) CanHaveState() bool
- func (v OpMode) CanIntroduceJoiner(isJoiner bool) bool
- func (v OpMode) CanVote() bool
- func (v OpMode) IsClean() bool
- func (v OpMode) IsEvicted() bool
- func (v OpMode) IsEvictedForcefully() bool
- func (v OpMode) IsEvictedGracefully() bool
- func (v OpMode) IsJustJoined() bool
- func (v OpMode) IsMistrustful() bool
- func (v OpMode) IsPowerless() bool
- func (v OpMode) IsRestricted() bool
- func (v OpMode) IsSuspended() bool
- func (v OpMode) String() string
- type Power
- type PowerSet
- func (v PowerSet) AsUint32() uint32
- func (v PowerSet) FindNearestValid(p Power) Power
- func (v PowerSet) ForLevel(lvl capacity.Level) Power
- func (v PowerSet) ForLevelWithPercents(lvl capacity.Level, pMinimal, pReduced, pNormal int) Power
- func (v PowerSet) IsAllowed(p Power) bool
- func (v PowerSet) IsEmpty() bool
- func (v PowerSet) IsValid() bool
- func (v PowerSet) Max() Power
- func (v PowerSet) Min() Power
- func (v PowerSet) Normalize() PowerSet
- type PrimaryRole
- type Rank
- type RankCursor
- type SortingRank
- type SpecialRole
- type StateBitset
- type TrustLevel
Constants ¶
View Source
const ( ModeBits = 4 ModeFlagRestrictedBehavior OpMode = 4 ModeFlagValidationWarning OpMode = 2 ModeFlagSuspendedOps OpMode = 1 ModeNormal OpMode = 0 ModeSuspected = ModeFlagSuspendedOps ModePossibleFraud = ModeFlagValidationWarning ModePossibleFraudAndSuspected = ModeFlagSuspendedOps | ModeFlagValidationWarning ModeRestrictedAnnouncement = ModeFlagRestrictedBehavior ModeEvictedGracefully = ModeFlagRestrictedBehavior | ModeFlagSuspendedOps ModeEvictedAsFraud = ModeFlagRestrictedBehavior | ModeFlagValidationWarning ModeEvictedAsSuspected = ModeFlagRestrictedBehavior | ModeFlagValidationWarning | ModeFlagSuspendedOps )
View Source
const MaxBitsetEntry = int(maxBitsetEntry)
View Source
const MaxLinearMemberPower = (0x1F+32)<<(0xFF>>5) - 32
View Source
const MaxNodeIndex = NodeIndexMask
View Source
const NodeIndexBits = 10 // DO NOT change it, otherwise nasty consequences will come
View Source
const NodeIndexMask = 1<<NodeIndexBits - 1
Variables ¶
This section is empty.
Functions ¶
func FmtBitsetEntry ¶
func SortingPowerRole ¶
func SortingPowerRole(role PrimaryRole, pw Power, mode OpMode) uint16
Types ¶
type BitsetEntry ¶
type BitsetEntry uint8
const ( BeHighTrust BitsetEntry = iota BeLimitedTrust BeBaselineTrust BeTimeout BeFraud )
func (BitsetEntry) IsFraud ¶
func (s BitsetEntry) IsFraud() bool
func (BitsetEntry) IsTimeout ¶
func (s BitsetEntry) IsTimeout() bool
func (BitsetEntry) IsTrusted ¶
func (s BitsetEntry) IsTrusted() bool
func (BitsetEntry) String ¶
func (s BitsetEntry) String() string
type FullRank ¶
type FullRank struct { InterimRank RoleCount uint16 RolePower uint32 }
func (FullRank) AsMembershipRank ¶
type InterimRank ¶
type InterimRank struct { RankCursor SpecialRoles SpecialRole Power Power OpMode OpMode }
type OpMode ¶
type OpMode uint8 // 4-bit value
func (OpMode) CanHaveState ¶
func (OpMode) CanIntroduceJoiner ¶
func (OpMode) IsEvictedForcefully ¶
func (OpMode) IsEvictedGracefully ¶
func (OpMode) IsJustJoined ¶
func (OpMode) IsMistrustful ¶
func (OpMode) IsPowerless ¶
func (OpMode) IsRestricted ¶
func (OpMode) IsSuspended ¶
type PowerSet ¶
type PowerSet [4]Power
func PowerSetOf ¶
func (PowerSet) FindNearestValid ¶
func (PowerSet) ForLevelWithPercents ¶
type PrimaryRole ¶
type PrimaryRole uint8 // MUST BE 6-bit
const ( PrimaryRoleInactive PrimaryRole = iota PrimaryRoleNeutral PrimaryRoleHeavyMaterial PrimaryRoleLightMaterial PrimaryRoleVirtual // PrimaryRoleCascade // PrimaryRoleRecrypt PrimaryRoleCount = iota PrimaryRoleUnknown = PrimaryRoleInactive )
func GetPrimaryRoleFromString ¶
func GetPrimaryRoleFromString(role string) PrimaryRole
GetPrimaryRoleFromString converts role from string to PrimaryRole.
func (PrimaryRole) Equal ¶
func (v PrimaryRole) Equal(other PrimaryRole) bool
func (PrimaryRole) IsHeavyMaterial ¶
func (v PrimaryRole) IsHeavyMaterial() bool
func (PrimaryRole) IsLightMaterial ¶
func (v PrimaryRole) IsLightMaterial() bool
func (PrimaryRole) IsMaterial ¶
func (v PrimaryRole) IsMaterial() bool
func (PrimaryRole) IsNeutral ¶
func (v PrimaryRole) IsNeutral() bool
func (PrimaryRole) IsVirtual ¶
func (v PrimaryRole) IsVirtual() bool
func (PrimaryRole) String ¶
func (v PrimaryRole) String() string
type RankCursor ¶
type RankCursor struct { Role PrimaryRole RoleIndex Index RolePowerIndex uint32 TotalIndex Index }
type SortingRank ¶
type SortingRank struct {
// contains filtered or unexported fields
}
func NewSortingRank ¶
func NewSortingRank(nodeID node.ShortNodeID, role PrimaryRole, pw Power, mode OpMode) SortingRank
func (SortingRank) GetNodeID ¶
func (v SortingRank) GetNodeID() node.ShortNodeID
func (SortingRank) GetPower ¶
func (v SortingRank) GetPower() Power
func (SortingRank) GetWorkingRole ¶
func (v SortingRank) GetWorkingRole() PrimaryRole
func (SortingRank) IsWorking ¶
func (v SortingRank) IsWorking() bool
type SpecialRole ¶
type SpecialRole uint8
const ( SpecialRoleNone SpecialRole = 0 SpecialRoleDiscovery SpecialRole = 1 << iota )
func (SpecialRole) Equal ¶
func (v SpecialRole) Equal(other SpecialRole) bool
func (SpecialRole) IsDiscovery ¶
func (v SpecialRole) IsDiscovery() bool
type StateBitset ¶
type StateBitset []BitsetEntry
func (StateBitset) Len ¶
func (b StateBitset) Len() int
type TrustLevel ¶
type TrustLevel int8
const ( FraudByBlacklist TrustLevel = -5 // in the blacklist FraudByNetwork TrustLevel = -4 // >2/3 of network have indicated fraud FraudByNeighbors TrustLevel = -3 // >50% of neighborhood have indicated fraud FraudBySome TrustLevel = -2 // some nodes have indicated fraud UnknownTrust TrustLevel = 0 // initial state TrustBySelf TrustLevel = 1 // node has provided a liveness proof or NSH TrustBySome TrustLevel = 2 // some nodes have indicated trust (same NSH) TrustByNeighbors TrustLevel = 3 // >50% of neighborhood have indicated trust TrustByNetwork TrustLevel = 4 // >2/3 of network have indicated trust TrustByMandate TrustLevel = 5 // on- or off-network node with a temporary mandate, e.g. pulsar or discovery TrustByCouncil TrustLevel = 6 // on- or off-network node with a permanent mandate LocalSelfTrust = TrustByNeighbors // MUST be not less than TrustByNeighbors FraudByThisNode = FraudByNeighbors // fraud is detected by this node )
func UnwrapTrustRange ¶
func UnwrapTrustRange(wrapped uint16) (lo, hi TrustLevel)
func (*TrustLevel) IsNegative ¶
func (v *TrustLevel) IsNegative() bool
func (*TrustLevel) Update ¶
func (v *TrustLevel) Update(newLevel TrustLevel) (modified bool)
Updates only to better/worse levels. Negative level of the same magnitude prevails.
func (*TrustLevel) UpdateKeepNegative ¶
func (v *TrustLevel) UpdateKeepNegative(newLevel TrustLevel) (modified bool)
func (TrustLevel) WrapRange ¶
func (v TrustLevel) WrapRange(hi TrustLevel) uint16
Click to show internal directories.
Click to hide internal directories.