block

package
v0.0.0-...-96e5f69 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: MIT Imports: 10 Imported by: 6

Documentation

Index

Constants

View Source
const GenesisDesc = "GenesisBlock Fri Aug 17 23:16:12 MDT 2018"

GenesisDesc is the constant that marks that a block is a genesis block.

Variables

This section is empty.

Functions

func IndentJSON

func IndentJSON(v interface{}) string

IndentJSON converts data to JSON format and returns it as a string.

func IsGenesisBlock

func IsGenesisBlock(bk *BlockType) bool

IsGenesisBlock returns true if this is a genisis block.

func SerializeBlock

func SerializeBlock(bk *BlockType) []byte

SearalizeBlock searializes into bytes the fields that will be hashed the hash of the block. This is the hash that the next block will use to point to this block and the hash that this block will be saved as.

func SerializeForSeal

func SerializeForSeal(bk *BlockType) []byte

SearalizeForSeal searializes into bytes the fields that will be hashed for the mining seal.

func WriteBlock

func WriteBlock(fn string, bk *BlockType) (err error)

WriteBlock read i;n a block from a file.

Types

type BlockType

type BlockType struct {
	Index         int                             // position of this block in the chain, 0, 1, 2, ...
	Desc          string                          // if "genesis" string then this is a genesis block.
	ThisBlockHash hash.BlockHashType              //
	PrevBlockHash hash.BlockHashType              // This is 0 length if this is a "genesis" block
	Nonce         uint64                          //
	Seal          hash.SealType                   //
	MerkleHash    hash.MerkleHashType             // AS-03
	Tx            []*transactions.TransactionType // Add Transactions to Block Later, (AS-04 will do this)
}

BlockType is a single block in the block chain.

func InitBlock

func InitBlock(ii int, dd string, prev hash.BlockHashType) (bk *BlockType)

InitBlock creates and returns a block.

func InitGenesisBlock

func InitGenesisBlock() (gb *BlockType)

InitGenesisBlock create and return a genesis block. This is a special block at the beginning of a chain.

func ReadBlock

func ReadBlock(fn string) (bk *BlockType, err error)

ReadBlock reads in from a file a block and returns it.

Jump to

Keyboard shortcuts

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