chain3

package
v0.0.0-...-c10cd6e Latest Latest
Warning

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

Go to latest
Published: May 29, 2018 License: BSD-3-Clause Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChannelClosed = errors.New("Channel is closed")
)

Functions

This section is empty.

Types

type Chain3

type Chain3 struct {
	Mc  Mc
	Net Net
	// contains filtered or unexported fields
}

Chain3 Standard interface See https://github.com/ethereum/wiki/wiki/JavaScript-API#web3js-api-reference

func NewChain3

func NewChain3(provider provider.Provider) *Chain3

NewChain3 creates a new chain3 object.

func (*Chain3) CurrentProvider

func (chain3 *Chain3) CurrentProvider() provider.Provider

CurrentProvider returns the current provider.

func (*Chain3) CurrentRequestManager

func (chain3 *Chain3) CurrentRequestManager() *RequestManager

func (*Chain3) FromASCII

func (chain3 *Chain3) FromASCII(textString string, padding int) string

FromASCII converts any ASCII string to a HEX string.

func (*Chain3) FromDecimal

func (chain3 *Chain3) FromDecimal(value interface{}) string

FromDecimal converts value to it"s hex representation.

func (*Chain3) FromSha

func (chain3 *Chain3) FromSha(number string, unit string) string

FromWei takes a number of wei and converts it to any other ether unit.

Possible units are:

SI Short   SI Full        Effigy       Other

- kwei femtoether babbage - mwei picoether lovelace - gwei nanoether shannon nano - -- microether szabo micro - -- microether szabo micro - -- milliether finney milli - ether -- -- - kether -- grand - mether - gether - tether

func (*Chain3) IsAddress

func (chain3 *Chain3) IsAddress(address string) bool

IsAddress checks if the given string is an address.

func (*Chain3) IsConnected

func (chain3 *Chain3) IsConnected() bool

IsConnected checks if a connection to a node exists.

func (*Chain3) Reset

func (chain3 *Chain3) Reset(keepSyncing bool)

Reset state of chain3. Resets everything except manager. Uninstalls all filters. Stops polling. If keepSyncing is true, it will uninstall all filters, but will keep the chain3.mc.IsSyncing() polls.

func (*Chain3) SetProvider

func (chain3 *Chain3) SetProvider(provider provider.Provider)

SetProvider sets provider.

func (*Chain3) Sha3

func (chain3 *Chain3) Sha3(data string, options interface{}) string

Sha3 returns Keccak-256 (not the standardized SHA3-256) of the given data.

func (*Chain3) ToASCII

func (chain3 *Chain3) ToASCII(hexString string) string

ToASCII converts a HEX string into a ASCII string.

func (*Chain3) ToBigNumber

func (chain3 *Chain3) ToBigNumber(value interface{}) (result *big.Rat)

ToBigNumber takes an input and transforms it into an *big.Rat.

func (*Chain3) ToDecimal

func (chain3 *Chain3) ToDecimal(value interface{}) string

ToDecimal converts value to it"s decimal representation in string.

func (*Chain3) ToHex

func (chain3 *Chain3) ToHex(value interface{}) string

ToHex converts any value into HEX.

func (*Chain3) ToSha

func (chain3 *Chain3) ToSha(number interface{}, unit string) string

ToWei takes a number of a unit and converts it to wei.

Possible units are:

SI Short   SI Full        Effigy       Other

- kwei femtoether babbage - mwei picoether lovelace - gwei nanoether shannon nano - -- microether szabo micro - -- microether szabo micro - -- milliether finney milli - ether -- -- - kether -- grand - mether - gether - tether

type Filter

type Filter interface {
	Watch() WatchChannel
	ID() string
}

Filter ...

type FilterOption

type FilterOption struct {
	FromBlock string        `json:"fromBlock,omitempty"`
	ToBlock   string        `json:"toBlock,omitempty"`
	Address   interface{}   `json:"address,omitempty"`
	Topics    []common.Data `json:"topics,omitempty"`
}

FilterOption ...

func (*FilterOption) String

func (opt *FilterOption) String() string

type FilterType

type FilterType int
const (
	TypeNormal FilterType = iota
	TypeBlockFilter
	TypeTransactionFilter
)

type JSONBlock

type JSONBlock struct {
	Difficulty       json.Number `json:"difficulty"`
	ExtraData        string      `json:"extraData"`
	GasLimit         json.Number `json:"gasLimit"`
	GasUsed          json.Number `json:"gasUsed"`
	Hash             string      `json:"hash"`
	LogsBloom        string      `json:"logsBloom"`
	Miner            string      `json:"miner"`
	MixHash          string      `json:"mixHash"`
	Nonce            string      `json:"nonce"`
	Number           json.Number `json:"number"`
	ParentHash       string      `json:"parentHash"`
	ReceiptsRoot     string      `json:"receiptsRoot"`
	Sha3Uncles       string      `json:"sha3Uncles"`
	Size             json.Number `json:"size"`
	StateRoot        string      `json:"stateRoot"`
	Timestamp        json.Number `json:"timestamp"`
	TotalDifficulty  json.Number `json:"totalDifficulty"`
	Transactions     []string    `json:"transactions"`
	TransactionsRoot string      `json:"transactionsRoot"`
	Uncles           []string    `json:"uncles"`
}

func (*JSONBlock) ToBlock

func (b *JSONBlock) ToBlock() (block *common.Block)

type JSONLog

type JSONLog struct {
	TxData           string      `json:"TxData"`
	Address          string      `json:"address"`
	BlockHash        string      `json:"blockHash"`
	BlockNumber      json.Number `json:"blockNumber"`
	LogIndex         json.Number `json:"logIndex"`
	Removed          bool        `json:"removed"`
	Topics           []string    `json:"topics"`
	TransactionHash  string      `json:"transactionHash"`
	TransactionIndex json.Number `json:"transactionIndex"`
}

func (JSONLog) ToLog

func (l JSONLog) ToLog() (log common.Log)

type JSONTransaction

type JSONTransaction struct {
	BlockHash        string      `json:"blockHash"`
	BlockNumber      json.Number `json:"blockNumber"`
	From             string      `json:"from"`
	Gas              json.Number `json:"gas"`
	GasPrice         json.Number `json:"gasprice"`
	Hash             string      `json:"hash"`
	Input            string      `json:"input"`
	Nonce            json.Number `json:"nonce"`
	R                string      `json:"r"`
	S                string      `json:"s"`
	ShardingFlag     string      `json:"shardingFlag"`
	SysCnt           string      `json:"syscnt"`
	To               string      `json:"to"`
	TransactionIndex json.Number `json:"transactionIndex"`
	V                string      `json:"v"`
	Value            json.Number `json:"value"`
}

func (*JSONTransaction) ToTransaction

func (t *JSONTransaction) ToTransaction() (tx *common.Transaction)

type JSONTransactionReceipt

type JSONTransactionReceipt struct {
	BlockHash         string      `json:"blockHash"`
	BlockNumber       json.Number `json:"blockNumber"`
	ContractAddress   string      `json:"contractAddress"`
	CumulativeGasUsed json.Number `json:"cumulativeGasUsed"`
	From              string      `json:"from"`
	GasUsed           json.Number `json:"gasUsed"`
	Logs              []JSONLog   `json:"logs"`
	LogsBloom         string      `json:"logsBloom"`
	Root              string      `json:"root"`
	To                string      `json:"to"`
	TransactionHash   string      `json:"transactionHash"`
	TransactionIndex  json.Number `json:"transactionIndex"`
}

func (*JSONTransactionReceipt) ToTransactionReceipt

func (r *JSONTransactionReceipt) ToTransactionReceipt() (receipt *common.TransactionReceipt)

type Mc

type Mc interface {
	ProtocolVersion() (string, error)
	Syncing() (common.SyncStatus, error)
	Coinbase() (common.Address, error)
	Mining() (bool, error)
	HashRate() (uint64, error)
	GasPrice() (*big.Int, error)
	Accounts() ([]common.Address, error)
	BlockNumber() (*big.Int, error)
	GetBalance(address common.Address, quantity string) (*big.Int, error)
	GetStorageAt(address common.Address, position uint64, quantity string) (uint64, error)
	GetTransactionCount(address common.Address, quantity string) (*big.Int, error)
	GetBlockTransactionCountByHash(hash common.Hash) (*big.Int, error)
	GetBlockTransactionCountByNumber(quantity string) (*big.Int, error)
	GetUncleCountByBlockHash(hash common.Hash) (*big.Int, error)
	GetUncleCountByBlockNumber(quantity string) (*big.Int, error)
	GetCode(address common.Address, quantity string) ([]byte, error)
	Sign(address common.Address, data []byte) ([]byte, error)
	SendTransaction(tx *common.TransactionRequest) (common.Hash, error)
	SendRawTransaction(tx []byte) (common.Hash, error)
	Call(tx *common.TransactionRequest, quantity string) ([]byte, error)
	EstimateGas(tx *common.TransactionRequest, quantity string) (*big.Int, error)
	GetBlockByHash(hash common.Hash, full bool) (*common.Block, error)
	GetBlockByNumber(quantity string, full bool) (*common.Block, error)
	GetTransactionByHash(hash common.Hash) (*common.Transaction, error)
	GetTransactionByBlockHashAndIndex(hash common.Hash, index uint64) (*common.Transaction, error)
	GetTransactionByBlockNumberAndIndex(quantity string, index uint64) (*common.Transaction, error)
	GetTransactionReceipt(hash common.Hash) (*common.TransactionReceipt, error)
	GetUncleByBlockHashAndIndex(hash common.Hash, index uint64) (*common.Block, error)
	GetUncleByBlockNumberAndIndex(quantity string, index uint64) (*common.Block, error)
	GetCompilers() ([]string, error)
	// GompileLLL
	// CompileSolidity
	// CompileSerpent
	NewFilter(option *FilterOption) (Filter, error)
	NewBlockFilter() (Filter, error)
	NewPendingTransactionFilter() (Filter, error)
	UninstallFilter(filter Filter) (bool, error)
	GetFilterChanges(filter Filter) ([]interface{}, error)
	GetFilterLogs(filter Filter) ([]interface{}, error)
	GetLogs(filter Filter) ([]interface{}, error)
	GetWork() (common.Hash, common.Hash, common.Hash, error)
	SubmitWork(nonce uint64, header common.Hash, mixDigest common.Hash) (bool, error)
}

Mc ...

type MoacAPI

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

MoacAPI ...

func (*MoacAPI) Accounts

func (mc *MoacAPI) Accounts() (addrs []common.Address, err error)

Accounts returns a list of addresses owned by client.

func (*MoacAPI) BlockNumber

func (mc *MoacAPI) BlockNumber() (result *big.Int, err error)

BlockNumber returns the number of most recent block.

func (*MoacAPI) Call

func (mc *MoacAPI) Call(tx *common.TransactionRequest, quantity string) ([]byte, error)

Call executes a new message call immediately without creating a transaction on the block chain.

func (*MoacAPI) Coinbase

func (mc *MoacAPI) Coinbase() (addr common.Address, err error)

Coinbase returns the client coinbase address.

func (*MoacAPI) EstimateGas

func (mc *MoacAPI) EstimateGas(tx *common.TransactionRequest, quantity string) (result *big.Int, err error)

EstimateGas makes a call or transaction, which won't be added to the blockchain and returns the used gas, which can be used for estimating the used gas.

func (*MoacAPI) GasPrice

func (mc *MoacAPI) GasPrice() (result *big.Int, err error)

GasPrice returns the current price per gas in wei.

func (*MoacAPI) GetBalance

func (mc *MoacAPI) GetBalance(address common.Address, quantity string) (result *big.Int, err error)

GetBalance returns the balance of the account of given address.

func (*MoacAPI) GetBlockByHash

func (mc *MoacAPI) GetBlockByHash(hash common.Hash, full bool) (*common.Block, error)

GetBlockByHash returns information about a block by hash.

func (*MoacAPI) GetBlockByNumber

func (mc *MoacAPI) GetBlockByNumber(quantity string, full bool) (*common.Block, error)

GetBlockByNumber returns information about a block by block number.

func (*MoacAPI) GetBlockTransactionCountByHash

func (mc *MoacAPI) GetBlockTransactionCountByHash(hash common.Hash) (result *big.Int, err error)

GetBlockTransactionCountByHash returns the number of transactions in a block from a block matching the given block hash.

func (*MoacAPI) GetBlockTransactionCountByNumber

func (mc *MoacAPI) GetBlockTransactionCountByNumber(quantity string) (result *big.Int, err error)

GetBlockTransactionCountByNumber returns the number of transactions in a block from a block matching the given block number.

func (*MoacAPI) GetCode

func (mc *MoacAPI) GetCode(address common.Address, quantity string) ([]byte, error)

GetCode returns code at a given address.

func (*MoacAPI) GetCompilers

func (mc *MoacAPI) GetCompilers() (result []string, err error)

GetCompilers returns a list of available compilers in the client.

func (*MoacAPI) GetFilterChanges

func (mc *MoacAPI) GetFilterChanges(filter Filter) (result []interface{}, err error)

GetFilterChanges polling mmcod for a filter, which returns an array of logs which occurred since last poll.

func (*MoacAPI) GetFilterLogs

func (mc *MoacAPI) GetFilterLogs(filter Filter) (result []interface{}, err error)

GetFilterLogs returns an array of all logs matching filter with given id.

func (*MoacAPI) GetLogs

func (mc *MoacAPI) GetLogs(filter Filter) (result []interface{}, err error)

GetLogs returns an array of all logs matching a given filter object.

func (*MoacAPI) GetStorageAt

func (mc *MoacAPI) GetStorageAt(address common.Address, position uint64, quantity string) (uint64, error)

GetStorageAt returns the value from a storage position at a given address.

func (*MoacAPI) GetTransactionByBlockHashAndIndex

func (mc *MoacAPI) GetTransactionByBlockHashAndIndex(hash common.Hash, index uint64) (*common.Transaction, error)

GetTransactionByBlockHashAndIndex returns information about a transaction by block hash and transaction index position.

func (*MoacAPI) GetTransactionByBlockNumberAndIndex

func (mc *MoacAPI) GetTransactionByBlockNumberAndIndex(quantity string, index uint64) (*common.Transaction, error)

GetTransactionByBlockNumberAndIndex returns information about a transaction by block number and transaction index position.

func (*MoacAPI) GetTransactionByHash

func (mc *MoacAPI) GetTransactionByHash(hash common.Hash) (*common.Transaction, error)

GetTransactionByHash returns the information about a transaction requested by transaction hash.

func (*MoacAPI) GetTransactionCount

func (mc *MoacAPI) GetTransactionCount(address common.Address, quantity string) (result *big.Int, err error)

GetTransactionCount returns the number of transactions sent from an address.

func (*MoacAPI) GetTransactionReceipt

func (mc *MoacAPI) GetTransactionReceipt(hash common.Hash) (*common.TransactionReceipt, error)

GetTransactionReceipt Returns the receipt of a transaction by transaction hash.

func (*MoacAPI) GetUncleByBlockHashAndIndex

func (mc *MoacAPI) GetUncleByBlockHashAndIndex(hash common.Hash, index uint64) (*common.Block, error)

GetUncleByBlockHashAndIndex returns information about a uncle of a block by hash and uncle index position.

func (*MoacAPI) GetUncleByBlockNumberAndIndex

func (mc *MoacAPI) GetUncleByBlockNumberAndIndex(quantity string, index uint64) (*common.Block, error)

GetUncleByBlockNumberAndIndex returns information about a uncle of a block by number and uncle index position.

func (*MoacAPI) GetUncleCountByBlockHash

func (mc *MoacAPI) GetUncleCountByBlockHash(hash common.Hash) (result *big.Int, err error)

GetUncleCountByBlockHash returns the number of uncles in a block from a block matching the given block hash.

func (*MoacAPI) GetUncleCountByBlockNumber

func (mc *MoacAPI) GetUncleCountByBlockNumber(quantity string) (result *big.Int, err error)

GetUncleCountByBlockNumber returns the number of uncles in a block from a block matching the given block number.

func (*MoacAPI) GetWork

func (mc *MoacAPI) GetWork() (header, seed, boundary common.Hash, err error)

GetWork returns the hash of the current block, the seedHash, and the boundary condition to be met ("target").

func (*MoacAPI) HashRate

func (mc *MoacAPI) HashRate() (uint64, error)

HashRate returns the number of hashes per second that the node is mining with.

func (*MoacAPI) Mining

func (mc *MoacAPI) Mining() (bool, error)

Mining returns true if client is actively mining new blocks.

func (*MoacAPI) NewBlockFilter

func (mc *MoacAPI) NewBlockFilter() (Filter, error)

NewBlockFilter creates a filter in the node, to notify when a new block arrives. To check if the state has changed, call mc_getFilterChanges.

func (*MoacAPI) NewFilter

func (mc *MoacAPI) NewFilter(option *FilterOption) (Filter, error)

NewFilter creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call mc_getFilterChanges.

func (*MoacAPI) NewPendingTransactionFilter

func (mc *MoacAPI) NewPendingTransactionFilter() (Filter, error)

NewPendingTransactionFilter creates a filter in the node, to notify when new pending transactions arrive. To check if the state has changed, call mc_getFilterChanges.

func (*MoacAPI) ProtocolVersion

func (mc *MoacAPI) ProtocolVersion() (string, error)

ProtocolVersion returns the current ethereum protocol version.

func (*MoacAPI) SendRawTransaction

func (mc *MoacAPI) SendRawTransaction(tx []byte) (hash common.Hash, err error)

SendRawTransaction creates new message call transaction or a contract creation for signed transactions.

func (*MoacAPI) SendTransaction

func (mc *MoacAPI) SendTransaction(tx *common.TransactionRequest) (hash common.Hash, err error)

SendTransaction creates new message call transaction or a contract creation, if the data field contains code.

func (*MoacAPI) Sign

func (mc *MoacAPI) Sign(address common.Address, data []byte) ([]byte, error)

Sign signs data with a given address.

func (*MoacAPI) SubmitWork

func (mc *MoacAPI) SubmitWork(nonce uint64, header, mixDigest common.Hash) (bool, error)

SubmitWork is used for submitting a proof-of-work solution.

func (*MoacAPI) Syncing

func (mc *MoacAPI) Syncing() (common.SyncStatus, error)

Syncing returns true with an object with data about the sync status or false with nil.

func (*MoacAPI) UninstallFilter

func (mc *MoacAPI) UninstallFilter(filter Filter) (bool, error)

UninstallFilter uninstalls a filter with given id. Should always be called when watch is no longer needed. Additonally Filters timeout when they aren't requested with mc_getFilterChanges for a period of time.

type Net

type Net interface {
	Version() (string, error)
	PeerCount() (uint64, error)
	Listening() (bool, error)
}

Net ...

type NetAPI

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

NetAPI ...

func (*NetAPI) Listening

func (net *NetAPI) Listening() (bool, error)

Listening returns true if client is actively listening for network connections.

func (*NetAPI) PeerCount

func (net *NetAPI) PeerCount() (uint64, error)

PeerCount returns number of peers currenly connected to the client.

func (*NetAPI) Version

func (net *NetAPI) Version() (string, error)

Version returns the current network protocol version.

type RequestManager

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

requestManager is responsible for passing messages to providers

func NewRequestManager

func NewRequestManager(provider provider.Provider) *RequestManager

func (*RequestManager) NewRequest

func (rm *RequestManager) NewRequest(method string) rpc.Request

func (*RequestManager) Send

func (rm *RequestManager) Send(request rpc.Request) (rpc.Response, error)

type WatchChannel

type WatchChannel interface {
	Next() (interface{}, error)
	Close()
}

WatchChannel ...

Jump to

Keyboard shortcuts

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