Documentation ¶
Overview ¶
Package pow implements a Proof-of-Work ordering service. This implementation very naive and only support one single node. It demonstrates a permissionless blockchain.
TODO: later improve or remove
Index ¶
Constants ¶
const Difficulty = 1
Difficulty is the default difficulty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block is a representation of a batch of transactions for a Proof-of-Work consensus. Each block has a fingerprint as a proof of correctness.
func NewBlock ¶
func NewBlock(ctx context.Context, data validation.Result, opts ...BlockOption) (Block, error)
NewBlock creates a new block.
type BlockOption ¶
type BlockOption func(*blockTemplate)
BlockOption is the type of options to create a block.
func WithDifficulty ¶
func WithDifficulty(diff uint) BlockOption
WithDifficulty is an option to set the difficulty of the proof of work. If the difficulty is set to 0, the hash will be calculated according to the current nonce.
func WithIndex ¶
func WithIndex(index uint64) BlockOption
WithIndex is an option to set the block index.
func WithNonce ¶
func WithNonce(nonce uint64) BlockOption
WithNonce is an option to set the nonce of a block.
func WithRoot ¶
func WithRoot(root []byte) BlockOption
WithRoot is an option to set the root of a block.
type Proof ¶
type Proof struct {
// contains filtered or unexported fields
}
Proof is a proof that the chain of blocks has or has not the key in the store. If the key exists, the proof also contains the value.
- implements ordering.Proof
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is an ordering service powered by a Proof-of-Work consensus algorithm.
- implements ordering.Service
func NewService ¶
NewService creates a new service.