mainchain

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MinSecurityDeposit represents the security deposit minimal required for start a sub-chain, which is 1M iotx
	MinSecurityDeposit = big.NewInt(0).Mul(big.NewInt(1000000000), big.NewInt(blockchain.Iotx))
	// SubChainsInOperationKey is to find the used chain IDs in the state factory
	// TODO: this is a not safe way to define the key, as other protocols could collide it
	SubChainsInOperationKey = byteutil.BytesTo20B(hash.Hash160b([]byte("subChainsInOperation")))
)

Functions

func DepositAddress

func DepositAddress(subChainAddr []byte, depositIndex uint64) hash.PKHash

DepositAddress returns the deposit address (20-byte)

func SortInOperation

func SortInOperation(x interface{}, y interface{}) int

SortInOperation compare two ChainInUse records by their chain IDs. If one of the input's type is not InOperation, it will not be comparable and 0 will be returned.

Types

type BlockProof

type BlockProof struct {
	SubChainAddress   string
	Height            uint64
	Roots             []MerkleRoot
	ProducerPublicKey keypair.PublicKey
	ProducerAddress   string
}

BlockProof represents the block proof of a sub-chain in the state factory

func (*BlockProof) Deserialize

func (bp *BlockProof) Deserialize(data []byte) error

Deserialize deserialize bytes into block proof state

func (*BlockProof) Serialize

func (bp *BlockProof) Serialize() ([]byte, error)

Serialize serialize block proof state into bytes

type Deposit

type Deposit struct {
	Amount    *big.Int
	Addr      []byte
	Confirmed bool
}

Deposit represents the state of a deposit

func (*Deposit) Deserialize

func (bs *Deposit) Deserialize(data []byte) error

Deserialize deserializes bytes into deposit state

func (*Deposit) Serialize

func (bs *Deposit) Serialize() ([]byte, error)

Serialize serializes deposit state into bytes

type InOperation

type InOperation struct {
	ID   uint32
	Addr []byte
}

InOperation represents a record of a sub-chain in operation

type MerkleRoot

type MerkleRoot struct {
	Name  string
	Value hash.Hash32B
}

MerkleRoot defines a merkle root in block proof.

type Protocol

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

Protocol defines the protocol of handling multi-chain actions on main-chain

func NewProtocol

func NewProtocol(rootChain blockchain.Blockchain) *Protocol

NewProtocol instantiates the protocol of sub-chain

func (*Protocol) Deposit

func (p *Protocol) Deposit(subChainAddr address.Address, depositIndex uint64) (*Deposit, error)

Deposit returns the deposit record

func (*Protocol) Handle

Handle handles how to mutate the state db given the multi-chain action on main-chain

func (*Protocol) SubChain

func (p *Protocol) SubChain(addr address.Address) (*SubChain, error)

SubChain returns the confirmed sub-chain state

func (*Protocol) SubChainsInOperation

func (p *Protocol) SubChainsInOperation() (state.SortedSlice, error)

SubChainsInOperation returns the used chain IDs

func (*Protocol) Validate

func (p *Protocol) Validate(_ context.Context, act action.Action) error

Validate validates the multi-chain action on main-chain

type StartSubChainReceipt

type StartSubChainReceipt struct {
	SubChainAddress string
}

StartSubChainReceipt is the receipt to user after executed start sub chain operation.

type SubChain

type SubChain struct {
	ChainID            uint32
	SecurityDeposit    *big.Int
	OperationDeposit   *big.Int
	StartHeight        uint64
	StopHeight         uint64
	ParentHeightOffset uint64
	OwnerPublicKey     keypair.PublicKey
	CurrentHeight      uint64
	DepositCount       uint64
}

SubChain represents the state of a sub-chain in the state factory

func (*SubChain) Deserialize

func (bs *SubChain) Deserialize(data []byte) error

Deserialize deserializes bytes into sub-chain state

func (*SubChain) Serialize

func (bs *SubChain) Serialize() ([]byte, error)

Serialize serializes sub-chain state into bytes

Jump to

Keyboard shortcuts

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