Documentation
¶
Index ¶
- func CalculateDataHash(txx []*Transaction) (hash common.Hash, err error)
- func RandomBytes(size int) []byte
- func RandomHash() common.Hash
- type Account
- type Block
- func NewBlock(h *Header, txs []*Transaction) (*Block, error)
- func NewBlockFromPrevHeader(prevHeader *Header, txs []*Transaction) (*Block, error)
- func NewRandomBlock(t *testing.T, height int32, prevBlockHash common.Hash) *Block
- func NewRandomBlockWithSignature(t *testing.T, pk PrivateKey, height int32, prevHash common.Hash) *Block
- type BlockHasher
- type Decoder
- type Encoder
- type GobAccountDecoder
- type GobAccountEncoder
- type GobBlockDecoder
- type GobBlockEncoder
- type GobHeaderDecoder
- type GobHeaderEncoder
- type GobPrivateKeyDecoder
- type GobPrivateKeyEncoder
- type GobTxDecoder
- type GobTxEncoder
- type Hasher
- type Header
- type PrivateKey
- type PublicKey
- type Signature
- type Transaction
- func CreateSignedTransaction(nonce uint64, from common.Address, to common.Address, value uint64, ...) *Transaction
- func CreateTransaction(nonce uint64, from common.Address, to common.Address, value uint64, ...) *Transaction
- func NewRandomTransaction(privateKey *PrivateKey) *Transaction
- func NewRandomTransactionWithSignature(t *testing.T, privateKey *PrivateKey, size int) *Transaction
- type TxHasher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateDataHash ¶
func CalculateDataHash(txx []*Transaction) (hash common.Hash, err error)
func RandomBytes ¶
func RandomHash ¶
Types ¶
type Block ¶
type Block struct { *Header Transactions []*Transaction Signer PublicKey Signature *Signature Extra string // Cached version of the header hash Hash common.Hash }
func NewBlockFromPrevHeader ¶
func NewBlockFromPrevHeader(prevHeader *Header, txs []*Transaction) (*Block, error)
func NewRandomBlock ¶
func (*Block) AddTransaction ¶
func (b *Block) AddTransaction(tx *Transaction)
func (*Block) Sign ¶
func (b *Block) Sign(privateKey PrivateKey) error
type BlockHasher ¶
type BlockHasher struct{}
type GobAccountDecoder ¶
type GobAccountDecoder struct {
// contains filtered or unexported fields
}
func NewGobAccountDecoder ¶
func NewGobAccountDecoder(r io.Reader) *GobAccountDecoder
func (*GobAccountDecoder) Decode ¶
func (dec *GobAccountDecoder) Decode(a *Account) error
type GobAccountEncoder ¶
type GobAccountEncoder struct {
// contains filtered or unexported fields
}
func NewGobAccountEncoder ¶
func NewGobAccountEncoder(w io.Writer) *GobAccountEncoder
func (*GobAccountEncoder) Encode ¶
func (enc *GobAccountEncoder) Encode(a *Account) error
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 GobHeaderDecoder ¶
type GobHeaderDecoder struct {
// contains filtered or unexported fields
}
func NewGobHeaderDecoder ¶
func NewGobHeaderDecoder(r io.Reader) *GobHeaderDecoder
func (*GobHeaderDecoder) Decode ¶
func (dec *GobHeaderDecoder) Decode(h *Header) error
type GobHeaderEncoder ¶
type GobHeaderEncoder struct {
// contains filtered or unexported fields
}
func NewGobHeaderEncoder ¶
func NewGobHeaderEncoder(w io.Writer) *GobHeaderEncoder
func (*GobHeaderEncoder) Encode ¶
func (enc *GobHeaderEncoder) Encode(h *Header) error
type GobPrivateKeyDecoder ¶
type GobPrivateKeyDecoder struct {
// contains filtered or unexported fields
}
func NewGobPrivateKeyDecoder ¶
func NewGobPrivateKeyDecoder(r io.Reader) *GobPrivateKeyDecoder
func (*GobPrivateKeyDecoder) Decode ¶
func (dec *GobPrivateKeyDecoder) Decode(key *PrivateKey) error
type GobPrivateKeyEncoder ¶
type GobPrivateKeyEncoder struct {
// contains filtered or unexported fields
}
func NewGobPrivateKeyEncoder ¶
func NewGobPrivateKeyEncoder(w io.Writer) *GobPrivateKeyEncoder
func (*GobPrivateKeyEncoder) Encode ¶
func (enc *GobPrivateKeyEncoder) Encode(key *PrivateKey) 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 PrivateKey ¶
type PrivateKey struct { Key *ecdsa.PrivateKey PublicKey PublicKey }
func CreatePrivateKey ¶
func CreatePrivateKey(hexKey string) (*PrivateKey, error)
func GeneratePrivateKey ¶
func GeneratePrivateKey() *PrivateKey
func NewPrivateKeyFromReader ¶
func NewPrivateKeyFromReader(r io.Reader) *PrivateKey
func (*PrivateKey) Decode ¶
func (k *PrivateKey) Decode(dec Decoder[*PrivateKey]) error
func (*PrivateKey) Encode ¶
func (k *PrivateKey) Encode(enc Encoder[*PrivateKey]) error
type Transaction ¶
type Transaction struct { Nonce uint64 BlockHeight int32 Timestamp int64 From common.Address To common.Address Value uint64 Data []byte Signer PublicKey Signature *Signature Hash common.Hash }
func CreateSignedTransaction ¶
func CreateTransaction ¶
func NewRandomTransaction ¶
func NewRandomTransaction(privateKey *PrivateKey) *Transaction
NewRandomTransaction return a new random transaction whithout signature.
func NewRandomTransactionWithSignature ¶
func NewRandomTransactionWithSignature(t *testing.T, privateKey *PrivateKey, size int) *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) GetHash ¶
func (tx *Transaction) GetHash() common.Hash
func (*Transaction) Sign ¶
func (tx *Transaction) Sign(privateKey *PrivateKey) error
func (*Transaction) Verify ¶
func (tx *Transaction) Verify() error
Click to show internal directories.
Click to hide internal directories.