Documentation ¶
Index ¶
- Constants
- Variables
- func GetAPIs(apiBackend Backend) []rpc.API
- type Backend
- type Block
- type BlockChain
- type Config
- type Peer
- type Plasma
- func (pls *Plasma) APIs() []rpc.API
- func (pls *Plasma) CurrentBlockNumber() uint64
- func (pls *Plasma) HandlePeer(remote *p2p.Peer, rw p2p.MsgReadWriter) error
- func (pls *Plasma) Protocols() []p2p.Protocol
- func (pls *Plasma) RegisterClient(backend *ethclient.Client)
- func (pls *Plasma) RegisterRpcClient(rpcClient *rpc.Client)
- func (pls *Plasma) Start(server *p2p.Server) error
- func (pls *Plasma) Stop() error
- func (pls *Plasma) Version() uint
- type PlasmaAPI
- type PlasmaOperatorAPI
- type PublicPlasmaAPI
- func (api *PublicPlasmaAPI) ApplyTransaction(ctx context.Context, args TxArgs) (common.Hash, error)
- func (api *PublicPlasmaAPI) CurrentBlockNumber(ctx context.Context) uint64
- func (api *PublicPlasmaAPI) Deposit(ctx context.Context) string
- func (api *PublicPlasmaAPI) GetBlock(ctx context.Context, BlkNum *hexutil.Big) (map[string]interface{}, error)
- func (api *PublicPlasmaAPI) GetTransaction(ctx context.Context, BlkNum, TxIndex *big.Int) (map[string]interface{}, error)
- func (api *PublicPlasmaAPI) SubmitBlock(ctx context.Context) (common.Hash, error)
- func (api *PublicPlasmaAPI) Version(ctx context.Context) string
- type Transaction
- func (tx *Transaction) DecodeRLP(s *rlp.Stream) error
- func (tx *Transaction) EncodeRLP(w io.Writer) error
- func (tx *Transaction) Hash() (h common.Hash)
- func (tx *Transaction) MarshalJSON() ([]byte, error)
- func (tx *Transaction) Sender(oIndex *big.Int) (common.Address, error)
- func (tx *Transaction) Sign1(privKey *ecdsa.PrivateKey) error
- func (tx *Transaction) Sign2(privKey *ecdsa.PrivateKey) error
- func (tx *Transaction) ToRPCResponse() map[string]interface{}
- type TxArgs
Constants ¶
const ( ProtocolVersion = uint64(1) ProtocolVersionStr = "1" ProtocolName = "pls" MaxMessageSize = uint32(10 * 1024 * 1024) // maximum accepted size of a message. DefaultMaxMessageSize = uint32(1024 * 1024) )
const ( ErrMsgTooLarge = iota ErrDecode ErrInvalidMsgCode ErrProtocolVersionMismatch )
Variables ¶
var DefaultConfig = Config{ ContractAddress: common.StringToAddress("0x0"), OperatorAddress: params.PlasmaOperatorAddress, }
Functions ¶
Types ¶
type Backend ¶
type Backend interface { // General Plasma APIs GetTransaction() GetCurrentBlock() GetCurrentBlockNum() GetBlock() ApplyTransaction() // Public Root chain APIs SubmitDeposit() StartExit() ChallangeExit() // Plasma Operator APIs SubmitBlock() }
Backend interface provides the common API services
type Block ¶
type Block struct { BlockNumber *big.Int TransactionSet []*Transaction Merkle *merkle.Merkle // TODO: store in DB with caching Sig []byte }
Block implements Plasma chiain block
func (*Block) MarshalJSON ¶
func (*Block) ToRPCResponse ¶
type BlockChain ¶
type BlockChain struct {
// contains filtered or unexported fields
}
BlockChain implements Plasma block chain service
func NewBlockChain ¶
func NewBlockChain(config *Config) *BlockChain
NewBlockChain creates BlockChain instance
type Config ¶
type Config struct { // Address of plasma contract on root chain ContractAddress common.Address // Address of plasma operator // TODO: load this address from Plasma contract on Ethereum network OperatorAddress common.Address // If this node is operator, specify the private key OperatorPrivateKey *ecdsa.PrivateKey // Plasma operator node OperatorNode *Peer OperatorNodeURL string // BlockChain specific configs DataDir string OnDisk bool // disk or memory }
Config represents the configuration state of a plasma node.
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
Peer represents a plasma protocol peer connection.
type Plasma ¶
type Plasma struct { ApiBackend *Backend // contains filtered or unexported fields }
Plasma implements the Plasma full node service
func (*Plasma) APIs ¶
APIs implements node.Service, retrieving the list of RPC descriptors the service provides
func (*Plasma) CurrentBlockNumber ¶
func (*Plasma) HandlePeer ¶
HandlePeer is called by the underlying P2P layer when the plasma sub-protocol connection is negotiated. XXX the life sycle of HandlePeer function is same as the p2p connection
func (*Plasma) Protocols ¶
Protocols implements node.Service, retrieving the P2P protocols the service wishes to start.
func (*Plasma) RegisterClient ¶
RegisterClient register endpoint of ethereum jsonrpc for Plasma single node
func (*Plasma) RegisterRpcClient ¶
func (*Plasma) Start ¶
Start implements node.Service, starting the background data propagation thread of the Plasma protocol.
type PlasmaAPI ¶
type PlasmaAPI struct { }
PlasmaAPI provides an API to access Plasma related information.
func NewPlasmaAPI ¶
func NewPlasmaAPI() PlasmaAPI
type PlasmaOperatorAPI ¶
type PlasmaOperatorAPI struct { }
PlasmaOperatorAPI provides an API for plasma operator.
func NewPlasmaOperatorAPI ¶
func NewPlasmaOperatorAPI() PlasmaOperatorAPI
type PublicPlasmaAPI ¶
type PublicPlasmaAPI struct {
// contains filtered or unexported fields
}
func NewPublicPlasmaAPI ¶
func NewPublicPlasmaAPI(pls *Plasma) *PublicPlasmaAPI
func (*PublicPlasmaAPI) ApplyTransaction ¶
func (*PublicPlasmaAPI) CurrentBlockNumber ¶
func (api *PublicPlasmaAPI) CurrentBlockNumber(ctx context.Context) uint64
func (*PublicPlasmaAPI) GetTransaction ¶
func (*PublicPlasmaAPI) SubmitBlock ¶
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction implements Plasma chain transaction
func NewTransaction ¶
func NewTransaction(blkNum1, txIndex1, oIndex1, blkNum2, txIndex2, oIndex2 *big.Int, newOwner1 *common.Address, amount1 *big.Int, newOwner2 *common.Address, amount2, fee *big.Int) *Transaction
NewTransaction creates Transaction instance
func (*Transaction) DecodeRLP ¶
func (tx *Transaction) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder
func (*Transaction) EncodeRLP ¶
func (tx *Transaction) EncodeRLP(w io.Writer) error
EncodeRLP implements rlp.Encoder
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() (h common.Hash)
Hash returns sha3 hash of Transaction
func (*Transaction) MarshalJSON ¶
func (tx *Transaction) MarshalJSON() ([]byte, error)
func (*Transaction) Sign1 ¶
func (tx *Transaction) Sign1(privKey *ecdsa.PrivateKey) error
func (*Transaction) Sign2 ¶
func (tx *Transaction) Sign2(privKey *ecdsa.PrivateKey) error
func (*Transaction) ToRPCResponse ¶
func (tx *Transaction) ToRPCResponse() map[string]interface{}
type TxArgs ¶
type TxArgs struct { BlkNum1 *hexutil.Big `json:"blkNum1"` TxIndex1 *hexutil.Big `json:"txIndex1"` OIndex1 *hexutil.Big `json:"oIndex1"` BlkNum2 *hexutil.Big `json:"blkNum2"` TxIndex2 *hexutil.Big `json:"txIndex2"` OIndex2 *hexutil.Big `json:"oIndex2"` NewOwner1 *common.Address `json:"newOwner1"` Amount1 *hexutil.Big `json:"amount1"` NewOwner2 *common.Address `json:"newOwner2"` Amount2 *hexutil.Big `json:"amount2"` Fee *hexutil.Big `json:"fee"` From1 *common.Address `json:"from1"` // sign input 1 From2 *common.Address `json:"from2"` // sign input 2 }