types

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InvalidBlockSize int = -1
)
View Source
const (
	InvalidTransactionSize = -1
)

Variables

This section is empty.

Functions

func IsValidAttributeType

func IsValidAttributeType(usage AttributeUsage) bool

Types

type Attribute

type Attribute struct {
	Usage AttributeUsage
	Data  []byte
}

func NewAttribute

func NewAttribute(u AttributeUsage, d []byte) Attribute

func (*Attribute) Deserialize

func (attr *Attribute) Deserialize(r io.Reader) error

func (*Attribute) Serialize

func (attr *Attribute) Serialize(w io.Writer) error

func (Attribute) String

func (attr Attribute) String() string

type AttributeUsage

type AttributeUsage byte
const (
	Nonce          AttributeUsage = 0x00
	Script         AttributeUsage = 0x20
	Memo           AttributeUsage = 0x81
	Description    AttributeUsage = 0x90
	DescriptionUrl AttributeUsage = 0x91
	Confirmations  AttributeUsage = 0x92
)

func (AttributeUsage) Name

func (it AttributeUsage) Name() string

type Block

type Block struct {
	Header
	Transactions []*Transaction
}

func (*Block) Deserialize

func (b *Block) Deserialize(r io.Reader) error

func (*Block) DeserializeTxLoc added in v0.5.0

func (b *Block) DeserializeTxLoc(r *bytes.Buffer) ([]TxLoc, error)

DeserializeTxLoc decodes r in the same manner Deserialize does, but it takes a byte buffer instead of a generic reader and returns a slice containing the start and length of each transaction within the raw data that is being deserialized.

func (*Block) GetSize

func (b *Block) GetSize() int

func (*Block) Hash

func (b *Block) Hash() common.Uint256

func (*Block) Serialize

func (b *Block) Serialize(w io.Writer) error

func (*Block) SerializeSizeStripped added in v0.5.0

func (b *Block) SerializeSizeStripped() int

SerializeSizeStripped returns the number of bytes it would take to serialize the block, excluding any witness data (if any).

func (*Block) TxLoc added in v0.5.0

func (b *Block) TxLoc() ([]TxLoc, error)

TxLoc returns the offsets and lengths of each transaction in a raw block. It is used to allow fast indexing into transactions within the raw byte stream.

type DPOSHeader added in v0.3.0

type DPOSHeader struct {
	Header
	HaveConfirm bool
	payload.Confirm
}

DPOSHeader represents a POW header + DPOS confirm

func (*DPOSHeader) Deserialize added in v0.3.0

func (h *DPOSHeader) Deserialize(r io.Reader) error

func (*DPOSHeader) Serialize added in v0.3.0

func (h *DPOSHeader) Serialize(w io.Writer) error

type DposBlock

type DposBlock struct {
	*Block
	HaveConfirm bool
	Confirm     *payload.Confirm
}

func (*DposBlock) Deserialize

func (b *DposBlock) Deserialize(r io.Reader) error

func (*DposBlock) Serialize

func (b *DposBlock) Serialize(w io.Writer) error
type Header struct {
	Version    uint32
	Previous   common.Uint256
	MerkleRoot common.Uint256
	Timestamp  uint32
	Bits       uint32
	Nonce      uint32
	Height     uint32
	AuxPow     auxpow.AuxPow
}

func (*Header) Deserialize

func (header *Header) Deserialize(r io.Reader) error

func (*Header) DeserializeNoAux added in v0.5.0

func (header *Header) DeserializeNoAux(r io.Reader) error

func (*Header) GetSize added in v0.5.0

func (header *Header) GetSize() int

func (*Header) Hash

func (header *Header) Hash() common.Uint256

func (*Header) Serialize

func (header *Header) Serialize(w io.Writer) error

func (*Header) SerializeNoAux added in v0.5.0

func (header *Header) SerializeNoAux(w io.Writer) error

type Input

type Input struct {
	// Reference outpoint of this input
	Previous OutPoint

	// Sequence number
	Sequence uint32
}

func (*Input) Deserialize

func (i *Input) Deserialize(r io.Reader) error

func (*Input) IsEqual

func (i *Input) IsEqual(o Input) bool

func (*Input) ReferKey

func (i *Input) ReferKey() string

func (*Input) Serialize

func (i *Input) Serialize(w io.Writer) error

func (Input) String

func (i Input) String() string

type OutPoint

type OutPoint struct {
	TxID  common.Uint256
	Index uint16
}

func NewOutPoint

func NewOutPoint(txID common.Uint256, index uint16) *OutPoint

func OutPointFromBytes

func OutPointFromBytes(value []byte) (*OutPoint, error)

func (*OutPoint) Bytes

func (op *OutPoint) Bytes() []byte

func (*OutPoint) Deserialize

func (op *OutPoint) Deserialize(r io.Reader) error

func (*OutPoint) IsEqual

func (op *OutPoint) IsEqual(o OutPoint) bool

func (*OutPoint) ReferKey added in v0.3.0

func (op *OutPoint) ReferKey() string

func (*OutPoint) Serialize

func (op *OutPoint) Serialize(w io.Writer) error

type Output

type Output struct {
	AssetID     common.Uint256
	Value       common.Fixed64
	OutputLock  uint32
	ProgramHash common.Uint168
	Type        OutputType
	Payload     OutputPayload
}

func (*Output) Deserialize

func (o *Output) Deserialize(r io.Reader, txVersion TransactionVersion) error

func (*Output) Serialize

func (o *Output) Serialize(w io.Writer, txVersion TransactionVersion) error

func (*Output) String

func (o *Output) String() string

type OutputInfo added in v0.7.0

type OutputInfo struct {
	Recipient common.Uint168
	Amount    common.Fixed64
}

func (*OutputInfo) Deserialize added in v0.7.0

func (o *OutputInfo) Deserialize(r io.Reader) (err error)

func (*OutputInfo) Serialize added in v0.7.0

func (o *OutputInfo) Serialize(w io.Writer) (err error)

type OutputPayload

type OutputPayload interface {
	// Get payload data
	Data() []byte
	Serialize(w io.Writer) error
	Deserialize(r io.Reader) error
	GetVersion() byte
	Validate() error
}

type OutputType

type OutputType byte

OutputType represents the type of a output payload.

const (
	// OTNone indicates there is no payload for this output.
	OTNone OutputType = iota

	// OTVote indicates the output payload is a vote.
	OTVote

	// OTMapping indicates the output payload is a mapping.
	OTMapping
)

type Payload

type Payload interface {
	// Get payload data
	Data(version byte) []byte

	Serialize(w io.Writer, version byte) error

	Deserialize(r io.Reader, version byte) error
}

Payload define the func for loading the payload data base on payload type which have different structure

func GetPayload

func GetPayload(txType TxType) (Payload, error)

type Transaction

type Transaction struct {
	Version        TransactionVersion // New field added in TxVersion09
	TxType         TxType
	PayloadVersion byte
	Payload        Payload
	Attributes     []*Attribute
	Inputs         []*Input
	Outputs        []*Output
	LockTime       uint32
	Programs       []*pg.Program
	Fee            common.Fixed64
	FeePerKB       common.Fixed64
	// contains filtered or unexported fields
}

func (*Transaction) Deserialize

func (tx *Transaction) Deserialize(r io.Reader) error

Deserialize the Transaction

func (*Transaction) DeserializeUnsigned

func (tx *Transaction) DeserializeUnsigned(r io.Reader) error

func (*Transaction) GetSize

func (tx *Transaction) GetSize() int

func (*Transaction) GetSpecialTxHash added in v0.7.0

func (tx *Transaction) GetSpecialTxHash() (common.Uint256, error)

func (*Transaction) Hash

func (tx *Transaction) Hash() common.Uint256

func (*Transaction) ISCRCouncilMemberClaimNode added in v0.7.0

func (tx *Transaction) ISCRCouncilMemberClaimNode() bool

func (*Transaction) IsActivateProducerTx added in v0.3.0

func (tx *Transaction) IsActivateProducerTx() bool

func (*Transaction) IsCRAssetsRectifyTx added in v0.7.0

func (tx *Transaction) IsCRAssetsRectifyTx() bool

func (*Transaction) IsCRCAppropriationTx added in v0.5.0

func (tx *Transaction) IsCRCAppropriationTx() bool

func (*Transaction) IsCRCProposalRealWithdrawTx added in v0.7.0

func (tx *Transaction) IsCRCProposalRealWithdrawTx() bool

func (*Transaction) IsCRCProposalReviewTx added in v0.7.0

func (tx *Transaction) IsCRCProposalReviewTx() bool

func (*Transaction) IsCRCProposalTrackingTx added in v0.7.0

func (tx *Transaction) IsCRCProposalTrackingTx() bool

func (*Transaction) IsCRCProposalTx added in v0.5.0

func (tx *Transaction) IsCRCProposalTx() bool

func (*Transaction) IsCRCProposalWithdrawTx added in v0.5.0

func (tx *Transaction) IsCRCProposalWithdrawTx() bool

func (*Transaction) IsCancelProducerTx

func (tx *Transaction) IsCancelProducerTx() bool

func (*Transaction) IsCoinBaseTx

func (tx *Transaction) IsCoinBaseTx() bool

func (*Transaction) IsCustomIDRelatedTx added in v0.7.0

func (tx *Transaction) IsCustomIDRelatedTx() bool

func (*Transaction) IsCustomIDResultTx added in v0.7.0

func (tx *Transaction) IsCustomIDResultTx() bool

func (*Transaction) IsIllegalBlockTx

func (tx *Transaction) IsIllegalBlockTx() bool

func (*Transaction) IsIllegalProposalTx

func (tx *Transaction) IsIllegalProposalTx() bool

func (*Transaction) IsIllegalTypeTx added in v0.3.0

func (tx *Transaction) IsIllegalTypeTx() bool

func (*Transaction) IsIllegalVoteTx

func (tx *Transaction) IsIllegalVoteTx() bool

func (*Transaction) IsInactiveArbitrators added in v0.3.0

func (tx *Transaction) IsInactiveArbitrators() bool

func (*Transaction) IsNewSideChainPowTx added in v0.3.2

func (tx *Transaction) IsNewSideChainPowTx() bool

func (*Transaction) IsNextTurnDPOSInfoTx added in v0.7.0

func (tx *Transaction) IsNextTurnDPOSInfoTx() bool

func (*Transaction) IsProducerRelatedTx added in v0.3.2

func (tx *Transaction) IsProducerRelatedTx() bool

func (*Transaction) IsRechargeToSideChainTx

func (tx *Transaction) IsRechargeToSideChainTx() bool

func (*Transaction) IsRegisterCRTx added in v0.5.0

func (tx *Transaction) IsRegisterCRTx() bool

func (*Transaction) IsRegisterProducerTx

func (tx *Transaction) IsRegisterProducerTx() bool

func (*Transaction) IsReturnCRDepositCoinTx added in v0.5.0

func (tx *Transaction) IsReturnCRDepositCoinTx() bool

func (*Transaction) IsReturnDepositCoin

func (tx *Transaction) IsReturnDepositCoin() bool

func (*Transaction) IsRevertToDPOS added in v0.7.0

func (tx *Transaction) IsRevertToDPOS() bool

func (*Transaction) IsRevertToPOW added in v0.7.0

func (tx *Transaction) IsRevertToPOW() bool

func (*Transaction) IsSideChainPowTx

func (tx *Transaction) IsSideChainPowTx() bool

func (*Transaction) IsSidechainIllegalDataTx added in v0.3.0

func (tx *Transaction) IsSidechainIllegalDataTx() bool

func (*Transaction) IsSpecialTx added in v0.7.0

func (tx *Transaction) IsSpecialTx() bool

special tx is this kind of tx who have no input and output

func (*Transaction) IsTransferCrossChainAssetTx

func (tx *Transaction) IsTransferCrossChainAssetTx() bool

func (*Transaction) IsUnregisterCRTx added in v0.5.0

func (tx *Transaction) IsUnregisterCRTx() bool

func (*Transaction) IsUpdateCRTx added in v0.5.0

func (tx *Transaction) IsUpdateCRTx() bool

func (*Transaction) IsUpdateProducerTx

func (tx *Transaction) IsUpdateProducerTx() bool

func (*Transaction) IsUpdateVersion added in v0.3.2

func (tx *Transaction) IsUpdateVersion() bool

func (*Transaction) IsWithdrawFromSideChainTx

func (tx *Transaction) IsWithdrawFromSideChainTx() bool

func (*Transaction) Serialize

func (tx *Transaction) Serialize(w io.Writer) error

Serialize the Transaction

func (*Transaction) SerializeSizeStripped added in v0.5.0

func (tx *Transaction) SerializeSizeStripped() int

SerializeSizeStripped returns the number of bytes it would take to serialize the block, excluding any witness data (if any).

func (*Transaction) SerializeUnsigned

func (tx *Transaction) SerializeUnsigned(w io.Writer) error

Serialize the Transaction data without contracts

func (*Transaction) String

func (tx *Transaction) String() string

type TransactionVersion

type TransactionVersion byte
const (
	TxVersionDefault TransactionVersion = 0x00
	TxVersion09      TransactionVersion = 0x09
)

type TxLoc added in v0.5.0

type TxLoc struct {
	TxStart int
	TxLen   int
}

TxLoc holds locator data for the offset and length of where a transaction is located within a MsgBlock data buffer.

type TxType added in v0.3.0

type TxType byte

TxType represents different transaction types with different payload format. The TxType range is 0x00 - 0x08. When it is greater than 0x08 it will be interpreted as a TransactionVersion.

const (
	CoinBase                TxType = 0x00
	RegisterAsset           TxType = 0x01
	TransferAsset           TxType = 0x02
	Record                  TxType = 0x03
	Deploy                  TxType = 0x04
	SideChainPow            TxType = 0x05
	RechargeToSideChain     TxType = 0x06
	WithdrawFromSideChain   TxType = 0x07
	TransferCrossChainAsset TxType = 0x08

	RegisterProducer  TxType = 0x09
	CancelProducer    TxType = 0x0a
	UpdateProducer    TxType = 0x0b
	ReturnDepositCoin TxType = 0x0c
	ActivateProducer  TxType = 0x0d

	IllegalProposalEvidence  TxType = 0x0e
	IllegalVoteEvidence      TxType = 0x0f
	IllegalBlockEvidence     TxType = 0x10
	IllegalSidechainEvidence TxType = 0x11
	InactiveArbitrators      TxType = 0x12
	UpdateVersion            TxType = 0x13
	NextTurnDPOSInfo         TxType = 0x14
	CustomIDResult           TxType = 0x15

	RegisterCR          TxType = 0x21
	UnregisterCR        TxType = 0x22
	UpdateCR            TxType = 0x23
	ReturnCRDepositCoin TxType = 0x24

	CRCProposal              TxType = 0x25
	CRCProposalReview        TxType = 0x26
	CRCProposalTracking      TxType = 0x27
	CRCAppropriation         TxType = 0x28
	CRCProposalWithdraw      TxType = 0x29
	CRCProposalRealWithdraw  TxType = 0x2a
	CRAssetsRectify          TxType = 0x2b
	CRCouncilMemberClaimNode TxType = 0x31

	RevertToPOW  TxType = 0x41
	RevertToDPOS TxType = 0x42
)

func (TxType) Name added in v0.3.0

func (self TxType) Name() string

type UTXO added in v0.5.0

type UTXO struct {
	TxID  common.Uint256
	Index uint16
	Value common.Fixed64
}

func (*UTXO) Deserialize added in v0.5.0

func (u *UTXO) Deserialize(r io.Reader) error

func (*UTXO) Hash added in v0.5.0

func (u *UTXO) Hash() common.Uint256

func (*UTXO) Serialize added in v0.5.0

func (u *UTXO) Serialize(w io.Writer) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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