Documentation ¶
Index ¶
- Constants
- Variables
- func CompareBeaconIDs(id1, id2 string) bool
- func CurrentRound(now int64, period time.Duration, genesis int64) uint64
- func GetCanonicalBeaconID(id string) string
- func IsDefaultBeaconID(beaconID string) bool
- func NextRound(now int64, period time.Duration, genesis int64) (nextRound uint64, nextTime int64)
- func TimeOfRound(period time.Duration, genesis int64, round uint64) int64
- type Beacon
- func (b *Beacon) Equal(b2 *Beacon) bool
- func (b *Beacon) GetPreviousSignature() []byte
- func (b *Beacon) GetRandomness() []byte
- func (b *Beacon) GetRound() uint64
- func (b *Beacon) GetSignature() []byte
- func (b *Beacon) Marshal() ([]byte, error)
- func (b *Beacon) Randomness() []byte
- func (b *Beacon) String() string
- func (b *Beacon) Unmarshal(buff []byte) error
- type HexBytes
- type Version
Constants ¶
const DefaultBeaconID = "default"
DefaultBeaconID is the value used when beacon id has an empty value. This value should not be changed for backward-compatibility reasons
const DefaultChainHash = "default"
DefaultChainHash is the value used when chain hash has an empty value on requests from clients. This value should not be changed for backward-compatibility reasons
const LogsToSkip = 300
LogsToSkip is used to reduce log verbosity when doing bulk processes, issuing logs only every LogsToSkip steps this is currently set so that when processing past beacons it will give a log every ~2 seconds
const MultiBeaconFolder = "multibeacon"
MultiBeaconFolder is the name of the folder where the multi-beacon data is stored
const TimeOfRoundErrorValue = math.MaxInt64 - maxTimeBuffer
TimeOfRoundErrorValue is the value returned by `TimeOfRound` when an invalid round is specified.
Variables ¶
var ( COMMIT = "" BUILDDATE = "" )
Set via -ldflags. Example:
go install -ldflags "-X common.BUILDDATE=`date -u +%d/%m/%Y@%H:%M:%S` -X common.GITCOMMIT=`git rev-parse HEAD`
See the Makefile and the Dockerfile in the root directory of the repo
var ErrEmptyClientUnsupportedGet = errors.New("not supported")
var ErrInvalidChainHash = errors.New("incorrect chain hash")
ErrInvalidChainHash means there was an error or a mismatch with the chain hash
var ErrNotPartOfGroup = errors.New("this node is not part of the group")
ErrNotPartOfGroup indicates that this node is not part of the group for a specific beacon ID
var ErrPeerNotFound = errors.New("peer not found")
ErrPeerNotFound indicates that a peer is not part of any group that this node knows of
Functions ¶
func CompareBeaconIDs ¶
CompareBeaconIDs indicates if two different beacon ids are equivalent or not. It handles default values too.
func CurrentRound ¶
CurrentRound calculates the active round at `now`
func GetCanonicalBeaconID ¶
GetCanonicalBeaconID returns the correct beacon id.
func IsDefaultBeaconID ¶
IsDefaultBeaconID indicates if the beacon id received is the default one or not. There is a direct relationship between an empty string and the reserved id "default". Internally, empty string is translated to "default" so we can create the beacon folder with a valid name.
Types ¶
type Beacon ¶
type Beacon struct { // PreviousSig is the previous signature generated PreviousSig HexBytes `json:"previous_signature,omitempty"` // Round is the round number this beacon is tied to Round uint64 `json:"round"` // Signature is the BLS deterministic signature as per the crypto.Scheme used Signature HexBytes `json:"signature"` }
Beacon holds the randomness as well as the info to verify it.
func (*Beacon) GetPreviousSignature ¶
GetPreviousSignature returns the previous signature if it's non-nil or nil otherwise
func (*Beacon) GetRandomness ¶
func (*Beacon) GetSignature ¶
GetSignature returns the signature if it's non-nil or nil otherwise
func (*Beacon) Marshal ¶
Marshal provides a JSON encoding of a beacon. Careful, this is not the one rendered by the public endpoints.
func (*Beacon) Randomness ¶
Randomness returns the hashed signature. The choice of the hash determines the size of the output.
type HexBytes ¶
type HexBytes []byte
HexBytes ensures that JSON marshallers marshal to hex rather than base64 to keep compatibility with old store formats
func (*HexBytes) MarshalJSON ¶
func (*HexBytes) UnmarshalJSON ¶
UnmarshalJSON converts a hexadecimal string from JSON to a byte slice
type Version ¶
func GetAppVersion ¶
func GetAppVersion() Version
func (Version) IsCompatible ¶
func (Version) ToProto ¶
func (v Version) ToProto() *pbcommon.NodeVersion