pi

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: ISC Imports: 0 Imported by: 0

Documentation

Overview

Package pi provides a plugin that extends records with functionality for decred's proposal system.

Index

Constants

View Source
const (
	// SettingKeyTextFileSizeMax is the plugin setting key for the
	// SettingTextFileSizeMax plugin setting.
	SettingKeyTextFileSizeMax = "textfilesizemax"

	// SettingKeyImageFileCountMax is the plugin setting key for the
	// SettingImageFileCountMax plugin setting.
	SettingKeyImageFileCountMax = "imagefilecountmax"

	// SettingKeyImageFileSizeMax is the plugin setting key for the
	// SettingImageFileSizeMax plugin setting.
	SettingKeyImageFileSizeMax = "imagefilesizemax"

	// SettingKeyProposalNameLengthMin is the plugin setting key for
	// the SettingProposalNameLengthMin plugin setting.
	SettingKeyProposalNameLengthMin = "proposalnamelengthmin"

	// SettingKeyProposalNameLengthMax is the plugin setting key for
	// the SettingProposalNameLengthMax plugin setting.
	SettingKeyProposalNameLengthMax = "proposalnamelengthmax"

	// SettingKeyProposalNameSupportedChars is the plugin setting key
	// for the SettingProposalNameSupportedChars plugin setting.
	SettingKeyProposalNameSupportedChars = "proposalnamesupportedchars"
)

Plugin setting keys can be used to specify custom plugin settings. Default plugin setting values can be overridden by providing a plugin setting key and value to the plugin on startup.

View Source
const (
	// SettingTextFileSizeMax is the default maximum allowed size of a
	// text file in bytes.
	SettingTextFileSizeMax uint32 = 512 * 1024

	// SettingImageFileCountMax is the default maximum number of image
	// files that can be included in a proposal.
	SettingImageFileCountMax uint32 = 5

	// SettingImageFileSizeMax is the default maximum allowed size of
	// an image file in bytes.
	SettingImageFileSizeMax uint32 = 512 * 1024

	// SettingProposalNameLengthMin is the default minimum number of
	// characters that a proposal name can be.
	SettingProposalNameLengthMin uint32 = 8

	// SettingProposalNameLengthMax is the default maximum number of
	// characters that a proposal name can be.
	SettingProposalNameLengthMax uint32 = 80
)

Plugin setting default values. These can be overridden by providing a plugin setting key and value to the plugin on startup.

View Source
const (
	// FileNameIndexFile is the file name of the proposal markdown
	// file. Every proposal is required to have an index file. The
	// index file should contain the proposal content.
	FileNameIndexFile = "index.md"

	// FileNameProposalMetadata is the filename of the ProposalMetadata
	// file that is saved to politeiad. ProposalMetadata is saved to
	// politeiad as a file, not as a metadata stream, since it contains
	// user provided metadata and needs to be included in the merkle
	// root that politeiad signs.
	FileNameProposalMetadata = "proposalmetadata.json"
)
View Source
const (
	// PluginID is the unique identifier for this plugin.
	PluginID = "pi"
)

Variables

View Source
var (
	// ErrorCodes contains the human readable errors.
	ErrorCodes = map[ErrorCodeT]string{
		ErrorCodeInvalid:               "error code invalid",
		ErrorCodeTextFileNameInvalid:   "text file name invalid",
		ErrorCodeTextFileSizeInvalid:   "text file size invalid",
		ErrorCodeTextFileMissing:       "text file is misisng",
		ErrorCodeImageFileCountInvalid: "image file count invalid",
		ErrorCodeImageFileSizeInvalid:  "image file size invalid",
		ErrorCodeProposalNameInvalid:   "proposal name invalid",
		ErrorCodeVoteStatusInvalid:     "vote status invalid",
	}
)
View Source
var (
	// SettingProposalNameSupportedChars contains the supported
	// characters in a proposal name.
	SettingProposalNameSupportedChars = []string{
		"A-z", "0-9", "&", ".", ",", ":", ";", "-", " ", "@", "+", "#",
		"/", "(", ")", "!", "?", "\"", "'",
	}
)

Functions

This section is empty.

Types

type ErrorCodeT

type ErrorCodeT uint32

ErrorCodeT represents a plugin error that was caused by the user.

const (
	// ErrorCodeInvalid represents and invalid error code.
	ErrorCodeInvalid ErrorCodeT = 0

	// ErrorCodeTextFileNameInvalid is returned when a text file has
	// a file name that is not allowed.
	ErrorCodeTextFileNameInvalid ErrorCodeT = 1

	// ErrorCodeTextFileSizeInvalid is returned when a text file size
	// exceedes the TextFileSizeMax setting.
	ErrorCodeTextFileSizeInvalid ErrorCodeT = 2

	// ErrorCodeTextFileMissing is returned when the proposal does not
	// contain one or more of the required text files.
	ErrorCodeTextFileMissing ErrorCodeT = 3

	// ErrorCodeImageFileCountInvalid is returned when the number of
	// image attachments exceedes the ImageFileCountMax setting.
	ErrorCodeImageFileCountInvalid ErrorCodeT = 4

	// ErrorCodeImageFileSizeInvalid is returned when an image file
	// size exceedes the ImageFileSizeMax setting.
	ErrorCodeImageFileSizeInvalid ErrorCodeT = 5

	// ErrorCodeProposalNameInvalid is returned when a proposal name
	// does not adhere to the proposal name settings.
	ErrorCodeProposalNameInvalid ErrorCodeT = 6

	// ErrorCodeVoteStatusInvalid is returned when a proposal vote
	// status does not allow changes to be made to the proposal.
	ErrorCodeVoteStatusInvalid ErrorCodeT = 7

	// ErrorCodeLast unit test only.
	ErrorCodeLast ErrorCodeT = 8
)

type ProposalMetadata

type ProposalMetadata struct {
	Name string `json:"name"`
}

ProposalMetadata contains metadata that is provided by the user as part of the proposal submission bundle. The proposal metadata is included in the proposal signature since it is user specified data. The ProposalMetadata object is saved to politeiad as a file, not as a metadata stream, since it needs to be included in the merkle root that politeiad signs.

Jump to

Keyboard shortcuts

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