Documentation ¶
Index ¶
- type Block
- type Blockchain
- func (bc *Blockchain) AddBlock(block Block) error
- func (bc *Blockchain) AddTx(tx Transaction) (Transaction, error)
- func (bc *Blockchain) CreateGenesisBlock()
- func (bc *Blockchain) NewBlock() (Block, error)
- func (bc *Blockchain) RemoveTx(tx Transaction)
- func (bc *Blockchain) RemoveTxs(txs []Transaction)
- type Node
- type Transaction
- type TransactionBody
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct { Idx int64 `json:"idx"` Timestamp int64 `json:"timestamp"` Txs []Transaction `json:"txs"` PrevHash []byte `json:"prevHash"` Nonce int64 `json:"nonce"` }
func (*Block) HasTx ¶
func (b *Block) HasTx(tx Transaction) bool
type Blockchain ¶
type Blockchain struct { Blocks []Block `json:"block"` TxPool []Transaction `json:"txPool"` }
func NewBlockchain ¶
func NewBlockchain() *Blockchain
func (*Blockchain) AddBlock ¶
func (bc *Blockchain) AddBlock(block Block) error
func (*Blockchain) AddTx ¶
func (bc *Blockchain) AddTx(tx Transaction) (Transaction, error)
func (*Blockchain) CreateGenesisBlock ¶
func (bc *Blockchain) CreateGenesisBlock()
func (*Blockchain) NewBlock ¶
func (bc *Blockchain) NewBlock() (Block, error)
func (*Blockchain) RemoveTx ¶
func (bc *Blockchain) RemoveTx(tx Transaction)
func (*Blockchain) RemoveTxs ¶
func (bc *Blockchain) RemoveTxs(txs []Transaction)
type Transaction ¶
type Transaction struct { Id string `json:"id"` Timestamp int64 `json:"timestamp"` Body TransactionBody `json:"body"` Signature string `json:"signature"` }
func NewTransaction ¶
func (Transaction) GetBodyHash ¶
func (tx Transaction) GetBodyHash() ([]byte, error)
func (Transaction) IsCoinbase ¶
func (tx Transaction) IsCoinbase() bool
type TransactionBody ¶
Click to show internal directories.
Click to hide internal directories.