Documentation
¶
Index ¶
- type Block
- func (b *Block) AddTransaction(tx *Transaction)
- func (b *Block) Decode(r io.Reader, dec Decoder[*Block]) error
- func (b *Block) Encode(w io.Writer, enc Encoder[*Block]) error
- func (b *Block) Hash(hasher Hasher[*Header]) types.Hash
- func (b *Block) Sign(privKey crypto.PrivateKey) error
- func (b *Block) Verify() error
- type BlockHasher
- type BlockValidator
- type Blockchain
- type Decoder
- type Encoder
- type Hasher
- type Header
- type MemoryStore
- type Storage
- type Transaction
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct { *Header Transactions []Transaction Validator crypto.PublicKey Signature *crypto.Signature // contains filtered or unexported fields }
func NewBlock ¶
func NewBlock(h *Header, txs []Transaction) *Block
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(genesis *Block) (*Blockchain, error)
func (*Blockchain) AddBlock ¶
func (bc *Blockchain) AddBlock(b *Block) error
func (*Blockchain) HasBlock ¶
func (bc *Blockchain) HasBlock(height uint32) bool
func (*Blockchain) Height ¶
func (bc *Blockchain) Height() uint32
func (*Blockchain) SetValidator ¶
func (bc *Blockchain) SetValidator(v Validator)
type Header ¶
type MemoryStore ¶
type MemoryStore struct { }
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
func (*MemoryStore) Put ¶
func (s *MemoryStore) Put(b *Block) error
type Transaction ¶
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.