Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Api ¶
type Api struct {
// contains filtered or unexported fields
}
Api runs the HTTP API for interacting with the node
type BlockCache ¶
BlockCache is a synchronized cache for blocks
func (*BlockCache) AddBlock ¶
func (b *BlockCache) AddBlock(block blockchain.Block)
AddBlock adds a block to the cache
func (*BlockCache) ReadBlocks ¶
func (b *BlockCache) ReadBlocks() <-chan blockchain.Block
ReadBlocks returns a channel for iterating over all the blocks in the cache
func (*BlockCache) ReadLastBlock ¶
func (b *BlockCache) ReadLastBlock() blockchain.Block
ReadBlock returns a block from the cache
type NewBlock ¶
type NewBlock struct {
Block blockchain.Block `json:"block"`
}
NewBlockEvent indicates a peer has mined a new block
type NewPeer ¶
type NewPeer struct {
Address string `json:"peerAddress"`
}
NewPeer indicates a new peer has been discovered
type NewTransaction ¶
type NewTransaction struct {
Transaction blockchain.Transaction `json:"transaction"`
}
NewTransaction indicates a peer has received a new transaction
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents the node running the blockchain
type NodeClient ¶
type NodeClient struct {
// contains filtered or unexported fields
}
NodeClient is an HTTP client used to communicate with a node
func (*NodeClient) GetBlocks ¶
func (c *NodeClient) GetBlocks() ([]blockchain.Block, error)
GetBlocks requests all known blocks from peer node
func (*NodeClient) SendBlock ¶
func (c *NodeClient) SendBlock(block blockchain.Block) error
SendBlock sends block to peer node
type Peers ¶
Peers contains all the peers a node knows about
func (*Peers) BroadcastBlock ¶
func (p *Peers) BroadcastBlock(block blockchain.Block)
BroadcastBlock sends block to all known peer ndoes