mdstream

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: ISC Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// mdstream IDs
	IDInvalid              = 0
	IDRecordStatusChange   = 2
	IDInvoiceGeneral       = 3
	IDInvoiceStatusChange  = 4
	IDInvoicePayment       = 5
	IDDCCGeneral           = 6
	IDDCCStatusChange      = 7
	IDDCCSupportOpposition = 8

	// mdstream current supported versions
	VersionRecordStatusChange   = 2
	VersionInvoiceGeneral       = 1
	VersionInvoiceStatusChange  = 1
	VersionInvoicePayment       = 1
	VersionDCCGeneral           = 1
	VersionDCCStatusChange      = 1
	VersionDCCSupposeOpposition = 1
)

Variables

This section is empty.

Functions

func DecodeRecordStatusChanges

func DecodeRecordStatusChanges(payload []byte) ([]RecordStatusChangeV1, []RecordStatusChangeV2, error)

DecodeRecordStatusChanges decodes a JSON byte slice into a slice of RecordStatusChangeV1 and a slice of RecordStatusChangeV2.

func DecodeVersion

func DecodeVersion(payload []byte) (uint, error)

DecodeVersion returns the version of the provided mstream payload. This function should only be used when the payload contains a single struct with a version field.

func EncodeDCCGeneral

func EncodeDCCGeneral(md DCCGeneral) ([]byte, error)

EncodeDCCGeneral encodes a DCCGeneral into a JSON byte slice.

func EncodeDCCStatusChange

func EncodeDCCStatusChange(md DCCStatusChange) ([]byte, error)

EncodeDCCStatusChange encodes a DCCStatusChange into a JSON byte slice.

func EncodeDCCSupportOpposition

func EncodeDCCSupportOpposition(md DCCSupportOpposition) ([]byte, error)

EncodeDCCSupportOpposition encodes a DCCSupportOpposition into a JSON byte slice.

func EncodeInvoiceGeneral

func EncodeInvoiceGeneral(md InvoiceGeneral) ([]byte, error)

EncodeInvoiceGeneral encodes a InvoiceGeneral into a JSON byte slice.

func EncodeInvoicePayment

func EncodeInvoicePayment(md InvoicePayment) ([]byte, error)

EncodeInvoicePayment encodes a InvoicePayment into a JSON byte slice.

func EncodeInvoiceStatusChange

func EncodeInvoiceStatusChange(md InvoiceStatusChange) ([]byte, error)

EncodeInvoiceStatusChange encodes a InvoiceStatusChange into a JSON byte slice.

func EncodeRecordStatusChangeV1

func EncodeRecordStatusChangeV1(rsc RecordStatusChangeV1) ([]byte, error)

EncodeRecordStatusChangeV1 encodes an RecordStatusChangeV1 into a JSON byte slice.

func EncodeRecordStatusChangeV2

func EncodeRecordStatusChangeV2(rsc RecordStatusChangeV2) ([]byte, error)

EncodeRecordStatusChangeV2 encodes an RecordStatusChangeV2 into a JSON byte slice.

Types

type DCCGeneral

type DCCGeneral struct {
	Version   uint64 `json:"version"`   // Version of the struct
	Timestamp int64  `json:"timestamp"` // Last update of invoice
	PublicKey string `json:"publickey"` // Key used for signature
	Signature string `json:"signature"` // Signature of merkle root
}

DCCGeneral represents the general metadata for a DCC and is stored in the metadata stream IDDCCGeneral in politeiad.

func DecodeDCCGeneral

func DecodeDCCGeneral(payload []byte) (*DCCGeneral, error)

DecodeDCCGeneral decodes a JSON byte slice into a DCCGeneral.

type DCCStatusChange

type DCCStatusChange struct {
	Version        uint           `json:"version"`        // Version of the struct
	AdminPublicKey string         `json:"adminpublickey"` // Identity of the administrator
	NewStatus      cms.DCCStatusT `json:"newstatus"`      // Status
	Reason         string         `json:"reason"`         // Reason
	Timestamp      int64          `json:"timestamp"`      // Timestamp of the change
	Signature      string         `json:"signature"`      // Signature of Token + NewStatus + Reason
}

DCCStatusChange represents the metadata for any status change that occurs to a patricular DCC issuance or revocation.

func DecodeDCCStatusChange

func DecodeDCCStatusChange(payload []byte) ([]DCCStatusChange, error)

DecodeDCCStatusChange decodes a JSON byte slice into a slice of DCCStatusChange.

type DCCSupportOpposition

type DCCSupportOpposition struct {
	Version   uint64 `json:"version"`   // Version of the struct
	Timestamp int64  `json:"timestamp"` // Last update of invoice
	PublicKey string `json:"publickey"` // Key used for signature
	Vote      string `json:"vote"`      // Vote for support/opposition
	Signature string `json:"signature"` // Signature of Token + Vote
}

DCCSupportOpposition represents the general metadata for a DCC Support/Opposition 'vote' for a given DCC proposal.

func DecodeDCCSupportOpposition

func DecodeDCCSupportOpposition(payload []byte) ([]DCCSupportOpposition, error)

DecodeDCCSupportOpposition decodes a JSON byte slice into a DCCSupportOpposition.

type InvoiceGeneral

type InvoiceGeneral struct {
	Version   uint64 `json:"version"`   // Version of the struct
	Timestamp int64  `json:"timestamp"` // Last update of invoice
	PublicKey string `json:"publickey"` // Key used for signature
	Signature string `json:"signature"` // Signature of merkle root
}

InvoiceGeneral represents the general metadata for an invoice and is stored in the metadata IDInvoiceGeneral in politeiad.

func DecodeInvoiceGeneral

func DecodeInvoiceGeneral(payload []byte) (*InvoiceGeneral, error)

DecodeInvoiceGeneral decodes a JSON byte slice into an InvoiceGeneral.

type InvoicePayment

type InvoicePayment struct {
	Version        uint   `json:"version"`        // Version of the struct
	TxIDs          string `json:"txids"`          // TxIDs captured from the payment, separated by commas
	Timestamp      int64  `json:"timeupdated"`    // Time of last payment update
	AmountReceived int64  `json:"amountreceived"` // Amount of DCR payment currently received
}

InvoicePayment represents an invoice payment and is stored in the metadata IDInvoicePayment in politeiad.

func DecodeInvoicePayment

func DecodeInvoicePayment(payload []byte) ([]InvoicePayment, error)

DecodeInvoicePayment decodes a JSON byte slice into an InvoicePayment.

type InvoiceStatusChange

type InvoiceStatusChange struct {
	Version        uint               `json:"version"`        // Version of the struct
	AdminPublicKey string             `json:"adminpublickey"` // Identity of the administrator
	NewStatus      cms.InvoiceStatusT `json:"newstatus"`      // Status
	Reason         string             `json:"reason"`         // Reason
	Timestamp      int64              `json:"timestamp"`      // Timestamp of the change
}

InvoiceStatusChange represents an invoice status change and is stored in the metadata IDInvoiceStatusChange in politeiad.

func DecodeInvoiceStatusChange

func DecodeInvoiceStatusChange(payload []byte) ([]InvoiceStatusChange, error)

DecodeInvoiceStatusChange decodes a JSON byte slice into a slice of InvoiceStatusChanges.

type RecordStatusChangeV1

type RecordStatusChangeV1 struct {
	Version             uint             `json:"version"`                       // Version of the struct
	AdminPubKey         string           `json:"adminpubkey"`                   // Identity of the administrator
	NewStatus           pd.RecordStatusT `json:"newstatus"`                     // New status
	StatusChangeMessage string           `json:"statuschangemessage,omitempty"` // Change message
	Timestamp           int64            `json:"timestamp"`                     // UNIX timestamp
}

RecordStatusChangeV1 represents a politeiad record status change and is used to store additional status change metadata that would not otherwise be captured by the politeiad status change routes.

This mdstream is used by both pi and cms.

type RecordStatusChangeV2

type RecordStatusChangeV2 struct {
	Version             uint             `json:"version"`                       // Struct version
	NewStatus           pd.RecordStatusT `json:"newstatus"`                     // New status
	StatusChangeMessage string           `json:"statuschangemessage,omitempty"` // Change message
	Signature           string           `json:"signature"`                     // Signature of (Token + NewStatus + StatusChangeMessage)
	AdminPubKey         string           `json:"adminpubkey"`                   // Signature pubkey
	Timestamp           int64            `json:"timestamp"`                     // UNIX timestamp
}

RecordStatusChangeV2 represents a politeiad record status change and is used to store additional status change metadata that would not otherwise be captured by the politeiad status change routes.

V2 adds the Signature field, which was erroneously left out of V1.

This mdstream is used by both pi and cms.

func (*RecordStatusChangeV2) VerifySignature

func (r *RecordStatusChangeV2) VerifySignature(token string) error

VerifySignature verifies that the RecordStatusChangeV2 signature is correct.

Jump to

Keyboard shortcuts

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