agendas

package
v2.0.0-...-c90cce5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2019 License: ISC Imports: 10 Imported by: 0

Documentation

Overview

Package agendas manages the various deployment agendas that are directly voted upon with the vote bits in vote transactions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info.

Types

type AgendaDB

type AgendaDB struct {
	NumAgendas int
	// contains filtered or unexported fields
}

AgendaDB represents the data for the stored DB.

func NewAgendasDB

func NewAgendasDB(client DeploymentSource, dbPath string) (*AgendaDB, error)

NewAgendasDB opens an existing database or create a new one using with the specified file name. An initialized agendas db connection is returned. It also checks the db version, Reindexes the db if need be and sets the required db version.

func (*AgendaDB) AgendaInfo

func (db *AgendaDB) AgendaInfo(agendaID string) (*AgendaTagged, error)

AgendaInfo fetches an agenda's details given it's agendaID.

func (*AgendaDB) AllAgendas

func (db *AgendaDB) AllAgendas() (agendas []*AgendaTagged, err error)

AllAgendas returns all agendas and their info in the db.

func (*AgendaDB) CheckAgendasUpdates

func (db *AgendaDB) CheckAgendasUpdates(activeVersions map[uint32][]chaincfg.ConsensusDeployment) error

CheckAgendasUpdates checks for update at the start of the process and will proceed to update when necessary.

func (*AgendaDB) Close

func (db *AgendaDB) Close() error

Close should be called when you are done with the AgendaDB to close the underlying database.

type AgendaSummary

type AgendaSummary struct {
	Description     string  `json:"description"`
	ID              string  `json:"id"`
	Quorum          uint32  `json:"quorum"`
	QuorumProgress  float32 `json:"quorum_progress"`
	QuorumAchieved  bool    `json:"quorum_achieved"`
	Aye             uint32  `json:"aye"`
	Nay             uint32  `json:"nay"`
	Abstain         uint32  `json:"abstain"`
	AbstainRate     float32 `json:"abstain_rate"`
	VoteCount       uint32  `json:"vote_count"` // non-abstaining
	PassThreshold   float32 `json:"pass_threshold"`
	FailThreshold   float32 `json:"fail_threshold"`
	Approval        float32 `json:"approval"`
	LockCount       uint32  `json:"lock_count"`
	IsWinning       bool    `json:"is_winning"`
	IsLosing        bool    `json:"is_losing"`
	IsVoting        bool    `json:"is_voting"`
	IsDefined       bool    `json:"is_defined"`
	VotingTriggered bool    `json:"voting_triggered"`
	IsLocked        bool    `json:"is_locked"`
	IsFailed        bool    `json:"is_failed"`
	IsActive        bool    `json:"is_active"`
}

AgendaSummary summarizes the current state of voting on a particular agenda.

type AgendaTagged

type AgendaTagged struct {
	ID             string                   `json:"id" storm:"id"`
	Description    string                   `json:"description"`
	Mask           uint16                   `json:"mask"`
	StartTime      uint64                   `json:"starttime" storm:"index"`
	ExpireTime     uint64                   `json:"expiretime" storm:"index"`
	Status         dbtypes.AgendaStatusType `json:"status" storm:"index"`
	QuorumProgress float64                  `json:"quorumprogress" storm:"index"`
	Choices        []chainjson.Choice       `json:"choices"`
	VoteVersion    uint32                   `json:"voteversion"`
}

AgendaTagged has the same fields as chainjson.Agenda plus the VoteVersion field, but with the ID field marked as the primary key via the `storm:"id"` tag. Fields tagged for indexing by the DB are: StartTime, ExpireTime, Status, and QuorumProgress.

type DeploymentSource

type DeploymentSource interface {
	GetVoteInfo(version uint32) (*chainjson.GetVoteInfoResult, error)
}

DeploymentSource provides a cleaner way to track the rpcclient methods used in this package. It also allows usage of alternative implementations to satisfy the interface.

type VoteDataSource

type VoteDataSource interface {
	GetStakeVersionInfo(int32) (*chainjson.GetStakeVersionInfoResult, error)
	GetVoteInfo(uint32) (*chainjson.GetVoteInfoResult, error)
	GetStakeVersions(string, int32) (*chainjson.GetStakeVersionsResult, error)
}

VoteDataSource is satisfied by rpcclient.Client.

type VoteSummary

type VoteSummary struct {
	Version         uint32          `json:"version"`
	Height          int64           `json:"height"`
	Hash            string          `json:"hash"`
	VoteVersion     uint32          `json:"vote_version"`
	Agendas         []AgendaSummary `json:"agendas"`
	OldVoters       uint32          `json:"old_voters"`
	NewVoters       uint32          `json:"new_voters"`
	VoterCount      uint32          `json:"voter_count"`
	VoterThreshold  float32         `json:"voter_threshold"`
	VoterProgress   float32         `json:"voter_progress"`
	OldMiners       uint32          `json:"old_miners"`
	NewMiners       uint32          `json:"new_miners"`
	MinerCount      uint32          `json:"miner_count"`
	MinerThreshold  float32         `json:"miner_threshold"`
	MinerProgress   float32         `json:"miner_progress"`
	RCIBlocks       uint32          `json:"rci_blocks"`
	RCIMined        uint32          `json:"rci_mined"`
	RCIProgress     float32         `json:"rci_progress"`
	SVIBlocks       uint32          `json:"svi_blocks"`
	SVIMined        uint32          `json:"svi_mined"`
	SVIProgress     float32         `json:"svi_progress"`
	TilNextRCI      int64           `json:"til_next_rci"`
	NextRCIHeight   uint32          `json:"next_rci_height"`
	NetworkUpgraded bool            `json:"network_upgrading"`
	VotingTriggered bool            `json:"voting_triggered"`
}

VoteSummary summarizes the current state of consensus voting. VoteSummary is the primary exported type produced by VoteTracker.

type VoteTracker

type VoteTracker struct {
	// contains filtered or unexported fields
}

VoteTracker manages the current state of node version data and vote data on the blockchain. VoteTracker refreshes its data when it is signaled by a call to Refresh. A VoteSummary is created and stored for requests with the Summary method.

func NewVoteTracker

func NewVoteTracker(params *chaincfg.Params, node VoteDataSource, counter voteCounter,
	activeVersions map[uint32][]chaincfg.ConsensusDeployment) (*VoteTracker, error)

NewVoteTracker is a constructor for a VoteTracker.

func (*VoteTracker) Refresh

func (tracker *VoteTracker) Refresh()

Refresh refreshes node version and vote data. It can be called as a goroutine. All VoteTracker updating and mutex locking is handled within VoteTracker.update.

func (*VoteTracker) Summary

func (tracker *VoteTracker) Summary() *VoteSummary

Summary is a getter for the cached VoteSummary. The summary returned will never be modified by VoteTracker, so can be used read-only by any number of threads.

func (*VoteTracker) Version

func (tracker *VoteTracker) Version() uint32

Version returns the current best known vote version. Since version could technically be updated without turning off pfcdata, the field must be protected.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL