Documentation
¶
Index ¶
- Variables
- func CalculateDataHash(txx []*Transaction) (hash types.Hash, err error)
- type Account
- type AccountState
- type Block
- type BlockHasher
- type BlockValidator
- type Blockchain
- func (bc *Blockchain) AddBlock(b *Block) error
- func (bc *Blockchain) GetBlock(height uint32) (*Block, error)
- func (bc *Blockchain) GetBlockByHash(hash types.Hash) (*Block, error)
- func (bc *Blockchain) GetHeader(height uint32) (*Header, error)
- func (bc *Blockchain) GetTxByHash(hash types.Hash) (*Transaction, error)
- func (bc *Blockchain) HasBlock(height uint32) bool
- func (bc *Blockchain) Height() uint32
- func (bc *Blockchain) SetValidator(v Validator)
- type CollectionTx
- type Decoder
- type Encoder
- type GobBlockDecoder
- type GobBlockEncoder
- type GobTxDecoder
- type GobTxEncoder
- type Hasher
- type Header
- type Instruction
- type MemoryStore
- type MintTx
- type Stack
- type State
- type Storage
- type Transaction
- type TxHasher
- type TxType
- type VM
- type Validator
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAccountNotFound = errors.New("account not found") ErrInsufficientBalance = errors.New("insufficient account balance") )
View Source
var ErrBlockKnown = errors.New("block already known")
Functions ¶
func CalculateDataHash ¶
func CalculateDataHash(txx []*Transaction) (hash types.Hash, err error)
Types ¶
type AccountState ¶
type AccountState struct {
// contains filtered or unexported fields
}
func NewAccountState ¶
func NewAccountState() *AccountState
func (*AccountState) CreateAccount ¶
func (s *AccountState) CreateAccount(address types.Address) *Account
func (*AccountState) GetAccount ¶
func (s *AccountState) GetAccount(address types.Address) (*Account, error)
func (*AccountState) GetBalance ¶
func (s *AccountState) GetBalance(address types.Address) (uint64, error)
type Block ¶
type Block struct { *Header Transactions []*Transaction Validator crypto.PublicKey Signature *crypto.Signature // contains filtered or unexported fields }
func NewBlockFromPrevHeader ¶
func NewBlockFromPrevHeader(prevHeader *Header, txx []*Transaction) (*Block, error)
func (*Block) AddTransaction ¶
func (b *Block) AddTransaction(tx *Transaction)
type BlockHasher ¶
type BlockHasher struct{}
type BlockValidator ¶
type BlockValidator struct {
// contains filtered or unexported fields
}
func NewBlockValidator ¶
func NewBlockValidator(bc *Blockchain) *BlockValidator
func (*BlockValidator) ValidateBlock ¶
func (v *BlockValidator) ValidateBlock(b *Block) error
type Blockchain ¶
type Blockchain struct {
// contains filtered or unexported fields
}
func NewBlockchain ¶
func NewBlockchain(l log.Logger, genesis *Block) (*Blockchain, error)
func (*Blockchain) AddBlock ¶
func (bc *Blockchain) AddBlock(b *Block) error
func (*Blockchain) GetBlockByHash ¶
func (bc *Blockchain) GetBlockByHash(hash types.Hash) (*Block, error)
func (*Blockchain) GetTxByHash ¶
func (bc *Blockchain) GetTxByHash(hash types.Hash) (*Transaction, error)
func (*Blockchain) HasBlock ¶
func (bc *Blockchain) HasBlock(height uint32) bool
func (*Blockchain) Height ¶
func (bc *Blockchain) Height() uint32
[0, 1, 2 ,3] => 4 len [0, 1, 2 ,3] => 3 height
func (*Blockchain) SetValidator ¶
func (bc *Blockchain) SetValidator(v Validator)
type CollectionTx ¶
type GobBlockDecoder ¶
type GobBlockDecoder struct {
// contains filtered or unexported fields
}
func NewGobBlockDecoder ¶
func NewGobBlockDecoder(r io.Reader) *GobBlockDecoder
func (*GobBlockDecoder) Decode ¶
func (dec *GobBlockDecoder) Decode(b *Block) error
type GobBlockEncoder ¶
type GobBlockEncoder struct {
// contains filtered or unexported fields
}
func NewGobBlockEncoder ¶
func NewGobBlockEncoder(w io.Writer) *GobBlockEncoder
func (*GobBlockEncoder) Encode ¶
func (enc *GobBlockEncoder) Encode(b *Block) error
type GobTxDecoder ¶
type GobTxDecoder struct {
// contains filtered or unexported fields
}
func NewGobTxDecoder ¶
func NewGobTxDecoder(r io.Reader) *GobTxDecoder
func (*GobTxDecoder) Decode ¶
func (e *GobTxDecoder) Decode(tx *Transaction) error
type GobTxEncoder ¶
type GobTxEncoder struct {
// contains filtered or unexported fields
}
func NewGobTxEncoder ¶
func NewGobTxEncoder(w io.Writer) *GobTxEncoder
func (*GobTxEncoder) Encode ¶
func (e *GobTxEncoder) Encode(tx *Transaction) error
type Header ¶
type Instruction ¶
type Instruction byte
const ( InstrPushInt Instruction = 0x0a // 10 InstrAdd Instruction = 0x0b // 11 InstrPushByte Instruction = 0x0c InstrPack Instruction = 0x0d InstrSub Instruction = 0x0e InstrStore Instruction = 0x0f )
type MemoryStore ¶
type MemoryStore struct { }
func NewMemorystore ¶
func NewMemorystore() *MemoryStore
func (*MemoryStore) Put ¶
func (s *MemoryStore) Put(b *Block) error
type Transaction ¶
type Transaction struct { // Only used for native NFT logic TxInner any // Any arbitrary data for the VM Data []byte To crypto.PublicKey Value uint64 From crypto.PublicKey Signature *crypto.Signature Nonce int64 // contains filtered or unexported fields }
func NewTransaction ¶
func NewTransaction(data []byte) *Transaction
func (*Transaction) Decode ¶
func (tx *Transaction) Decode(dec Decoder[*Transaction]) error
func (*Transaction) Encode ¶
func (tx *Transaction) Encode(enc Encoder[*Transaction]) error
func (*Transaction) Hash ¶
func (tx *Transaction) Hash(hasher Hasher[*Transaction]) types.Hash
func (*Transaction) Sign ¶
func (tx *Transaction) Sign(privKey crypto.PrivateKey) error
func (*Transaction) Verify ¶
func (tx *Transaction) Verify() error
Click to show internal directories.
Click to hide internal directories.