Documentation ¶
Overview ¶
Package base provides the fundamental structures for currency model.
Index ¶
- Variables
- func DecodeStateValue(b []byte, enc encoder.Encoder) (base.StateValue, error)
- func DecorateError(err, v error, arg interface{}) error
- func IsValidOperationFact(fact base.Fact, networkID []byte) error
- func IsValidSignFact(sf base.SignFact, networkID []byte) error
- func NewHashFromBytes(b []byte) util.Hash
- type BaseFactBSONUnmarshaler
- type BaseNode
- func (n BaseNode) Address() base.Address
- func (n *BaseNode) DecodeBSON(b []byte, enc *bsonenc.Encoder) error
- func (n *BaseNode) DecodeJSON(b []byte, enc encoder.Encoder) error
- func (n BaseNode) HashBytes() []byte
- func (n BaseNode) IsValid([]byte) error
- func (n BaseNode) MarshalBSON() ([]byte, error)
- func (n BaseNode) MarshalJSON() ([]byte, error)
- func (n BaseNode) Publickey() base.Publickey
- type BaseNodeBSONUnMarshaler
- type BaseNodeJSONMarshaler
- type BaseNodeJSONUnmarshaler
- type BaseNodeOperation
- func (op *BaseNodeOperation) AddNodeSigns(signs []base.NodeSign) (added bool, _ error)
- func (op *BaseNodeOperation) DecodeBSON(b []byte, enc *bsonenc.Encoder) error
- func (op *BaseNodeOperation) DecodeJSON(b []byte, enc encoder.Encoder) error
- func (op BaseNodeOperation) IsValid(networkID []byte) error
- func (op BaseNodeOperation) MarshalJSON() ([]byte, error)
- func (op *BaseNodeOperation) NodeSign(priv base.Privatekey, networkID base.NetworkID, node base.Address) error
- func (op BaseNodeOperation) NodeSigns() []base.NodeSign
- func (op *BaseNodeOperation) SetNodeSigns(signs []base.NodeSign) error
- type BaseOperation
- func (op *BaseOperation) DecodeBSON(b []byte, enc *bsonenc.Encoder) error
- func (op *BaseOperation) DecodeJSON(b []byte, enc encoder.Encoder) error
- func (op BaseOperation) Fact() base.Fact
- func (op BaseOperation) Hash() util.Hash
- func (op BaseOperation) HashBytes() []byte
- func (op BaseOperation) IsValid(networkID []byte) error
- func (op BaseOperation) JSONMarshaler() BaseOperationJSONMarshaler
- func (op BaseOperation) MarshalBSON() ([]byte, error)
- func (op BaseOperation) MarshalJSON() ([]byte, error)
- func (BaseOperation) PreProcess(ctx context.Context, _ base.GetStateFunc) (context.Context, base.OperationProcessReasonError, error)
- func (BaseOperation) Process(context.Context, base.GetStateFunc) ([]base.StateMergeValue, base.OperationProcessReasonError, error)
- func (op *BaseOperation) SetFact(fact base.Fact)
- func (op *BaseOperation) SetHash(h util.Hash)
- func (op *BaseOperation) Sign(priv base.Privatekey, networkID base.NetworkID) error
- func (op BaseOperation) Signs() []base.Sign
- type BaseOperationBSONUnmarshaler
- type BaseOperationJSONMarshaler
- type BaseOperationJSONUnmarshaler
- type BaseSignBSONUnmarshaler
- type BaseState
- func (s BaseState) BSONM() bson.M
- func (s *BaseState) DecodeBSON(b []byte, enc *bsonenc.Encoder) error
- func (s *BaseState) DecodeJSON(b []byte, enc encoder.Encoder) error
- func (s BaseState) Hash() util.Hash
- func (s BaseState) Height() base.Height
- func (s BaseState) IsValid([]byte) error
- func (s BaseState) Key() string
- func (s BaseState) MarshalBSON() ([]byte, error)
- func (s BaseState) MarshalJSON() ([]byte, error)
- func (s BaseState) Operations() []util.Hash
- func (s BaseState) Previous() util.Hash
- func (s BaseState) Value() base.StateValue
- type BaseStateBSONUnmarshaler
- type BaseStateMergeValue
- type BaseStateValueMerger
- func (s *BaseStateValueMerger) AddOperation(op util.Hash)
- func (s *BaseStateValueMerger) Close() error
- func (s *BaseStateValueMerger) CloseValue() (base.State, error)
- func (s *BaseStateValueMerger) Height() base.Height
- func (s *BaseStateValueMerger) Key() string
- func (s *BaseStateValueMerger) Merge(value base.StateValue, op util.Hash) error
- func (s *BaseStateValueMerger) Reset(height base.Height, key string, st base.State)
- func (s *BaseStateValueMerger) SetValue(v base.StateValue)
- func (s *BaseStateValueMerger) State() base.State
- type Big
- func (a Big) Add(b Big) Big
- func (a Big) Compare(b Big) int
- func (a Big) Div(b Big) Big
- func (a Big) Equal(b Big) bool
- func (Big) IsValid([]byte) error
- func (a Big) IsZero() bool
- func (a Big) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (a Big) MarshalJSON() ([]byte, error)
- func (a Big) Mul(b Big) Big
- func (a Big) MulFloat64(b float64) Big
- func (a Big) MulInt64(b int64) Big
- func (a Big) Neg() Big
- func (a Big) OverNil() bool
- func (a Big) OverZero() bool
- func (a Big) String() string
- func (a Big) Sub(b Big) Big
- func (a *Big) UnmarshalBSONValue(t bsontype.Type, b []byte) error
- func (a *Big) UnmarshalJSON(b []byte) error
- type Bytes
- type ErrMessage
- type HashDecoder
- type HashGenerator
Constants ¶
This section is empty.
Variables ¶
View Source
var ( NilBig = NewBig(-1) NilBigString = big.NewInt(-1).String() ZeroBig = NewBig(0) )
View Source
var ( ErrDecodeJson = util.NewIDError(string(ErrMDecodeJson)) ErrDecodeBson = util.NewIDError(string(ErrMDecodeBson)) ErrFactInvalid = util.NewIDError(string(ErrMFactInvalid)) ErrItemInvalid = util.NewIDError(string(ErrMItemInvalid)) ErrNodeOperationInvalid = util.NewIDError(string(ErrMNodeOperationInvalid)) ErrOperationInvalid = util.NewIDError(string(ErrMOperationInvalid)) ErrPreProcess = util.NewIDError(string(ErrMPreProcess)) ErrStateInvalid = util.NewIDError(string(ErrMStateInvalid)) )
View Source
var ( ErrAccountE = util.NewIDError(string(ErrMAccountE)) ErrAccountNAth = util.NewIDError(string(ErrMAccountNAth)) ErrAccountNF = util.NewIDError(string(ErrMAccountNF)) ErrAccTypeInvalid = util.NewIDError(string(ErrMAccTypeInvalid)) ErrArrayLen = util.NewIDError(string(ErrMArrayLen)) ErrCAccountE = util.NewIDError(string(ErrMCAccountE)) ErrCAccountNA = util.NewIDError(string(ErrMCAccountNA)) ErrCAccountNF = util.NewIDError(string(ErrMCAccountNF)) ErrCurrencyNF = util.NewIDError(string(ErrMCurrencyNF)) ErrDupVal = util.NewIDError(string(ErrMDupVal)) ErrSelfTarget = util.NewIDError(string(ErrMSelfTarget)) ErrServiceE = util.NewIDError(string(ErrMServiceE)) ErrServiceNF = util.NewIDError(string(ErrMServiceNF)) ErrSignInvalid = util.NewIDError(string(ErrMSignInvalid)) ErrSignNE = util.NewIDError(string(ErrMSignNE)) ErrStateE = util.NewIDError(string(ErrMStateE)) ErrStateNF = util.NewIDError(string(ErrMStateNF)) ErrStateValInvalid = util.NewIDError(string(ErrMStateValInvalid)) ErrTypeMismatch = util.NewIDError(string(ErrMTypeMismatch)) ErrValOOR = util.NewIDError(string(ErrMValOOR)) ErrValueInvalid = util.NewIDError(string(ErrMValueInvalid)) )
View Source
var ( ErrMDecodeJson = ErrMessage("Decode Json") ErrMDecodeBson = ErrMessage("Decode Bson") ErrMFactInvalid = ErrMessage("Invalid fact") ErrMItemInvalid = ErrMessage("Invalid item") ErrMNodeOperationInvalid = ErrMessage("Invalid BaseNodeOperation") ErrMOperationInvalid = ErrMessage("Invalid BaseOperation") ErrMPreProcess = ErrMessage("PreProcess") ErrMStateInvalid = ErrMessage("Invalid BaseState") )
View Source
var ( ErrMAccountE = ErrMessage("Account exist") ErrMAccountNAth = ErrMessage("Account not authorized") ErrMAccountNF = ErrMessage("Account not found") ErrMAccTypeInvalid = ErrMessage("Invalid account type") ErrMArrayLen = ErrMessage("Array length") ErrMCAccountE = ErrMessage("Contract account exist") ErrMCAccountNA = ErrMessage("Contract account not allowed") ErrMCAccountNF = ErrMessage("Contract account not found") ErrMCurrencyE = ErrMessage("Currency exist") ErrMCurrencyNF = ErrMessage("Currency not found") ErrMDupVal = ErrMessage("Duplicated value") ErrMSignInvalid = ErrMessage("Invalid signing") ErrMSignNE = ErrMessage("Not enough sign") ErrMSelfTarget = ErrMessage("Self targeted") ErrMServiceE = ErrMessage("Service exist") ErrMServiceNF = ErrMessage("Service not found") ErrMStateE = ErrMessage("State exist") ErrMStateNF = ErrMessage("State not found") ErrMStateValInvalid = ErrMessage("Invalid state value") ErrMTypeMismatch = ErrMessage("Type mismatch") ErrMValOOR = ErrMessage("Value out of range") ErrMValueInvalid = ErrMessage("Invalid value") )
View Source
var BaseStateHint = hint.MustNewHint("currency-base-state-v0.0.1")
View Source
var NodeHint = hint.MustNewHint("currency-node-v0.0.1")
Functions ¶
func DecodeStateValue ¶
func DecorateError ¶
func NewHashFromBytes ¶
Types ¶
type BaseFactBSONUnmarshaler ¶
type BaseNode ¶
type BaseNode struct { util.IsValider hint.BaseHinter // contains filtered or unexported fields }
func (BaseNode) MarshalBSON ¶
func (BaseNode) MarshalJSON ¶
type BaseNodeBSONUnMarshaler ¶
type BaseNodeJSONMarshaler ¶
type BaseNodeJSONUnmarshaler ¶
type BaseNodeOperation ¶
type BaseNodeOperation struct {
BaseOperation
}
func NewBaseNodeOperation ¶
func NewBaseNodeOperation(ht hint.Hint, fact base.Fact) BaseNodeOperation
func (*BaseNodeOperation) AddNodeSigns ¶
func (op *BaseNodeOperation) AddNodeSigns(signs []base.NodeSign) (added bool, _ error)
func (*BaseNodeOperation) DecodeBSON ¶
func (op *BaseNodeOperation) DecodeBSON(b []byte, enc *bsonenc.Encoder) error
func (*BaseNodeOperation) DecodeJSON ¶
func (op *BaseNodeOperation) DecodeJSON(b []byte, enc encoder.Encoder) error
func (BaseNodeOperation) IsValid ¶
func (op BaseNodeOperation) IsValid(networkID []byte) error
func (BaseNodeOperation) MarshalJSON ¶
func (op BaseNodeOperation) MarshalJSON() ([]byte, error)
func (*BaseNodeOperation) NodeSign ¶
func (op *BaseNodeOperation) NodeSign(priv base.Privatekey, networkID base.NetworkID, node base.Address) error
func (BaseNodeOperation) NodeSigns ¶
func (op BaseNodeOperation) NodeSigns() []base.NodeSign
func (*BaseNodeOperation) SetNodeSigns ¶
func (op *BaseNodeOperation) SetNodeSigns(signs []base.NodeSign) error
type BaseOperation ¶
type BaseOperation struct { hint.BaseHinter // contains filtered or unexported fields }
func NewBaseOperation ¶
func NewBaseOperation(ht hint.Hint, fact base.Fact) BaseOperation
func (*BaseOperation) DecodeBSON ¶
func (op *BaseOperation) DecodeBSON(b []byte, enc *bsonenc.Encoder) error
func (*BaseOperation) DecodeJSON ¶
func (op *BaseOperation) DecodeJSON(b []byte, enc encoder.Encoder) error
func (BaseOperation) Fact ¶
func (op BaseOperation) Fact() base.Fact
func (BaseOperation) Hash ¶
func (op BaseOperation) Hash() util.Hash
func (BaseOperation) HashBytes ¶
func (op BaseOperation) HashBytes() []byte
func (BaseOperation) IsValid ¶
func (op BaseOperation) IsValid(networkID []byte) error
func (BaseOperation) JSONMarshaler ¶
func (op BaseOperation) JSONMarshaler() BaseOperationJSONMarshaler
func (BaseOperation) MarshalBSON ¶
func (op BaseOperation) MarshalBSON() ([]byte, error)
func (BaseOperation) MarshalJSON ¶
func (op BaseOperation) MarshalJSON() ([]byte, error)
func (BaseOperation) PreProcess ¶
func (BaseOperation) PreProcess(ctx context.Context, _ base.GetStateFunc) ( context.Context, base.OperationProcessReasonError, error, )
func (BaseOperation) Process ¶
func (BaseOperation) Process(context.Context, base.GetStateFunc) ([]base.StateMergeValue, base.OperationProcessReasonError, error)
func (*BaseOperation) SetFact ¶
func (op *BaseOperation) SetFact(fact base.Fact)
func (*BaseOperation) SetHash ¶
func (op *BaseOperation) SetHash(h util.Hash)
func (*BaseOperation) Sign ¶
func (op *BaseOperation) Sign(priv base.Privatekey, networkID base.NetworkID) error
func (BaseOperation) Signs ¶
func (op BaseOperation) Signs() []base.Sign
type BaseOperationJSONUnmarshaler ¶
type BaseOperationJSONUnmarshaler struct { Hash valuehash.HashDecoder `json:"hash"` Fact json.RawMessage `json:"fact"` Signs []json.RawMessage `json:"signs"` }
type BaseSignBSONUnmarshaler ¶
type BaseState ¶
type BaseState struct { hint.BaseHinter // contains filtered or unexported fields }
func NewBaseState ¶
func (BaseState) MarshalBSON ¶
func (BaseState) MarshalJSON ¶
func (BaseState) Operations ¶
func (BaseState) Value ¶
func (s BaseState) Value() base.StateValue
type BaseStateMergeValue ¶
type BaseStateMergeValue struct { base.StateValue // contains filtered or unexported fields }
func NewBaseStateMergeValue ¶
func NewBaseStateMergeValue( key string, value base.StateValue, merger func(base.Height, base.State) base.StateValueMerger, ) BaseStateMergeValue
func (BaseStateMergeValue) Key ¶
func (v BaseStateMergeValue) Key() string
func (BaseStateMergeValue) Merger ¶
func (v BaseStateMergeValue) Merger(height base.Height, st base.State) base.StateValueMerger
func (BaseStateMergeValue) Value ¶
func (v BaseStateMergeValue) Value() base.StateValue
type BaseStateValueMerger ¶
func NewBaseStateValueMerger ¶
func (*BaseStateValueMerger) AddOperation ¶
func (s *BaseStateValueMerger) AddOperation(op util.Hash)
func (*BaseStateValueMerger) Close ¶
func (s *BaseStateValueMerger) Close() error
func (*BaseStateValueMerger) CloseValue ¶
func (s *BaseStateValueMerger) CloseValue() (base.State, error)
func (*BaseStateValueMerger) Height ¶
func (s *BaseStateValueMerger) Height() base.Height
func (*BaseStateValueMerger) Key ¶
func (s *BaseStateValueMerger) Key() string
func (*BaseStateValueMerger) Merge ¶
func (s *BaseStateValueMerger) Merge(value base.StateValue, op util.Hash) error
func (*BaseStateValueMerger) SetValue ¶
func (s *BaseStateValueMerger) SetValue(v base.StateValue)
func (*BaseStateValueMerger) State ¶
func (s *BaseStateValueMerger) State() base.State
type Big ¶
func MustBigFromString ¶
func NewBigFromBigInt ¶
func NewBigFromInterface ¶
func NewBigFromString ¶
func (Big) MarshalJSON ¶
func (Big) MulFloat64 ¶
func (*Big) UnmarshalJSON ¶
type Bytes ¶
type Bytes []byte
func NewBytesFromString ¶
func (Bytes) MarshalText ¶
func (*Bytes) UnmarshalText ¶
type ErrMessage ¶
type ErrMessage string
func (ErrMessage) Errorf ¶
func (e ErrMessage) Errorf(format string, args ...interface{}) string
func (ErrMessage) Wrap ¶
func (e ErrMessage) Wrap(s ErrMessage) ErrMessage
type HashDecoder ¶
type HashDecoder struct {
// contains filtered or unexported fields
}
func (HashDecoder) Hash ¶
func (d HashDecoder) Hash() util.Hash
func (*HashDecoder) UnmarshalText ¶
func (d *HashDecoder) UnmarshalText(b []byte) error
type HashGenerator ¶
Click to show internal directories.
Click to hide internal directories.