Documentation ¶
Index ¶
- type BlockHeaderList
- type BlockStore
- type Chain
- func (c *Chain) AddBlock(block *genproto.Block) error
- func (c *Chain) GetBlockByHash(hash []byte) (*genproto.Block, error)
- func (c *Chain) GetBlockByHeight(height int) (*genproto.Block, error)
- func (c *Chain) Height() int
- func (c *Chain) ValidateBlock(block *genproto.Block) error
- func (c *Chain) ValidateTransaction(tx *genproto.Transaction) error
- type ConnectedPeer
- type MemoryBlockStore
- type MemoryTxStore
- type MemoryUTXOStore
- type Mempool
- type Node
- type NodeConfig
- type TxStore
- type UTXO
- type UTXOStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockHeaderList ¶
type BlockHeaderList struct {
// contains filtered or unexported fields
}
func NewBlockHeaderList ¶
func NewBlockHeaderList() *BlockHeaderList
func (*BlockHeaderList) Add ¶
func (hs *BlockHeaderList) Add(h *genproto.BlockHeader)
func (*BlockHeaderList) Get ¶
func (hs *BlockHeaderList) Get(height int) *genproto.BlockHeader
func (*BlockHeaderList) Height ¶
func (hs *BlockHeaderList) Height() int
type BlockStore ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
func (*Chain) GetBlockByHeight ¶
func (*Chain) ValidateTransaction ¶
func (c *Chain) ValidateTransaction(tx *genproto.Transaction) error
type ConnectedPeer ¶
type ConnectedPeer struct {
// contains filtered or unexported fields
}
type MemoryBlockStore ¶
func NewMemoryBlockStore ¶
func NewMemoryBlockStore() *MemoryBlockStore
type MemoryTxStore ¶
func NewMemoryTxStore ¶
func NewMemoryTxStore() *MemoryTxStore
func (*MemoryTxStore) Get ¶
func (s *MemoryTxStore) Get(hash string) (*genproto.Transaction, error)
func (*MemoryTxStore) Put ¶
func (s *MemoryTxStore) Put(tx *genproto.Transaction) error
type MemoryUTXOStore ¶
func NewMemoryUTXOStore ¶
func NewMemoryUTXOStore() *MemoryUTXOStore
func (*MemoryUTXOStore) Put ¶
func (s *MemoryUTXOStore) Put(utxo *UTXO) error
type Mempool ¶
func NewMempool ¶
func NewMempool() *Mempool
func (*Mempool) Clear ¶
func (p *Mempool) Clear() []*genproto.Transaction
type Node ¶
type Node struct { genproto.UnimplementedNodeServer NodeConfig // contains filtered or unexported fields }
func NewNode ¶
func NewNode(config NodeConfig, chain *Chain) *Node
func (*Node) HandleTransaction ¶
func (*Node) Handshake ¶
func (n *Node) Handshake(ctx context.Context, peerNodeInfo *genproto.NodeInfo) (*genproto.NodeInfo, error)
Handshake is called when a new peer node connects to the current node. It exchanges node information with the peer node and adds the peer to the list of connected peers.
If there is an error creating the client connection to the peer node, the function will return an error.
type NodeConfig ¶
type NodeConfig struct { Version string ListenAddr string PrivateKey *cryptography.PrivateKey }
type TxStore ¶
type TxStore interface { Get(hash string) (*genproto.Transaction, error) Put(*genproto.Transaction) error }
type UTXO ¶
type UTXO struct { Hash string // OutIndex is an index of the output in the transaction OutIndex int Amount int64 // Every UTXO is considered “unspent” until it is used as an input in a new transaction. // Once it is used, it is no longer a valid UTXO. The blockchain tracks all UTXOs to know what funds are available to be spent. IsSpent bool }
Click to show internal directories.
Click to hide internal directories.