cockroachdb

package
v0.0.0-...-db4ab52 Latest Latest
Warning

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

Go to latest
Published: May 15, 2019 License: ISC Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Database users
	UserPoliteiad   = "politeiad"   // politeiad user (read/write access)
	UserPoliteiawww = "politeiawww" // politeiawww user (read access)
)

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func New

func New(user, host, net, rootCert, cert, key string) (*cockroachdb, error)

New returns a new cockroachdb context that contains a connection to the specified database that was made using the passed in user and certificates.

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using slog.

Types

type AuthorizeVote

type AuthorizeVote struct {
	Key       string `gorm:"primary_key"`       // Primary key (token+version)
	Token     string `gorm:"not null;size:64"`  // Censorship token
	Version   uint64 `gorm:"not null"`          // Version of files
	Action    string `gorm:"not null"`          // Authorize or revoke
	Signature string `gorm:"not null;size:128"` // Signature of token+version+action
	PublicKey string `gorm:"not null;size:64"`  // Pubkey used for signature
	Receipt   string `gorm:"not null;size:128"` // Server signature of client signature
	Timestamp int64  `gorm:"not null"`          // Received UNIX timestamp
}

AuthorizeVote is used to indicate that a record has been finalized and is ready to be voted on.

This is a fonero plugin model.

func (AuthorizeVote) TableName

func (AuthorizeVote) TableName() string

TableName returns the name of the AuthorizeVote database table.

type CastVote

type CastVote struct {
	Key       uint   `gorm:"primary_key"`       // Primary key
	Token     string `gorm:"not null;size:64"`  // Censorship token
	Ticket    string `gorm:"not null"`          // Ticket ID
	VoteBit   string `gorm:"not null"`          // Hex encoded vote bit that was selected
	Signature string `gorm:"not null;size:130"` // Signature of Token+Ticket+VoteBit

	// TokenVoteBit is the Token+VoteBit. Indexing TokenVoteBit allows
	// for quick lookups of the number of votes cast for each vote bit.
	TokenVoteBit string `gorm:"no null;index"`
}

CastVote records a signed vote.

This is a fonero plugin model.

func (CastVote) TableName

func (CastVote) TableName() string

TableName returns the name of the CastVote database table.

type Comment

type Comment struct {
	Key       string `gorm:"primary_key"`       // Primary key (token+commentID)
	Token     string `gorm:"not null;size:64"`  // Censorship token
	ParentID  string `gorm:"not null"`          // Parent comment ID
	Comment   string `gorm:"not null"`          // Comment
	Signature string `gorm:"not null;size:128"` // Client Signature of Token+ParentID+Comment
	PublicKey string `gorm:"not null;size:64"`  // Pubkey used for Signature
	CommentID string `gorm:"not null"`          // Comment ID
	Receipt   string `gorm:"not null"`          // Server signature of the client Signature
	Timestamp int64  `gorm:"not null"`          // Received UNIX timestamp
	Censored  bool   `gorm:"not null"`          // Has this comment been censored
}

Comment represents a record comment, including all of the server side metadata.

This is a fonero plugin model.

func (Comment) TableName

func (Comment) TableName() string

TableName returns the name of the Comment database table.

type File

type File struct {
	Key       uint   `gorm:"primary_key"`      // Primary key
	RecordKey string `gorm:"not null"`         // Record foreign key
	Name      string `gorm:"not null"`         // Basename of the file
	MIME      string `gorm:"not null"`         // MIME type
	Digest    string `gorm:"not null;size:64"` // SHA256 of decoded Payload
	Payload   string `gorm:"not null"`         // base64 encoded file
}

File describes an individual file that is part of the record.

func (File) TableName

func (File) TableName() string

TableName returns the name of the File database table.

type LikeComment

type LikeComment struct {
	Key       uint   `gorm:"primary_key"`       // Primary key
	Token     string `gorm:"not null;size:64"`  // Censorship token
	CommentID string `gorm:"not null"`          // Comment ID
	Action    string `gorm:"not null;size:2"`   // Up or downvote (1, -1)
	Signature string `gorm:"not null;size:128"` // Client Signature of Token+CommentID+Action
	PublicKey string `gorm:"not null;size:64"`  // Public key used for Signature
}

LikeComment describes a comment upvote/downvote. The server side metadata is not included.

This is a fonero plugin model.

func (LikeComment) TableName

func (LikeComment) TableName() string

TableName returns the name of the LikeComment database table.

type MetadataStream

type MetadataStream struct {
	Key       uint   `gorm:"primary_key"` // Primary key
	RecordKey string `gorm:"not null"`    // Record foreign key
	ID        uint64 `gorm:"not null"`    // Stream identity
	Payload   string `gorm:"not null"`    // String encoded metadata
}

MetadataStream identifies a metadata stream by its identity.

func (MetadataStream) TableName

func (MetadataStream) TableName() string

TableName returns the name of the MetadataStream database table.

type Record

type Record struct {
	Key       string `gorm:"primary_key"`       // Primary key (token+version)
	Token     string `gorm:"not null;size:64"`  // Censorship token
	Version   uint64 `gorm:"not null"`          // Version of files
	Status    int    `gorm:"not null"`          // Current status
	Timestamp int64  `gorm:"not null"`          // UNIX timestamp of last updated
	Merkle    string `gorm:"not null;size:64"`  // Merkle root of all files in record
	Signature string `gorm:"not null;size:128"` // Server signature of merkle+token

	Metadata []MetadataStream `gorm:"foreignkey:RecordKey"` // User provided metadata
	Files    []File           `gorm:"foreignkey:RecordKey"` // User provided files
}

Record is an entire record and it's content.

func (Record) TableName

func (Record) TableName() string

TableName returns the name of the Record database table.

type StartVote

type StartVote struct {
	Token               string       `gorm:"primary_key;size:64"` // Censorship token
	Version             uint64       `gorm:"not null"`            // Version of files
	Mask                uint64       `gorm:"not null"`            // Valid votebits
	Duration            uint32       `gorm:"not null"`            // Duration in blocks
	QuorumPercentage    uint32       `gorm:"not null"`            // Percent of eligible votes required for quorum
	PassPercentage      uint32       `gorm:"not null"`            // Percent of total votes required to pass
	Options             []VoteOption `gorm:"foreignkey:Token"`    // Vote option
	PublicKey           string       `gorm:"not null;size:64"`    // Key used for signature
	Signature           string       `gorm:"not null;size:128"`   // Signature of Votehash
	StartBlockHeight    string       `gorm:"not null"`            // Block height
	StartBlockHash      string       `gorm:"not null"`            // Block hash
	EndHeight           uint64       `gorm:"not null"`            // Height of vote end
	EligibleTickets     string       `gorm:"not null"`            // Valid voting tickets
	EligibleTicketCount int          `gorm:"not null"`            // Number of eligible tickets
}

StartVote records the details of a proposal vote.

This is a fonero plugin model.

func (StartVote) TableName

func (StartVote) TableName() string

TableName returns the name of the StartVote database table.

type Version

type Version struct {
	ID        string `gorm:"primary_key"` // Primary key
	Version   string `gorm:"not null"`    // Version
	Timestamp int64  `gorm:"not null"`    // UNIX timestamp of record creation
}

Version describes the version of a record or plugin that the database is currently using.

func (Version) TableName

func (Version) TableName() string

TableName returns the name of the Version database table.

type VoteOption

type VoteOption struct {
	Key         uint   `gorm:"primary_key"`      // Primary key
	Token       string `gorm:"not null;size:64"` // StartVote foreign key
	ID          string `gorm:"not null"`         // Single unique word identifying vote (e.g. yes)
	Description string `gorm:"not null"`         // Longer description of the vote
	Bits        uint64 `gorm:"not null"`         // Bits used for this option
}

VoteOption describes a single vote option.

This is a fonero plugin model.

func (VoteOption) TableName

func (VoteOption) TableName() string

TableName returns the name of the VoteOption database table.

type VoteOptionResult

type VoteOptionResult struct {
	Key       string     `gorm:"primary_key"`      // Primary key (token+votebit)
	Token     string     `gorm:"not null;size:64"` // Censorship token (VoteResults foreign key)
	Votes     uint64     `gorm:"not null"`         // Number of votes cast for this option
	Option    VoteOption `gorm:"not null"`         // Vote option
	OptionKey uint       `gorm:"not null"`         // VoteOption foreign key
}

VoteOptionResults records the vote result for a vote option. A VoteOptionResult should only be created once the proposal vote has finished.

This is a fonero plugin model.

func (VoteOptionResult) TableName

func (VoteOptionResult) TableName() string

TableName returns the name of the VoteOptionResult database table.

type VoteResults

type VoteResults struct {
	Token    string             `gorm:"primary_key;size:64"` // Censorship token
	Approved bool               `gorm:"not null"`            // Vote was approved
	Results  []VoteOptionResult `gorm:"foreignkey:Token"`    // Results for the vote options
}

VoteResults records the tallied vote results for a proposal and whether the vote was approved/rejected. A vote result entry should only be created once the voting period has ended. The vote results table is lazy loaded.

This is a fonero plugin model.

func (VoteResults) TableName

func (VoteResults) TableName() string

TableName returns the name of the VoteResults database table.

Jump to

Keyboard shortcuts

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