chain

package
v0.0.0-...-ee306bc Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package chain implements IPFN rootchain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MinDelegatedPower

func MinDelegatedPower(total uint64) uint64

MinDelegatedPower - Returns amount of minimum power delegated.

func SealPower

func SealPower(delegated uint64) uint64

SealPower - Returns amount of power required for sealing a block.

Types

type Block

type Block struct {
	// contains filtered or unexported fields
}

Block - Chain block.

func NewBlock

func NewBlock(index uint64, prevCID *cells.CID, opsRoot cells.MutableCell) (*Block, error)

NewBlock - Creates new block.

func (*Block) EnsureHead

func (block *Block) EnsureHead() error

EnsureHead - Calculates head.

func (*Block) Exec

func (block *Block) Exec(op cells.Cell)

Exec - Adds operation to execute.

func (*Block) ExecSize

func (block *Block) ExecSize() int

ExecSize - Returns amount of operations.

func (*Block) HeadHash

func (block *Block) HeadHash() *cells.CID

HeadHash - Returns head CID.

func (*Block) Header

func (block *Block) Header() (*BlockHeader, error)

Header - Creates block header.

func (*Block) Height

func (block *Block) Height() uint64

Height - Returns state index.

func (*Block) IsGenesis

func (block *Block) IsGenesis() bool

IsGenesis - Returns true on zero height.

func (*Block) MarshalJSON

func (block *Block) MarshalJSON() ([]byte, error)

MarshalJSON - Marshals state to JSON.

func (*Block) Next

func (block *Block) Next(opsRoot cells.MutableCell) (*Block, error)

Next - Returns next state including given ops.

func (*Block) PrevHash

func (block *Block) PrevHash() *cells.CID

PrevHash - Returns previous CID.

func (*Block) Root

func (block *Block) Root() cells.Cell

Root - Returns root operation.

func (*Block) Seal

func (block *Block) Seal() *SignedBlock

Seal - Creates signed block.

func (*Block) SetStateHash

func (block *Block) SetStateHash(c *cells.CID)

SetStateHash - Sets state hash. Resets head hash and signatures.

func (*Block) StateHash

func (block *Block) StateHash() *cells.CID

StateHash - Returns state CID.

type BlockHeader

type BlockHeader struct {
	// Height - Block height.
	Height uint64 `json:"height,omitempty"`
	// Timestamp - Block time.
	Timestamp time.Time `json:"timestamp,omitempty"`
	// HeadHash - Head content ID.
	HeadHash *cells.CID `json:"head_hash,omitempty"`
	// PrevHash - Previous block head hash.
	PrevHash *cells.CID `json:"prev_hash,omitempty"`
	// ExecHash - Block execution hash.
	ExecHash *cells.CID `json:"exec_hash,omitempty"`
	// StateHash - State trie hash.
	StateHash *cells.CID `json:"state_hash,omitempty"`
	// SignedHash - Signed head hash.
	SignedHash *cells.CID `json:"signed_hash,omitempty"`
}

BlockHeader - Block header.

type Chain

type Chain struct {
}

Chain - Chain structure.

type SignedBlock

type SignedBlock struct {
	*Block
	// contains filtered or unexported fields
}

SignedBlock - Signed chain block.

func NewSignedBlock

func NewSignedBlock(block *Block) *SignedBlock

NewSignedBlock - Creates new signed block.

func (*SignedBlock) Header

func (block *SignedBlock) Header() (header *BlockHeader, err error)

Header - Creates block header with signed hash.

func (*SignedBlock) MarshalJSON

func (block *SignedBlock) MarshalJSON() ([]byte, error)

MarshalJSON - Marshals state to JSON.

func (*SignedBlock) Sign

func (block *SignedBlock) Sign(key *btcec.PrivateKey) (err error)

Sign - Signs state with given private key. Computes new signed header hash.

func (*SignedBlock) Signatures

func (block *SignedBlock) Signatures() [][]byte

Signatures - Returns state signatures.

func (*SignedBlock) SignedHash

func (block *SignedBlock) SignedHash() *cells.CID

SignedHash - Returns signed head CID.

Jump to

Keyboard shortcuts

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