protocol

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2019 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProtocolID = protocol.ID("/stratumn/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

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

func (c *Coin) AppendBlock(ctx context.Context, block *pb.Block) error

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

func (c *Coin) GetAccount(peerID []byte) (*pb.Account, error)

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

func (c *Coin) GetBlockchain(blockNumber uint64, hash []byte, count uint32) ([]*pb.Block, error)

GetBlockchain gets blocks from the blockchain. It returns the blocks in decreasing block number, starting from the block requested.

func (*Coin) GetTransactionPool

func (c *Coin) GetTransactionPool(count uint32) (uint64, []*pb.Transaction, error)

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) Run

func (c *Coin) Run(ctx context.Context) error

Run starts the coin.

func (*Coin) StartBlockGossip

func (c *Coin) StartBlockGossip(ctx context.Context) error

StartBlockGossip starts gossiping blocks.

func (*Coin) StartMining

func (c *Coin) StartMining(ctx context.Context) error

StartMining starts the underlying miner.

func (*Coin) StartTxGossip

func (c *Coin) StartTxGossip(ctx context.Context) error

StartTxGossip starts gossiping transactions.

func (*Coin) StreamHandler

func (c *Coin) StreamHandler(ctx context.Context, stream inet.Stream)

StreamHandler handles incoming messages from peers.

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.
p2p
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL