chain

package
v0.0.0-...-da31739 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2018 License: LGPL-3.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Set

func Set(t ChainType, blc Chain)

Set register or update the underlying chain instance of the given chain type

Types

type Chain

type Chain interface {
	GetContract(addr []byte, contractType string) (interface{}, error)
	NewContract(ctx context.Context, from []byte, contractType string, contractData interface{}) (*transaction.Transaction, error)
	Call(ctx context.Context, from []byte, contractType string, contractAddr []byte, methodName string, value *big.Int, callData interface{}) (*transaction.Transaction, error)
	Query(ctx context.Context, addr []byte, abiString string, methodName string, result interface{}, params ...interface{}) error
	CallWithAbi(ctx context.Context, from []byte, contractAddr []byte, methodName string, value *big.Int, callData interface{}, abiStr string) (*transaction.Transaction, error)
	ConfirmTrans(ctx context.Context, trans *transaction.Transaction, sig []byte) error
	WaitMined(ctx context.Context, trans *transaction.Transaction) error
	BalanceAt(ctx context.Context, addr []byte) (*big.Int, error)
	BalanceAtICST(ctx context.Context, addr []byte) (*big.Int, error)
	PubKeyToAddress(pub *ecdsa.PublicKey) []byte
	UnmarshalPubkey(pub string) (*ecdsa.PublicKey, error)
	MarshalPubKey(pub *ecdsa.PublicKey) string
	GenerateKey(ctx context.Context) (*ecdsa.PrivateKey, error)
	Sign(hash []byte, prv *ecdsa.PrivateKey) (sig []byte, err error)
	Transfer(ctx context.Context, from []byte, to []byte, value *big.Int) (*transaction.Transaction, error)
	TransferICST(ctx context.Context, from []byte, to []byte, value *big.Int) (*transaction.Transaction, error)
	WatchBlocks(ctx context.Context, blockStart *big.Int) (<-chan *transaction.Block, <-chan error)
	WatchICSTTransfer(ctx context.Context, blockStart *big.Int) (<-chan *transaction.Block, <-chan error)

	GetContractEvents(ctx context.Context, addr []byte, fromBlock, toBlock *big.Int, abiString string, eventTypes map[string]reflect.Type) ([]*ContractEvent, error)
}

func Get

func Get(t ChainType) (Chain, error)

Get returns the underlying chain instance of the given chain type. Error returned if no chain initialized yet.

type ChainType

type ChainType int

ChainType defines the type of underlying blockchain

const (
	//Eth blockchain
	Eth ChainType = 0
	//EOS blockchain
	EOS ChainType = 1
)

type ContractEvent

type ContractEvent struct {
	Addr      []byte       //contract address
	Name      string       //event name
	T         reflect.Type //type of underlying chain specific contract event
	V         interface{}  //underlying chain specific contract event
	BlockNum  uint64
	BlockHash []byte
	TxIndex   uint64
	TxHash    []byte
	Unwatch   func() `json:"-"` //unwatch the event at any time
}

type ContractType

type ContractType string
const (
	ContentContractType ContractType = "Content"
	SkillContractType   ContractType = "Skill"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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