Documentation ¶
Index ¶
- Variables
- func DepositAddress(subChainAddr []byte, depositIndex uint64) hash.PKHash
- func SortInOperation(x interface{}, y interface{}) int
- type BlockProof
- type Deposit
- type InOperation
- type MerkleRoot
- type Protocol
- func (p *Protocol) Deposit(subChainAddr address.Address, depositIndex uint64) (*Deposit, error)
- func (p *Protocol) Handle(_ context.Context, act action.Action, ws state.WorkingSet) (*action.Receipt, error)
- func (p *Protocol) SubChain(addr address.Address) (*SubChain, error)
- func (p *Protocol) SubChainsInOperation() (state.SortedSlice, error)
- func (p *Protocol) Validate(_ context.Context, act action.Action) error
- type StartSubChainReceipt
- type SubChain
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
Deposit represents the state of a deposit
func (*Deposit) Deserialize ¶
Deserialize deserializes bytes into deposit state
type InOperation ¶
InOperation represents a record of a sub-chain in operation
type MerkleRoot ¶
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) Handle ¶
func (p *Protocol) Handle(_ context.Context, act action.Action, ws state.WorkingSet) (*action.Receipt, error)
Handle handles how to mutate the state db given the multi-chain action on main-chain
func (*Protocol) SubChainsInOperation ¶
func (p *Protocol) SubChainsInOperation() (state.SortedSlice, error)
SubChainsInOperation returns the used chain IDs
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 ¶
Deserialize deserializes bytes into sub-chain state