Documentation ¶
Index ¶
- type Block
- type BlockHasher
- type BlockValidator
- type Blockchain
- type Decoder
- type Encoder
- type GobTxDecoder
- type GobTxEncoder
- type Hasher
- type Header
- type MemoryStore
- type Storage
- type Transaction
- func (tx *Transaction) Decode(dec Decoder[*Transaction]) (err error)
- func (tx *Transaction) Encode(dec Encoder[*Transaction]) (err error)
- func (tx *Transaction) FirstSeen() int64
- func (tx *Transaction) Hash(hasher Hasher[*Transaction]) types.Hash
- func (tx *Transaction) SetFirstSeen(t int64)
- func (tx *Transaction) Sign(privKey crypto.PrivateKey) error
- func (tx *Transaction) Verify() error
- type TxHasher
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct { *Header Transaction []Transaction Validator crypto.PublicKey Signature *crypto.Signature // contains filtered or unexported fields }
func NewBlock ¶
func NewBlock(h *Header, tx []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) (err 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 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 NewGotTxEncoder ¶
func NewGotTxEncoder(w io.Writer) *GobTxEncoder
func (*GobTxEncoder) Encode ¶
func (e *GobTxEncoder) Encode(tx *Transaction) error
type Header ¶
type MemoryStore ¶
type MemoryStore struct{}
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
func (*MemoryStore) Put ¶
func (m *MemoryStore) Put(b *Block) error
type Transaction ¶
type Transaction struct { Data []byte From crypto.PublicKey Signature *crypto.Signature // contains filtered or unexported fields }
func NewTransaction ¶
func NewTransaction(data []byte) *Transaction
func (*Transaction) Decode ¶
func (tx *Transaction) Decode(dec Decoder[*Transaction]) (err error)
func (*Transaction) Encode ¶
func (tx *Transaction) Encode(dec Encoder[*Transaction]) (err error)
func (*Transaction) FirstSeen ¶
func (tx *Transaction) FirstSeen() int64
func (*Transaction) Hash ¶
func (tx *Transaction) Hash(hasher Hasher[*Transaction]) types.Hash
func (*Transaction) SetFirstSeen ¶
func (tx *Transaction) SetFirstSeen(t int64)
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.