common

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PacketIdentifierTransactionBody = 12338327753349604039
	PacketIdentifierTransaction     = 11306821277700167240
	PacketIdentifierGenesisParams   = 6807263723591883565
	PacketIdentifierGeneralParams   = 13469299839833990814
	PacketIdentifierBlockHeader     = 6888014730382219470
	PacketIdentifierBlock           = 1202114546008698459
	PacketIdentifierDataCommand     = 11594215842612946088
)
View Source
const (
	HashLength = 32
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Header       BlockHeader
	Transactions []Transaction
}

func NewBlock

func NewBlock() Block

func (*Block) BlockHash

func (b *Block) BlockHash() string

BlockHash 获取区块的 hex 格式的区块哈希值

func (*Block) IsGenesisBlock

func (b *Block) IsGenesisBlock() bool

IsGenesisBlock 判断区块是否为创世区块,通过判断前一个区块的哈希值

func (*Block) PacketIdentifier

func (x *Block) PacketIdentifier() PacketIdentifier

func (*Block) PrevBlockHash

func (b *Block) PrevBlockHash() string

PrevBlockHash 获取区块的 hex 格式的前一个区块哈希值

func (*Block) Read

func (x *Block) Read(viewer *BlockViewer, reader *karmem.Reader)

func (*Block) ReadAsRoot

func (x *Block) ReadAsRoot(reader *karmem.Reader)

func (*Block) Reset

func (x *Block) Reset()

func (*Block) Write

func (x *Block) Write(writer *karmem.Writer, start uint) (offset uint, err error)

func (*Block) WriteAsRoot

func (x *Block) WriteAsRoot(writer *karmem.Writer) (offset uint, err error)

type BlockHeader

type BlockHeader struct {
	Timestamp     int64
	PrevBlockHash [32]byte
	BlockHash     [32]byte
	MerkleRoot    [32]byte
	Height        int64
	PublicKey     [33]byte
	Params        []byte
	GasLimit      int64
}

func NewBlockHeader

func NewBlockHeader() BlockHeader

func (*BlockHeader) PacketIdentifier

func (x *BlockHeader) PacketIdentifier() PacketIdentifier

func (*BlockHeader) Read

func (x *BlockHeader) Read(viewer *BlockHeaderViewer, reader *karmem.Reader)

func (*BlockHeader) ReadAsRoot

func (x *BlockHeader) ReadAsRoot(reader *karmem.Reader)

func (*BlockHeader) Reset

func (x *BlockHeader) Reset()

func (*BlockHeader) Write

func (x *BlockHeader) Write(writer *karmem.Writer, start uint) (offset uint, err error)

func (*BlockHeader) WriteAsRoot

func (x *BlockHeader) WriteAsRoot(writer *karmem.Writer) (offset uint, err error)

type BlockHeaderViewer

type BlockHeaderViewer struct {
	// contains filtered or unexported fields
}

func NewBlockHeaderViewer

func NewBlockHeaderViewer(reader *karmem.Reader, offset uint32) (v *BlockHeaderViewer)

func (*BlockHeaderViewer) BlockHash

func (x *BlockHeaderViewer) BlockHash() (v []byte)

func (*BlockHeaderViewer) GasLimit

func (x *BlockHeaderViewer) GasLimit() (v int64)

func (*BlockHeaderViewer) Height

func (x *BlockHeaderViewer) Height() (v int64)

func (*BlockHeaderViewer) MerkleRoot

func (x *BlockHeaderViewer) MerkleRoot() (v []byte)

func (*BlockHeaderViewer) Params

func (x *BlockHeaderViewer) Params(reader *karmem.Reader) (v []byte)

func (*BlockHeaderViewer) PrevBlockHash

func (x *BlockHeaderViewer) PrevBlockHash() (v []byte)

func (*BlockHeaderViewer) PublicKey

func (x *BlockHeaderViewer) PublicKey() (v []byte)

func (*BlockHeaderViewer) Timestamp

func (x *BlockHeaderViewer) Timestamp() (v int64)

type BlockViewer

type BlockViewer struct {
	// contains filtered or unexported fields
}

func NewBlockViewer

func NewBlockViewer(reader *karmem.Reader, offset uint32) (v *BlockViewer)

func (*BlockViewer) Header

func (x *BlockViewer) Header(reader *karmem.Reader) (v *BlockHeaderViewer)

func (*BlockViewer) Transactions

func (x *BlockViewer) Transactions(reader *karmem.Reader) (v []TransactionViewer)

type DataCommand

type DataCommand struct {
	Opt   []byte
	Key   []byte
	Value []byte
}

func NewDataCommand

func NewDataCommand() DataCommand

func (*DataCommand) PacketIdentifier

func (x *DataCommand) PacketIdentifier() PacketIdentifier

func (*DataCommand) Read

func (x *DataCommand) Read(viewer *DataCommandViewer, reader *karmem.Reader)

func (*DataCommand) ReadAsRoot

func (x *DataCommand) ReadAsRoot(reader *karmem.Reader)

func (*DataCommand) Reset

func (x *DataCommand) Reset()

func (*DataCommand) Write

func (x *DataCommand) Write(writer *karmem.Writer, start uint) (offset uint, err error)

func (*DataCommand) WriteAsRoot

func (x *DataCommand) WriteAsRoot(writer *karmem.Writer) (offset uint, err error)

type DataCommandViewer

type DataCommandViewer struct {
	// contains filtered or unexported fields
}

func NewDataCommandViewer

func NewDataCommandViewer(reader *karmem.Reader, offset uint32) (v *DataCommandViewer)

func (*DataCommandViewer) Key

func (x *DataCommandViewer) Key(reader *karmem.Reader) (v []byte)

func (*DataCommandViewer) Opt

func (x *DataCommandViewer) Opt(reader *karmem.Reader) (v []byte)

func (*DataCommandViewer) Value

func (x *DataCommandViewer) Value(reader *karmem.Reader) (v []byte)

type GeneralParams

type GeneralParams struct {
	Result       []byte
	Proof        []byte
	RandomNumber [33]byte
	S            []byte
	T            []byte
}

func NewGeneralParams

func NewGeneralParams() GeneralParams

func (*GeneralParams) PacketIdentifier

func (x *GeneralParams) PacketIdentifier() PacketIdentifier

func (*GeneralParams) Read

func (x *GeneralParams) Read(viewer *GeneralParamsViewer, reader *karmem.Reader)

func (*GeneralParams) ReadAsRoot

func (x *GeneralParams) ReadAsRoot(reader *karmem.Reader)

func (*GeneralParams) Reset

func (x *GeneralParams) Reset()

func (*GeneralParams) Write

func (x *GeneralParams) Write(writer *karmem.Writer, start uint) (offset uint, err error)

func (*GeneralParams) WriteAsRoot

func (x *GeneralParams) WriteAsRoot(writer *karmem.Writer) (offset uint, err error)

type GeneralParamsViewer

type GeneralParamsViewer struct {
	// contains filtered or unexported fields
}

func NewGeneralParamsViewer

func NewGeneralParamsViewer(reader *karmem.Reader, offset uint32) (v *GeneralParamsViewer)

func (*GeneralParamsViewer) Proof

func (x *GeneralParamsViewer) Proof(reader *karmem.Reader) (v []byte)

func (*GeneralParamsViewer) RandomNumber

func (x *GeneralParamsViewer) RandomNumber() (v []byte)

func (*GeneralParamsViewer) Result

func (x *GeneralParamsViewer) Result(reader *karmem.Reader) (v []byte)

func (*GeneralParamsViewer) S

func (x *GeneralParamsViewer) S(reader *karmem.Reader) (v []byte)

func (*GeneralParamsViewer) T

func (x *GeneralParamsViewer) T(reader *karmem.Reader) (v []byte)

type GenesisParams

type GenesisParams struct {
	Order       [128]byte
	TimeParam   int64
	Seed        [32]byte
	VerifyParam [32]byte
}

func NewGenesisParams

func NewGenesisParams() GenesisParams

func (*GenesisParams) PacketIdentifier

func (x *GenesisParams) PacketIdentifier() PacketIdentifier

func (*GenesisParams) Read

func (x *GenesisParams) Read(viewer *GenesisParamsViewer, reader *karmem.Reader)

func (*GenesisParams) ReadAsRoot

func (x *GenesisParams) ReadAsRoot(reader *karmem.Reader)

func (*GenesisParams) Reset

func (x *GenesisParams) Reset()

func (*GenesisParams) Write

func (x *GenesisParams) Write(writer *karmem.Writer, start uint) (offset uint, err error)

func (*GenesisParams) WriteAsRoot

func (x *GenesisParams) WriteAsRoot(writer *karmem.Writer) (offset uint, err error)

type GenesisParamsViewer

type GenesisParamsViewer struct {
	// contains filtered or unexported fields
}

func NewGenesisParamsViewer

func NewGenesisParamsViewer(reader *karmem.Reader, offset uint32) (v *GenesisParamsViewer)

func (*GenesisParamsViewer) Order

func (x *GenesisParamsViewer) Order() (v []byte)

func (*GenesisParamsViewer) Seed

func (x *GenesisParamsViewer) Seed() (v []byte)

func (*GenesisParamsViewer) TimeParam

func (x *GenesisParamsViewer) TimeParam() (v int64)

func (*GenesisParamsViewer) VerifyParam

func (x *GenesisParamsViewer) VerifyParam() (v []byte)

type Hash

type Hash [HashLength]byte

type PacketIdentifier

type PacketIdentifier uint64

type Transaction

type Transaction struct {
	Body TransactionBody
}

func NewTransaction

func NewTransaction() Transaction

func (*Transaction) PacketIdentifier

func (x *Transaction) PacketIdentifier() PacketIdentifier

func (*Transaction) Read

func (x *Transaction) Read(viewer *TransactionViewer, reader *karmem.Reader)

func (*Transaction) ReadAsRoot

func (x *Transaction) ReadAsRoot(reader *karmem.Reader)

func (*Transaction) Reset

func (x *Transaction) Reset()

func (*Transaction) Verify

func (tx *Transaction) Verify() bool

Verify 交易验证方法

func (*Transaction) Write

func (x *Transaction) Write(writer *karmem.Writer, start uint) (offset uint, err error)

func (*Transaction) WriteAsRoot

func (x *Transaction) WriteAsRoot(writer *karmem.Writer) (offset uint, err error)

type TransactionBody

type TransactionBody struct {
	Hash      [32]byte
	Address   [20]byte
	Receiver  [20]byte
	Gas       int64
	Nonce     int64
	Event     []byte
	Opt       []byte
	State     []byte
	Data      []byte
	Expire    int64
	Height    int64
	Index     int64
	BlockHash [32]byte
	Timestamp int64
	Public    [33]byte
	Signature []byte
}

func NewTransactionBody

func NewTransactionBody() TransactionBody

func (*TransactionBody) PacketIdentifier

func (x *TransactionBody) PacketIdentifier() PacketIdentifier

func (*TransactionBody) Read

func (x *TransactionBody) Read(viewer *TransactionBodyViewer, reader *karmem.Reader)

func (*TransactionBody) ReadAsRoot

func (x *TransactionBody) ReadAsRoot(reader *karmem.Reader)

func (*TransactionBody) Reset

func (x *TransactionBody) Reset()

func (*TransactionBody) Write

func (x *TransactionBody) Write(writer *karmem.Writer, start uint) (offset uint, err error)

func (*TransactionBody) WriteAsRoot

func (x *TransactionBody) WriteAsRoot(writer *karmem.Writer) (offset uint, err error)

type TransactionBodyViewer

type TransactionBodyViewer struct {
	// contains filtered or unexported fields
}

func NewTransactionBodyViewer

func NewTransactionBodyViewer(reader *karmem.Reader, offset uint32) (v *TransactionBodyViewer)

func (*TransactionBodyViewer) Address

func (x *TransactionBodyViewer) Address() (v []byte)

func (*TransactionBodyViewer) BlockHash

func (x *TransactionBodyViewer) BlockHash() (v []byte)

func (*TransactionBodyViewer) Data

func (x *TransactionBodyViewer) Data(reader *karmem.Reader) (v []byte)

func (*TransactionBodyViewer) Event

func (x *TransactionBodyViewer) Event(reader *karmem.Reader) (v []byte)

func (*TransactionBodyViewer) Expire

func (x *TransactionBodyViewer) Expire() (v int64)

func (*TransactionBodyViewer) Gas

func (x *TransactionBodyViewer) Gas() (v int64)

func (*TransactionBodyViewer) Hash

func (x *TransactionBodyViewer) Hash() (v []byte)

func (*TransactionBodyViewer) Height

func (x *TransactionBodyViewer) Height() (v int64)

func (*TransactionBodyViewer) Index

func (x *TransactionBodyViewer) Index() (v int64)

func (*TransactionBodyViewer) Nonce

func (x *TransactionBodyViewer) Nonce() (v int64)

func (*TransactionBodyViewer) Opt

func (x *TransactionBodyViewer) Opt(reader *karmem.Reader) (v []byte)

func (*TransactionBodyViewer) Public

func (x *TransactionBodyViewer) Public() (v []byte)

func (*TransactionBodyViewer) Receiver

func (x *TransactionBodyViewer) Receiver() (v []byte)

func (*TransactionBodyViewer) Signature

func (x *TransactionBodyViewer) Signature(reader *karmem.Reader) (v []byte)

func (*TransactionBodyViewer) State

func (x *TransactionBodyViewer) State(reader *karmem.Reader) (v []byte)

func (*TransactionBodyViewer) Timestamp

func (x *TransactionBodyViewer) Timestamp() (v int64)

type TransactionViewer

type TransactionViewer struct {
	// contains filtered or unexported fields
}

func NewTransactionViewer

func NewTransactionViewer(reader *karmem.Reader, offset uint32) (v *TransactionViewer)

func (*TransactionViewer) Body

func (x *TransactionViewer) Body(reader *karmem.Reader) (v *TransactionBodyViewer)

Jump to

Keyboard shortcuts

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