CovenantSQL: github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces Index | Files

package interfaces

import "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"

Package interfaces defines commonly used interfaces for block producers.

Index

Package Files

doc.go mixins.go mixins_gen.go transaction.go transaction_gen.go transaction_wrapper.go

Variables

var (

    // ErrInvalidContainerType represents invalid container type read from msgpack bytes.
    ErrInvalidContainerType = errors.New("invalid container type for TransactionWrapper")
    // ErrInvalidTransactionType represents invalid transaction type read from msgpack bytes.
    ErrInvalidTransactionType = errors.New("invalid transaction type, can not instantiate transaction")
    // ErrTransactionRegistration represents invalid transaction object type being registered.
    ErrTransactionRegistration = errors.New("transaction register failed")
    // ErrMsgPackVersionMismatch represents the msgpack library abi has changed.
    ErrMsgPackVersionMismatch = errors.New("msgpack library version mismatch")
)

func RegisterTransaction Uses

func RegisterTransaction(t TransactionType, tx Transaction)

RegisterTransaction registers transaction type to wrapper.

type AccountNonce Uses

type AccountNonce uint32

AccountNonce defines the an account nonce.

func (AccountNonce) MarshalHash Uses

func (z AccountNonce) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (AccountNonce) Msgsize Uses

func (z AccountNonce) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

type ContainsTransactionTypeMixin Uses

type ContainsTransactionTypeMixin interface {
    SetTransactionType(TransactionType)
}

ContainsTransactionTypeMixin interface defines interface to detect transaction type mixin.

type Transaction Uses

type Transaction interface {
    GetTransactionType() TransactionType
    GetAccountAddress() proto.AccountAddress
    GetAccountNonce() AccountNonce
    GetTimestamp() time.Time
    Hash() hash.Hash
    Sign(signer *asymmetric.PrivateKey) error
    Verify() error
    MarshalHash() ([]byte, error)
    Msgsize() int
}

Transaction is the interface implemented by an object that can be verified and processed by block producers.

func NewTransaction Uses

func NewTransaction(t TransactionType) (tx Transaction, err error)

NewTransaction instantiates new transaction object.

type TransactionState Uses

type TransactionState uint32

TransactionState defines a transaction state.

const (
    TransactionStatePending TransactionState = iota
    TransactionStatePacked
    TransactionStateConfirmed
    TransactionStateExpired
    TransactionStateNotFound
)

Transaction state transition: [o] ---[ Add ]--> Pending ---[ Produce Block ]--> Packed ---[ Irreversible ]--> Confirmed

|                     |                              x
|                     x                              +------[ Prune ]--> Not Found
x                     |
|                     +------------------------------------[ Expire ]--> Expired
|
+----------------------------------------------------------------------> Not Found.

func (TransactionState) MarshalHash Uses

func (z TransactionState) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (TransactionState) Msgsize Uses

func (z TransactionState) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (TransactionState) String Uses

func (s TransactionState) String() string

type TransactionType Uses

type TransactionType uint32

TransactionType defines a transaction type.

const (
    // TransactionTypeDeprecated is a deprecated transaction type, do NOT use it.
    TransactionTypeDeprecated TransactionType = iota
    // TransactionTypeTransfer defines transfer transaction type.
    TransactionTypeTransfer
    // TransactionTypeCreateAccount defines account creation transaction type.
    TransactionTypeCreateAccount
    // TransactionTypeDeleteAccount defines account deletion transaction type.
    TransactionTypeDeleteAccount
    // TransactionTypeAddDatabaseUser defines database user addition transaction type.
    TransactionTypeAddDatabaseUser
    // TransactionTypeAlterDatabaseUser defines database user alteration transaction type.
    TransactionTypeAlterDatabaseUser
    // TransactionTypeDeleteDatabaseUser defines database user deletion transaction type.
    TransactionTypeDeleteDatabaseUser
    // TransactionTypeBaseAccount defines base account transaction type.
    TransactionTypeBaseAccount
    // TransactionTypeCreateDatabase defines database creation transaction type.
    TransactionTypeCreateDatabase
    // TransactionTypeProvideService defines miner providing database service type.
    TransactionTypeProvideService
    // TransactionTypeUpdatePermission defines admin user grant/revoke permission type.
    TransactionTypeUpdatePermission
    // TransactionTypeIssueKeys defines SQLChain owner assign symmetric key.
    TransactionTypeIssueKeys
    // TransactionTypeUpdateBilling defines SQLChain update billing information.
    TransactionTypeUpdateBilling
    // TransactionTypeNumber defines transaction types number.
    TransactionTypeNumber
)

func FromBytes Uses

func FromBytes(b []byte) TransactionType

FromBytes decodes a TransactionType from a byte slice.

func (TransactionType) Bytes Uses

func (t TransactionType) Bytes() (b []byte)

Bytes encodes a TransactionType to a byte slice.

func (TransactionType) MarshalHash Uses

func (z TransactionType) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (TransactionType) Msgsize Uses

func (z TransactionType) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (TransactionType) String Uses

func (t TransactionType) String() string

type TransactionTypeMixin Uses

type TransactionTypeMixin struct {
    TxType    TransactionType
    Timestamp time.Time
}

TransactionTypeMixin provide type heuristic features to transaction wrapper.

func NewTransactionTypeMixin Uses

func NewTransactionTypeMixin(txType TransactionType) *TransactionTypeMixin

NewTransactionTypeMixin returns new instance.

func (*TransactionTypeMixin) GetTimestamp Uses

func (m *TransactionTypeMixin) GetTimestamp() time.Time

GetTimestamp implements Transaciton.GetTimestamp().

func (*TransactionTypeMixin) GetTransactionType Uses

func (m *TransactionTypeMixin) GetTransactionType() TransactionType

GetTransactionType implements Transaction.GetTransactionType.

func (*TransactionTypeMixin) MarshalHash Uses

func (z *TransactionTypeMixin) MarshalHash() (o []byte, err error)

MarshalHash marshals for hash

func (*TransactionTypeMixin) Msgsize Uses

func (z *TransactionTypeMixin) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*TransactionTypeMixin) SetTimestamp Uses

func (m *TransactionTypeMixin) SetTimestamp(t time.Time)

SetTimestamp is a helper function for derived types.

func (*TransactionTypeMixin) SetTransactionType Uses

func (m *TransactionTypeMixin) SetTransactionType(t TransactionType)

SetTransactionType is a helper function for derived types.

type TransactionWrapper Uses

type TransactionWrapper struct {
    Transaction
}

TransactionWrapper is the wrapper for Transaction interface for serialization/deserialization purpose.

func WrapTransaction Uses

func WrapTransaction(tx Transaction) *TransactionWrapper

WrapTransaction wraps transaction in wrapper.

func (*TransactionWrapper) CodecDecodeSelf Uses

func (w *TransactionWrapper) CodecDecodeSelf(d *codec.Decoder)

CodecDecodeSelf implements codec.Selfer interface.

func (*TransactionWrapper) CodecEncodeSelf Uses

func (w *TransactionWrapper) CodecEncodeSelf(e *codec.Encoder)

CodecEncodeSelf implements codec.Selfer interface.

func (TransactionWrapper) MarshalJSON Uses

func (w TransactionWrapper) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*TransactionWrapper) UnmarshalJSON Uses

func (w *TransactionWrapper) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements json.Unmarshaler interface.

func (*TransactionWrapper) Unwrap Uses

func (w *TransactionWrapper) Unwrap() Transaction

Unwrap returns transaction within wrapper.

Package interfaces imports 12 packages (graph) and is imported by 8 packages. Updated 2019-04-11. Refresh now. Tools for package owners.