plasma

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2018 License: GPL-3.0 Imports: 28 Imported by: 0

README

Documentation

Index

Constants

View Source
const (
	ProtocolVersion    = uint64(1)
	ProtocolVersionStr = "1"
	ProtocolName       = "pls"

	MaxMessageSize        = uint32(10 * 1024 * 1024) // maximum accepted size of a message.
	DefaultMaxMessageSize = uint32(1024 * 1024)
)
View Source
const (
	ErrMsgTooLarge = iota
	ErrDecode
	ErrInvalidMsgCode
	ErrProtocolVersionMismatch
)

Variables

View Source
var DefaultConfig = Config{
	ContractAddress: common.StringToAddress("0x0"),
	OperatorAddress: params.PlasmaOperatorAddress,
}

Functions

func GetAPIs

func GetAPIs(apiBackend Backend) []rpc.API

GetAPIs returns available plasma related apis

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 NewBlock

func NewBlock() *Block

func (*Block) Hash

func (b *Block) Hash() common.Hash

Hash returns sha3 hash of Block

func (*Block) MarshalJSON

func (b *Block) MarshalJSON() ([]byte, error)

func (*Block) Seal

func (b *Block) Seal() (common.Hash, error)

func (*Block) Sender

func (b *Block) Sender() (common.Address, error)

Sender returns address of block minder

func (*Block) Sign

func (b *Block) Sign(privKey *ecdsa.PrivateKey) error

func (*Block) ToRPCResponse

func (b *Block) ToRPCResponse() map[string]interface{}

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.

func (*Peer) ID

func (p *Peer) ID() []byte

type Plasma

type Plasma struct {
	ApiBackend *Backend
	// contains filtered or unexported fields
}

Plasma implements the Plasma full node service

func New

func New(config *Config, accountManager *accounts.Manager) *Plasma

func (*Plasma) APIs

func (pls *Plasma) APIs() []rpc.API

APIs implements node.Service, retrieving the list of RPC descriptors the service provides

func (*Plasma) CurrentBlockNumber

func (pls *Plasma) CurrentBlockNumber() uint64

func (*Plasma) HandlePeer

func (pls *Plasma) HandlePeer(remote *p2p.Peer, rw p2p.MsgReadWriter) error

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

func (pls *Plasma) Protocols() []p2p.Protocol

Protocols implements node.Service, retrieving the P2P protocols the service wishes to start.

func (*Plasma) RegisterClient

func (pls *Plasma) RegisterClient(backend *ethclient.Client)

RegisterClient register endpoint of ethereum jsonrpc for Plasma single node

func (*Plasma) RegisterRpcClient

func (pls *Plasma) RegisterRpcClient(rpcClient *rpc.Client)

func (*Plasma) Start

func (pls *Plasma) Start(server *p2p.Server) error

Start implements node.Service, starting the background data propagation thread of the Plasma protocol.

func (*Plasma) Stop

func (pls *Plasma) Stop() error

Stop implements node.Service, stopping the background data propagation thread of the Plasma protocol.

func (*Plasma) Version

func (pls *Plasma) Version() uint

Version returns the plasma sub-protocols version number.

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 (api *PublicPlasmaAPI) ApplyTransaction(ctx context.Context, args TxArgs) (common.Hash, error)

func (*PublicPlasmaAPI) CurrentBlockNumber

func (api *PublicPlasmaAPI) CurrentBlockNumber(ctx context.Context) uint64

func (*PublicPlasmaAPI) Deposit

func (api *PublicPlasmaAPI) Deposit(ctx context.Context) string

func (*PublicPlasmaAPI) GetBlock

func (api *PublicPlasmaAPI) GetBlock(ctx context.Context, BlkNum *hexutil.Big) (map[string]interface{}, error)

func (*PublicPlasmaAPI) GetTransaction

func (api *PublicPlasmaAPI) GetTransaction(ctx context.Context, BlkNum, TxIndex *big.Int) (map[string]interface{}, error)

func (*PublicPlasmaAPI) SubmitBlock

func (api *PublicPlasmaAPI) SubmitBlock(ctx context.Context) (common.Hash, error)

func (*PublicPlasmaAPI) Version

func (api *PublicPlasmaAPI) Version(ctx context.Context) string

Version returns the Whisper sub-protocol version.

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) Sender

func (tx *Transaction) Sender(oIndex *big.Int) (common.Address, error)

Sender returns owner address of TX input

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
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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