blocks

package
v0.0.0-...-85b665a Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2018 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Open    BlockType = "open"
	Receive           = "receive"
	Send              = "send"
	Change            = "change"
	Utx               = "utx"
)
View Source
const TestPrivateKey string = "34F0A37AAD20F4A260F0A5B3CB3D7FB50673212263E58A380BC10474BB039CE4"

Variables

View Source
var GenesisAmount uint128.Uint128 = uint128.FromInts(0xffffffffffffffff, 0xffffffffffffffff)
View Source
var LiveGenesisBlock = liveGenesisBlock.(*OpenBlock)
View Source
var LiveGenesisBlockHash, _ = types.BlockHashFromString("991CF190094C00F0B68E2E5F75F6BEE95A2E0BD93CEAA4A6734DB9F19B728948")
View Source
var LiveGenesisSourceHash, _ = types.BlockHashFromString("E89208DD038FBB269987689621D52292AE9C35941A7484756ECCED92A65093BA")
View Source
var TestGenesisBlock = testGenesisBlock.(*OpenBlock)

Functions

func GenerateWork

func GenerateWork(b Block) types.Work

func HashBytes

func HashBytes(inputs ...[]byte) types.BlockHash

func HashChange

func HashChange(previous types.BlockHash, representative types.PubKey) types.BlockHash

func HashOpen

func HashOpen(source types.BlockHash, representative types.PubKey, account types.PubKey) types.BlockHash

func HashReceive

func HashReceive(previous types.BlockHash, source types.BlockHash) types.BlockHash

func HashSend

func HashSend(previous types.BlockHash, destination types.PubKey, balance uint128.Uint128) types.BlockHash

func HashUtx

func HashUtx(account types.PubKey, prev types.BlockHash, repr types.PubKey, balance uint128.Uint128, amount uint128.Uint128, link types.PubKey) types.BlockHash

func SignMessage

func SignMessage(prvStr string, message []byte) (types.Signature, error)

func ValidateBlockWork

func ValidateBlockWork(b Block) bool

Types

type Block

type Block interface {
	Type() BlockType
	GetSignature() types.Signature
	GetWork() types.Work
	GetRoot() types.BlockHash
	Hash() types.BlockHash
	GetPrevious() types.BlockHash
}

func FromJson

func FromJson(b []byte) (Block, error)

type BlockStore

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

func NewBlockStore

func NewBlockStore(store *store.Store) *BlockStore

func (*BlockStore) GetBlock

func (s *BlockStore) GetBlock(hash types.BlockHash) (Block, error)

func (*BlockStore) SetBlock

func (s *BlockStore) SetBlock(b Block) error

type BlockType

type BlockType string

type ChangeBlock

type ChangeBlock struct {
	Previous       types.BlockHash
	Representative types.PubKey
	CommonBlock
}

func (*ChangeBlock) GetPrevious

func (b *ChangeBlock) GetPrevious() types.BlockHash

func (*ChangeBlock) GetRoot

func (b *ChangeBlock) GetRoot() types.BlockHash

func (*ChangeBlock) Hash

func (b *ChangeBlock) Hash() types.BlockHash

func (*ChangeBlock) Type

func (*ChangeBlock) Type() BlockType

type CommonBlock

type CommonBlock struct {
	Work      types.Work
	Signature types.Signature
	Account   types.PubKey
}

func (*CommonBlock) GetSignature

func (b *CommonBlock) GetSignature() types.Signature

func (*CommonBlock) GetWork

func (b *CommonBlock) GetWork() types.Work

type OpenBlock

type OpenBlock struct {
	Source         types.BlockHash
	Representative types.PubKey
	Account        types.PubKey
	CommonBlock
}
var GenesisBlock *OpenBlock

func (*OpenBlock) GetPrevious

func (b *OpenBlock) GetPrevious() types.BlockHash

func (*OpenBlock) GetRoot

func (b *OpenBlock) GetRoot() types.BlockHash

func (*OpenBlock) Hash

func (b *OpenBlock) Hash() types.BlockHash

func (*OpenBlock) Type

func (*OpenBlock) Type() BlockType

func (*OpenBlock) VerifySignature

func (b *OpenBlock) VerifySignature() (bool, error)

type RawBlock

type RawBlock struct {
	Type           BlockType
	Source         types.BlockHash
	Representative types.PubKey
	Account        types.PubKey
	Work           types.Work
	Signature      types.Signature
	Previous       types.BlockHash
	Balance        uint128.Uint128
	Destination    types.PubKey
}

func (RawBlock) Hash

func (b RawBlock) Hash() [32]byte

func (RawBlock) HashToString

func (b RawBlock) HashToString() string

type ReceiveBlock

type ReceiveBlock struct {
	Previous types.BlockHash
	Source   types.BlockHash
	CommonBlock
}

func (*ReceiveBlock) GetPrevious

func (b *ReceiveBlock) GetPrevious() types.BlockHash

func (*ReceiveBlock) GetRoot

func (b *ReceiveBlock) GetRoot() types.BlockHash

func (*ReceiveBlock) Hash

func (b *ReceiveBlock) Hash() types.BlockHash

func (*ReceiveBlock) Type

func (*ReceiveBlock) Type() BlockType

type SendBlock

type SendBlock struct {
	Previous    types.BlockHash
	Destination types.PubKey
	Balance     uint128.Uint128
	CommonBlock
}

func (*SendBlock) GetPrevious

func (b *SendBlock) GetPrevious() types.BlockHash

func (*SendBlock) GetRoot

func (b *SendBlock) GetRoot() types.BlockHash

func (*SendBlock) Hash

func (b *SendBlock) Hash() types.BlockHash

func (*SendBlock) Type

func (*SendBlock) Type() BlockType

type UtxBlock

type UtxBlock struct {
	Account        types.PubKey
	Previous       types.BlockHash
	Representative types.PubKey
	Balance        uint128.Uint128
	Amount         uint128.Uint128
	Link           types.PubKey
	CommonBlock
}

func (*UtxBlock) GetPrevious

func (b *UtxBlock) GetPrevious() types.BlockHash

func (*UtxBlock) GetRoot

func (b *UtxBlock) GetRoot() types.BlockHash

func (*UtxBlock) Hash

func (b *UtxBlock) Hash() types.BlockHash

func (*UtxBlock) IsSend

func (b *UtxBlock) IsSend() bool

func (*UtxBlock) Type

func (b *UtxBlock) Type() BlockType

func (*UtxBlock) VerifySignature

func (b *UtxBlock) VerifySignature() (bool, error)

Jump to

Keyboard shortcuts

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