operation

package
v0.0.0-...-5a6e01e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package operation is the collection of Operations.

Index

Constants

View Source
const MaxTokenSize = 100

Variables

View Source
var (
	SealType   = hint.Type("seal")
	SealHint   = hint.NewHint(SealType, "v0.0.1")
	SealHinter = BaseSeal{BaseSeal: seal.NewBaseSealWithHint(SealHint)}
)
View Source
var (
	FixedTreeNodeType   = hint.Type("operation-fixedtree-node")
	FixedTreeNodeHint   = hint.NewHint(FixedTreeNodeType, "v0.0.1")
	FixedTreeNodeHinter = FixedTreeNode{
		BaseFixedTreeNode: tree.BaseFixedTreeNode{BaseHinter: hint.NewBaseHinter(FixedTreeNodeHint)},
	}
	BaseReasonErrorType = hint.Type("base-operation-reason")
	BaseReasonErrorHint = hint.NewHint(BaseReasonErrorType, "v0.0.1")
)

Functions

func IsValidOperation

func IsValidOperation(op Operation, networkID []byte) error

func IsValidOperationFact

func IsValidOperationFact(fact OperationFact, networkID []byte) error

func LastSignedAt

func LastSignedAt(fs []base.FactSign) time.Time

Types

type BaseOperation

type BaseOperation struct {
	hint.BaseHinter
	// contains filtered or unexported fields
}

func EmptyBaseOperation

func EmptyBaseOperation(ht hint.Hint) BaseOperation

func NewBaseOperation

func NewBaseOperation(ht hint.Hint, fact OperationFact, h valuehash.Hash, fs []base.FactSign) BaseOperation

func NewBaseOperationFromFact

func NewBaseOperationFromFact(ht hint.Hint, fact OperationFact, fs []base.FactSign) (BaseOperation, error)

func (BaseOperation) AddFactSigns

func (bo BaseOperation) AddFactSigns(fs ...base.FactSign) (base.FactSignUpdater, error)

func (BaseOperation) BSONM

func (bo BaseOperation) BSONM() bson.M

func (BaseOperation) Fact

func (bo BaseOperation) Fact() base.Fact

func (BaseOperation) GenerateHash

func (bo BaseOperation) GenerateHash() valuehash.Hash

func (BaseOperation) Hash

func (bo BaseOperation) Hash() valuehash.Hash

func (BaseOperation) IsValid

func (bo BaseOperation) IsValid(networkID []byte) error

func (BaseOperation) JSONM

func (bo BaseOperation) JSONM() map[string]interface{}

func (BaseOperation) LastSignedAt

func (bo BaseOperation) LastSignedAt() time.Time

func (BaseOperation) MarshalBSON

func (bo BaseOperation) MarshalBSON() ([]byte, error)

func (BaseOperation) MarshalJSON

func (bo BaseOperation) MarshalJSON() ([]byte, error)

func (BaseOperation) SetHash

func (bo BaseOperation) SetHash(h valuehash.Hash) BaseOperation

func (BaseOperation) Signs

func (bo BaseOperation) Signs() []base.FactSign

func (BaseOperation) Token

func (bo BaseOperation) Token() []byte

func (*BaseOperation) UnpackBSON

func (bo *BaseOperation) UnpackBSON(b []byte, enc *bsonenc.Encoder) error

func (*BaseOperation) UnpackJSON

func (bo *BaseOperation) UnpackJSON(b []byte, enc *jsonenc.Encoder) error

type BaseOperationBSONUnpacker

type BaseOperationBSONUnpacker struct {
	H  valuehash.Bytes `bson:"hash"`
	FC bson.Raw        `bson:"fact"`
	FS bson.Raw        `bson:"fact_signs"`
}

type BaseReasonError

type BaseReasonError struct {
	*util.NError
	// contains filtered or unexported fields
}

func NewBaseReasonError

func NewBaseReasonError(s string, a ...interface{}) BaseReasonError

func (BaseReasonError) Data

func (e BaseReasonError) Data() map[string]interface{}

func (BaseReasonError) Error

func (e BaseReasonError) Error() string

func (BaseReasonError) Errorf

func (e BaseReasonError) Errorf(s string, a ...interface{}) ReasonError

func (BaseReasonError) Format

func (e BaseReasonError) Format(s fmt.State, v rune)

func (BaseReasonError) Hint

func (BaseReasonError) Hint() hint.Hint

func (BaseReasonError) MarshalBSON

func (e BaseReasonError) MarshalBSON() ([]byte, error)

func (BaseReasonError) MarshalJSON

func (e BaseReasonError) MarshalJSON() ([]byte, error)

func (BaseReasonError) Msg

func (e BaseReasonError) Msg() string

func (BaseReasonError) SetData

func (e BaseReasonError) SetData(data map[string]interface{}) BaseReasonError

func (*BaseReasonError) UnmarshalBSON

func (e *BaseReasonError) UnmarshalBSON(b []byte) error

func (*BaseReasonError) UnmarshalJSON

func (e *BaseReasonError) UnmarshalJSON(b []byte) error

type BaseReasonErrorBSONUnpacker

type BaseReasonErrorBSONUnpacker struct {
	MS string                 `bson:"msg"`
	DT map[string]interface{} `bson:"data"`
}

type BaseReasonErrorJSONPacker

type BaseReasonErrorJSONPacker struct {
	jsonenc.HintedHead
	MS string                 `json:"msg"`
	DT map[string]interface{} `json:"data"`
}

type BaseReasonErrorJSONUnpacker

type BaseReasonErrorJSONUnpacker struct {
	MS string                 `json:"msg"`
	DT map[string]interface{} `json:"data"`
}

type BaseSeal

type BaseSeal struct {
	seal.BaseSeal
	// contains filtered or unexported fields
}

func NewBaseSeal

func NewBaseSeal(pk key.Privatekey, ops []Operation, networkID []byte) (BaseSeal, error)

func (BaseSeal) BodyBytes

func (sl BaseSeal) BodyBytes() []byte

func (BaseSeal) IsValid

func (sl BaseSeal) IsValid(networkID []byte) error

func (BaseSeal) MarshalBSON

func (sl BaseSeal) MarshalBSON() ([]byte, error)

func (BaseSeal) MarshalJSON

func (sl BaseSeal) MarshalJSON() ([]byte, error)

func (BaseSeal) Operations

func (sl BaseSeal) Operations() []Operation

func (BaseSeal) SetOperations

func (sl BaseSeal) SetOperations(ops []Operation) SealUpdater

func (*BaseSeal) UnpackBSON

func (sl *BaseSeal) UnpackBSON(b []byte, enc *bsonenc.Encoder) error

func (*BaseSeal) UnpackJSON

func (sl *BaseSeal) UnpackJSON(b []byte, enc *jsonenc.Encoder) error

type BaseSealBSONUnpack

type BaseSealBSONUnpack struct {
	OPS bson.Raw `bson:"operations"`
}

type BaseSealJSONPack

type BaseSealJSONPack struct {
	*seal.BaseSealJSONPack
	OPS []Operation `json:"operations"`
}

type BaseSealJSONUnpack

type BaseSealJSONUnpack struct {
	OPS json.RawMessage `json:"operations"`
}

type FixedTreeNode

type FixedTreeNode struct {
	tree.BaseFixedTreeNode
	// contains filtered or unexported fields
}

func NewFixedTreeNode

func NewFixedTreeNode(index uint64, key []byte, inState bool, reason error) FixedTreeNode

func NewFixedTreeNodeWithHash

func NewFixedTreeNodeWithHash(index uint64, key, hash []byte, inState bool, reason error) FixedTreeNode

func (FixedTreeNode) Equal

func (no FixedTreeNode) Equal(n tree.FixedTreeNode) bool

func (FixedTreeNode) InState

func (no FixedTreeNode) InState() bool

func (FixedTreeNode) MarshalBSON

func (no FixedTreeNode) MarshalBSON() ([]byte, error)

func (FixedTreeNode) MarshalJSON

func (no FixedTreeNode) MarshalJSON() ([]byte, error)

func (FixedTreeNode) Reason

func (no FixedTreeNode) Reason() ReasonError

func (FixedTreeNode) SetHash

func (no FixedTreeNode) SetHash(h []byte) tree.FixedTreeNode

func (*FixedTreeNode) UnpackBSON

func (no *FixedTreeNode) UnpackBSON(b []byte, enc *bsonenc.Encoder) error

func (*FixedTreeNode) UnpackJSON

func (no *FixedTreeNode) UnpackJSON(b []byte, enc *jsonenc.Encoder) error

type FixedTreeNodeBSONUnpacker

type FixedTreeNodeBSONUnpacker struct {
	IS bool     `bson:"in_state"`
	RS bson.Raw `bson:"reason"`
}

type FixedTreeNodeJSONPacker

type FixedTreeNodeJSONPacker struct {
	jsonenc.HintedHead
	IN uint64      `json:"index"`
	KY string      `json:"key"`
	HS string      `json:"hash"`
	IS bool        `json:"in_state"`
	RS ReasonError `json:"reason"`
}

type FixedTreeNodeJSONUnpacker

type FixedTreeNodeJSONUnpacker struct {
	IS bool            `json:"in_state"`
	RS json.RawMessage `json:"reason"`
}

type Operation

type Operation interface {
	isvalid.IsValider
	hint.Hinter
	valuehash.Hasher
	valuehash.HashGenerator
	Fact() base.Fact
	Signs() []base.FactSign
	LastSignedAt() time.Time
}

type OperationFact

type OperationFact interface {
	base.Fact
	Token() []byte
}

type ReasonError

type ReasonError interface {
	error
	hint.Hinter
	Msg() string
	Data() map[string]interface{}
	Errorf(string, ...interface{}) ReasonError
}

func NewBaseReasonErrorFromError

func NewBaseReasonErrorFromError(err error) ReasonError

type Seal

type Seal interface {
	seal.Seal
	Operations() []Operation
}

type SealUpdater

type SealUpdater interface {
	SetOperations([]Operation) SealUpdater
}

Jump to

Keyboard shortcuts

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