Documentation ¶
Index ¶
- Variables
- type Coin
- func (c *Coin) AddTransaction(tx *pb.Transaction) error
- func (c *Coin) AddValidTransaction(tx *pb.Transaction) error
- func (c *Coin) AppendBlock(ctx context.Context, block *pb.Block) error
- func (c *Coin) GetAccount(peerID []byte) (*pb.Account, error)
- func (c *Coin) GetAccountTransactions(peerID []byte) ([]*pb.Transaction, error)
- func (c *Coin) GetBlockchain(blockNumber uint64, hash []byte, count uint32) ([]*pb.Block, error)
- func (c *Coin) GetTransactionPool(count uint32) (uint64, []*pb.Transaction, error)
- func (c *Coin) PublishTransaction(tx *pb.Transaction) error
- func (c *Coin) Run(ctx context.Context) error
- func (c *Coin) StartBlockGossip(ctx context.Context) error
- func (c *Coin) StartMining(ctx context.Context) error
- func (c *Coin) StartTxGossip(ctx context.Context) error
- func (c *Coin) StreamHandler(ctx context.Context, stream inet.Stream)
- type Protocol
Constants ¶
This section is empty.
Variables ¶
var ProtocolID = protocol.ID("/indigo/node/coin/v1.0.0")
ProtocolID is the protocol ID of the protocol.
Functions ¶
This section is empty.
Types ¶
type Coin ¶
type Coin struct {
// contains filtered or unexported fields
}
Coin implements Protocol with a PoW engine.
func NewCoin ¶
func NewCoin( b *pb.Block, txp state.TxPool, e engine.Engine, s state.State, c chain.Chain, g gossip.Gossip, v validator.Validator, p processor.Processor, p2p p2p.P2P, sync synchronizer.Synchronizer, ) *Coin
NewCoin creates a new Coin.
func (*Coin) AddTransaction ¶
func (c *Coin) AddTransaction(tx *pb.Transaction) error
AddTransaction validates incoming transactions against the latest state and adds them to the pool.
func (*Coin) AddValidTransaction ¶
func (c *Coin) AddValidTransaction(tx *pb.Transaction) error
AddValidTransaction adds a valid transaction to the mempool.
func (*Coin) AppendBlock ¶
AppendBlock validates the incoming block and adds it at the end of the chain, updating internal state to reflect the block's transactions. The miner will be notified of the new block and can decide to mine on top of it or keep mining on another fork.
func (*Coin) GetAccount ¶
GetAccount gets the account details of a user identified by his public key. It returns &pb.Account{} if the account is not found.
func (*Coin) GetAccountTransactions ¶
func (c *Coin) GetAccountTransactions(peerID []byte) ([]*pb.Transaction, error)
GetAccountTransactions gets the transaction history of a user identified by his public key.
func (*Coin) GetBlockchain ¶
GetBlockchain gets blocks from the blockchain. It returns the blocks in decreasing block number, starting from the block requested.
func (*Coin) GetTransactionPool ¶
GetTransactionPool returns the size of the transaction pool and a few random transactions from the pool.
func (*Coin) PublishTransaction ¶
func (c *Coin) PublishTransaction(tx *pb.Transaction) error
PublishTransaction publishes and adds transaction received via grpc.
func (*Coin) StartBlockGossip ¶
StartBlockGossip starts gossiping blocks.
func (*Coin) StartMining ¶
StartMining starts the underlying miner.
func (*Coin) StartTxGossip ¶
StartTxGossip starts gossiping transactions.
type Protocol ¶
type Protocol interface { // AddTransaction validates a transaction and adds it to the transaction pool. AddTransaction(tx *pb.Transaction) error // AppendBlock validates the incoming block and adds it at the end of // the chain, updating internal state to reflect the block's transactions. // Note: it might cause the consensus engine to stop mining on an outdated // block and mine on top of the newly added block. AppendBlock(block *pb.Block) error // StartMining starts mining blocks. // This method will not return until the input context is canceled. StartMining(ctx context.Context) error }
Protocol describes the interface exposed to other nodes in the network.
Directories ¶
Path | Synopsis |
---|---|
mockchain
Package mockchain is a generated GoMock package.
|
Package mockchain is a generated GoMock package. |
mockengine
Package mockengine is a generated GoMock package.
|
Package mockengine is a generated GoMock package. |
mockgossip
Package mockgossip is a generated GoMock package.
|
Package mockgossip is a generated GoMock package. |
mockencoder
Package mockencoder is a generated GoMock package.
|
Package mockencoder is a generated GoMock package. |
mockp2p
Package mockp2p is a generated GoMock package.
|
Package mockp2p is a generated GoMock package. |
mockprocessor
Package mockprocessor is a generated GoMock package.
|
Package mockprocessor is a generated GoMock package. |
mockstate
Package mockstate is a generated GoMock package.
|
Package mockstate is a generated GoMock package. |
mocksynchronizer
Package mocksynchronizer is a generated GoMock package.
|
Package mocksynchronizer is a generated GoMock package. |
Package trie implements a Patricia Merkle Trie.
|
Package trie implements a Patricia Merkle Trie. |
mockvalidator
Package mockvalidator is a generated GoMock package.
|
Package mockvalidator is a generated GoMock package. |