Versions in this module Expand all Collapse all v1 v1.0.0 Jan 27, 2025 Changes in this version + func CalculateDataHash(txx []Transaction) (hash types.Hash, err error) + type Block struct + Signature *crypto.Signature + Transactions []Transaction + Validator crypto.PublicKey + func NewBlock(h *Header, tsc []Transaction) (*Block, error) + func NewBlockFromHeader(prevHeader *Header, txx []Transaction) (*Block, error) + func (b *Block) AddTransaction(tx *Transaction) + func (b *Block) Decode(dec Decoder[*Block]) error + func (b *Block) Encode(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 BlockChain struct + Headers []*Header + Lock sync.RWMutex + Store Storage + Validator Validator + func NewBlockChain(genesis *Block) (*BlockChain, error) + func (bc *BlockChain) AddBlock(b *Block) error + func (bc *BlockChain) GetHeader(height uint32) (*Header, error) + func (bc *BlockChain) HasBlock(heigh uint32) bool + func (bc *BlockChain) Height() uint32 + func (bc *BlockChain) SetValidator(v Validator) + type BlockHasher struct + func (BlockHasher) Hash(b *Header) types.Hash + type BlockValidator struct + Bc *BlockChain + func NewBlockValidator(bc *BlockChain) *BlockValidator + func (v *BlockValidator) ValidateBlock(b *Block) error + type Decoder interface + Decode func(T) error + type Encoder interface + Encode func(T) error + type GobTxDecoder struct + R io.Reader + func NewGobDecoder(r io.Reader) *GobTxDecoder + func (d *GobTxDecoder) Decode(tx *Transaction) error + type GobTxEncoder struct + W io.Writer + func NewGobEncoder(w io.Writer) *GobTxEncoder + func (e *GobTxEncoder) Encode(tx *Transaction) error + type Hasher interface + Hash func(T) types.Hash + type Header struct + DataHash types.Hash + Height uint32 + PrevBlockHash types.Hash + Timestamp uint64 + Version uint32 + func (h *Header) Bytes() []byte + type MemoryStore struct + func NewMemStore() *MemoryStore + func (ms *MemoryStore) Put(b *Block) error + type Storage interface + Put func(*Block) error + type Transaction struct + CacheHash types.Hash + Data []byte + FirstSeen int64 + From crypto.PublicKey + Signature *crypto.Signature + func NewTransaction(data []byte) *Transaction + func (tx *Transaction) Decode(dec Decoder[*Transaction]) error + func (tx *Transaction) Encode(enc Encoder[*Transaction]) error + func (tx *Transaction) GetFirstSeen() int64 + func (tx *Transaction) Hash(h 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 struct + func (TxHasher) Hash(tx *Transaction) types.Hash + type Validator interface + ValidateBlock func(*Block) error