chain

package
v0.0.0-...-4496321 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const FINE = 100

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	BlockId      int64         `json:"block_id"`
	SubHash      *SubHash      `json:"hash_sub"`
	SubSignature *SubSignature `json:"signature_sub"`
	SubTx        *SubTx        `json:"tx_sub"`
}

func GenesisBlock

func GenesisBlock(commitProof *proto.CommitProof, priv crypto.PrivKeyEd25519, spaceProof *proto.SpaceProof, txs []*Tx) *Block

func NewBlock

func NewBlock(commitProof *proto.CommitProof, prevBlock *Block, priv crypto.PrivKeyEd25519, spaceProof *proto.SpaceProof, txs []*Tx) *Block

func (*Block) Serialize

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

type Chain

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

func NewChain

func NewChain(chainPath string) *Chain

func (*Chain) Last

func (c *Chain) Last() int

func (*Chain) MustRead

func (c *Chain) MustRead(id int) *Block

func (*Chain) MustWrite

func (c *Chain) MustWrite(b *Block)

func (*Chain) Read

func (c *Chain) Read(id int) (*Block, error)

func (*Chain) Write

func (c *Chain) Write(b *Block) error

type In

type In struct {
	PubKey    crypto.PubKeyEd25519    `json:"public_key"`
	Signature crypto.SignatureEd25519 `json:"signature"` //sig(tx_id, past_tx_id, past_beneficiary, out)
	TxId      int64                   `json:"tx_id"`
}

func NewIn

func NewIn(outs []*Out, pastTxId int64, priv crypto.PrivKeyEd25519, pub crypto.PubKeyEd25519, txId int64) *In

type InSign

type InSign struct {
	Outs     []*Out               `json:"out"`
	PastTxId int64                `json:"past_tx_id"`
	Pubkey   crypto.PubKeyEd25519 `json:"public_key"`
	TxId     int64                `json:"tx_id"`
}

func NewInSign

func NewInSign(outs []*Out, pastTxId int64, pub crypto.PubKeyEd25519, txId int64) *InSign

func (*InSign) Serialize

func (inSign *InSign) Serialize() []byte

type IsTx

type IsTx interface {
	IsTx()
}

type Out

type Out struct {
	PubKey crypto.PubKeyEd25519 `json:"public_key"`
	Value  int64                `json:"value"`
}

func NewOut

func NewOut(pub crypto.PubKeyEd25519, value int64) *Out

type Punishment

type Punishment struct {
	BlockId         int64                `json:"block_id"`
	PubKey          crypto.PubKeyEd25519 `json:"public_key"`
	PunishmentProof *PunishmentProof     `json:"punishment_proof"`
}

func NewPunishment

func NewPunishment(blockId int64, pub crypto.PubKeyEd25519, proof *PunishmentProof) *Punishment

type PunishmentProof

type PunishmentProof struct {
	Chain1Next   *Block               `json:"chain1_next_block"`
	Chain1Recent *Block               `json:"chain1_recent_block"`
	Chain2Next   *Block               `json:"chain2_next_block"`
	Chain2Recent *Block               `json:"chain2_recent_block"`
	PubKey       crypto.PubKeyEd25519 `json:"public_key"`
}

func NewPunishmentProof

func NewPunishmentProof(pub crypto.PubKeyEd25519, chain1Next, chain1Recent, chain2Next, chain2Recent *Block) *PunishmentProof

type SubHash

type SubHash struct {
	BlockId     int64                   `json:"block_id"`
	CommitProof *proto.CommitProof      `json:"commit_proof"`
	SpaceProof  *proto.SpaceProof       `json:"space_proof"`
	Signature   crypto.SignatureEd25519 `json:"signature"`
}

func NewSubHash

func NewSubHash(blockId int64, commitProof *proto.CommitProof, prevSubHash *SubHash, priv crypto.PrivKeyEd25519, spaceProof *proto.SpaceProof) *SubHash

func (*SubHash) Serialize

func (subHash *SubHash) Serialize() []byte

type SubSignature

type SubSignature struct {
	BlockId      int64                   `json:"block_id"`
	SignatureSig crypto.SignatureEd25519 `json:"signature_sig"`
	SignatureTx  crypto.SignatureEd25519 `json:"signature_tx"`
}

func NewSubSignature

func NewSubSignature(blockId int64, prevSubSig *SubSignature, priv crypto.PrivKeyEd25519, subTx *SubTx) *SubSignature

func (*SubSignature) Serialize

func (subSig *SubSignature) Serialize() []byte

type SubTx

type SubTx struct {
	BlockId int64 `json:"block_id"`
	Txs     []*Tx `json:"txs"`
}

func NewSubTx

func NewSubTx(blockId int64, txs []*Tx) *SubTx

func (*SubTx) Serialize

func (subTx *SubTx) Serialize() []byte

type Tx

type Tx struct {
	*TxCommit
	*TxPayment
	*TxPunishment
}

Tx

func NewTx

func NewTx(isTx IsTx) *Tx

type TxCommit

type TxCommit struct {
	Commit []byte               `json:"commit"`
	PubKey crypto.PubKeyEd25519 `json:"public_key"`
	TxId   int64                `json:"tx_id"`
}

func NewTxCommit

func NewTxCommit(commit []byte, pub crypto.PubKeyEd25519, txId int64) *TxCommit

func (*TxCommit) IsTx

func (_ *TxCommit) IsTx()

type TxPayment

type TxPayment struct {
	Ins  []*In  `json:"ins"`
	Outs []*Out `json:"outs"`
	TxId int64  `json:"tx_id"`
}

func NewTxPayment

func NewTxPayment(ins []*In, outs []*Out, txId int64) *TxPayment

func (*TxPayment) IsTx

func (_ *TxPayment) IsTx()

type TxPunishment

type TxPunishment struct {
	PubKey     crypto.PubKeyEd25519 `json:"public_key"`
	Punishment *Punishment          `json:"punishment"`
	TxId       int64                `json:"tx_id"`
}

func NewTxPunishment

func NewTxPunishment(pub crypto.PubKeyEd25519, punishment *Punishment, txId int64) *TxPunishment

func (*TxPunishment) IsTx

func (_ *TxPunishment) IsTx()

Jump to

Keyboard shortcuts

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