mainchain

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ImageHash = "0xc672b8d1ef56ed28ab87c3622c5114069bdd3ad7b8f9737498d0c01ecef0967a"

ImageHash is the main chain identifier The main chain does not have an image (i.e. the image hash is nil). The hex encoded, sha2_256 hash of a nil bytes array is ImageHash https://play.golang.org/p/69Z8ot5uly5

Variables

View Source
var (
	// ErrNilBlock ...
	ErrNilBlock = errors.New("block is nil")
	// GenesisBlockHash ...
	GenesisBlockHash = "0x90770ba62574b68607ebd14a41dd2eb9df3c537df11b68647faea34a88315e49"
	// GenesisBlock ...
	GenesisBlock = Block{
					// contains filtered or unexported fields
	}
)

Functions

func BuildCoderFromBlock

func BuildCoderFromBlock(b *Block) *coder.MainchainBlock

BuildCoderFromBlock ...

func BuildCoderFromBytes

func BuildCoderFromBytes(data []byte) (*coder.MainchainBlock, error)

BuildCoderFromBytes ...

Types

type Block

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

Block ...

func New

func New(props *Props) *Block

New ...

func (*Block) CalculateHash

func (b *Block) CalculateHash() (string, error)

CalculateHash ...

func (*Block) CalculateHashBytes

func (b *Block) CalculateHashBytes() ([]byte, error)

CalculateHashBytes ...

func (*Block) Deserialize

func (b *Block) Deserialize(data []byte) error

Deserialize ...

func (*Block) DeserializeString

func (b *Block) DeserializeString(hexStr string) error

DeserializeString ...

func (*Block) Equals

func (b *Block) Equals(other merkletree.Content) (bool, error)

Equals ...

func (*Block) MarshalJSON

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

MarshalJSON ...

func (*Block) Props

func (b *Block) Props() Props

Props ...

func (*Block) Serialize

func (b *Block) Serialize() ([]byte, error)

Serialize ...

func (*Block) SerializeString

func (b *Block) SerializeString() (string, error)

SerializeString ...

func (*Block) SetHash

func (b *Block) SetHash() error

SetHash ...

func (*Block) UnmarshalJSON

func (b *Block) UnmarshalJSON(data []byte) error

UnmarshalJSON ...

type MinerSig

type MinerSig struct {
	R string `json:"r"`
	S string `json:"s"`
}

MinerSig ...

type Props

type Props struct {
	BlockHash             *string   `json:"blockHash,omitempty" rlp:"nil"`
	BlockNumber           string    `json:"blockNumber"`
	BlockTime             string    `json:"blockTime"` // unix timestamp
	ImageHash             string    `json:"imageHash"`
	StateBlocksMerkleHash string    `json:"stateBlocksMerkleHash"`
	PrevBlockHash         string    `json:"prevBlockHash"`
	Nonce                 string    `json:"nonce"`
	Difficulty            string    `json:"difficulty"`
	MinerAddress          string    `json:"minerAddress"`
	MinerSig              *MinerSig `json:"minerSig,omitempty" rlp:"nil"`
}

Props ...

func BuildBlockPropsFromBytes

func BuildBlockPropsFromBytes(data []byte) (*Props, error)

BuildBlockPropsFromBytes ...

func BuildBlockPropsFromCoder

func BuildBlockPropsFromCoder(tmp *coder.MainchainBlock) (*Props, error)

BuildBlockPropsFromCoder ...

Jump to

Keyboard shortcuts

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