Documentation
¶
Index ¶
- Constants
- func ContextNodeReq() (context.Context, context.CancelFunc)
- func ContextWaitMined() (context.Context, context.CancelFunc)
- func EthToWeiFloat(ethv float64) *big.Int
- func EthToWeiInt(ethv int64) *big.Int
- func NewHdWallet(rng io.Reader) *hdwallet.Wallet
- func NewRandomAddress(rng *rand.Rand) common.Address
- func SetNodeReqTimeout(duration time.Duration)
- func SetWaitMinedTimeout(duration time.Duration)
- func WeiToEthFloat(weiv *big.Int) *big.Float
- func WeiToEthInt(weiv *big.Int) *big.Int
- type BlockSubscription
- type BlockSubscription2
- type Client
- func CreateEthereumClient(ctx context.Context, url string, wallet accounts.Wallet, a accounts.Account) (*Client, error)
- func NewClient(cb peruneth.ContractBackend, a accounts.Account) *Client
- func NewClientForWallet(ci peruneth.ContractInterface, w accounts.Wallet) (*Client, error)
- func NewClientForWalletAndAccount(ci peruneth.ContractInterface, w accounts.Wallet, a accounts.Account) *Client
- func (cl *Client) Account() accounts.Account
- func (cl *Client) BindContract(ctx context.Context, addr common.Address) (*tee.Parameters, *bindings.Erdstall, error)
- func (cl *Client) BlockByHash(ctx context.Context, hash common.Hash) (*tee.Block, error)
- func (cl *Client) DeployContracts(params *tee.Parameters) error
- func (cl *Client) NetworkID() (*big.Int, error)
- func (cl *Client) NewTransactor(ctx context.Context) (*bind.TransactOpts, error)
- func (cl *Client) NextNonce(ctx context.Context) (uint64, error)
- func (cl *Client) OnlyErdstallReceipts()
- func (cl *Client) SubscribeBlocks() (*BlockSubscription, error)
- func (cl *Client) SubscribeEpochs(ctx context.Context, params tee.Parameters, sink chan uint64, ...) error
- func (cl *Client) SubscribeExiting(ctx context.Context, contract *bindings.Erdstall, epochs []uint64, ...) (*ExitingSubscription, error)
- func (cl *Client) SubscribeFrozen(ctx context.Context, contract *bindings.Erdstall, epochs []uint64) (*FrozenSubscription, error)
- func (cl *Client) SubscribeVerifiedBlocksFrom(start uint64) (*BlockSubscription2, error)
- func (cl *Client) TransactionReceipts(ctx context.Context, block *types.Block) (types.Receipts, error)
- func (cl *Client) WaitForBlock(ctx context.Context, target uint64) error
- type DefaultTransactor
- type ExitingSubscription
- type FrozenSubscription
- type SimSetup
Constants ¶
const (
// DefaultGasLimit represents the default gas limit for this application.
DefaultGasLimit = 2000000
)
Variables ¶
This section is empty.
Functions ¶
func ContextNodeReq ¶
func ContextNodeReq() (context.Context, context.CancelFunc)
ContextNodeReq creates a node request timeout context (default: 2 sec). Use this context when performing a node request that doesn't wait for any blocks to be mined, e.g., setting up a subscription, sending a transaction (but not waiting for it to be mined).
Can be changed using SetNodeReqTimeout.
func ContextWaitMined ¶
func ContextWaitMined() (context.Context, context.CancelFunc)
ContextWaitMined creates a mining timeout context (default: 10 sec). Use this context when waiting for a transaction to be mined or similar.
Can be changed using SetWaitMinedTimeout.
func EthToWeiFloat ¶
func EthToWeiInt ¶
func NewRandomAddress ¶
NewRandomAddress creates a new random address.
func SetNodeReqTimeout ¶
SetNodeReqTimeout sets the timeout used when creating contexts with ContextNodeReq.
func SetWaitMinedTimeout ¶
SetWaitMinedTimeout sets the timeout used when creating contexts with ContextWaitMined.
Types ¶
type BlockSubscription ¶
type BlockSubscription struct {
// contains filtered or unexported fields
}
BlockSubscription represents a subscription to Ethereum blocks.
func (*BlockSubscription) Blocks ¶
func (sub *BlockSubscription) Blocks() <-chan *tee.Block
Blocks returns the channel on which to receive subscribed blocks.
func (*BlockSubscription) Unsubscribe ¶
func (sub *BlockSubscription) Unsubscribe()
Unsubscribe ends the subscription.
type BlockSubscription2 ¶
type BlockSubscription2 struct {
// contains filtered or unexported fields
}
BlockSubscription2 represents a subscription to Ethereum blocks, version 2.
func (*BlockSubscription2) Blocks ¶
func (blockSub *BlockSubscription2) Blocks() <-chan *tee.Block
Blocks returns the channel on which to receive subscribed blocks.
func (*BlockSubscription2) Unsubscribe ¶
func (blockSub *BlockSubscription2) Unsubscribe()
Unsubscribe ends the subscription.
type Client ¶
type Client struct { peruneth.ContractBackend // contains filtered or unexported fields }
Client is an Ethereum client to interact with the Erdstall contract.
func CreateEthereumClient ¶
func CreateEthereumClient(ctx context.Context, url string, wallet accounts.Wallet, a accounts.Account) (*Client, error)
CreateEthereumClient creates and connects a new ethereum client.
func NewClient ¶
func NewClient( cb peruneth.ContractBackend, a accounts.Account, ) *Client
NewClient creates a new Erdstall Ethereum client.
func NewClientForWallet ¶
NewClientForWallet returns a new Client using the given wallet as transactor. The first account is derived from the wallet and used as the account in the client.
func NewClientForWalletAndAccount ¶
func NewClientForWalletAndAccount( ci peruneth.ContractInterface, w accounts.Wallet, a accounts.Account, ) *Client
NewClientForWalletAndAccount creates a new Erdstall Ethereum client for the given wallet and account.
func (*Client) BindContract ¶
func (*Client) BlockByHash ¶
BlockByHash returns the block for the given block hash together with the block's transaction receipts.
func (*Client) DeployContracts ¶
func (cl *Client) DeployContracts(params *tee.Parameters) error
DeployContracts deploys the Erdstall contract to the blockchain. It updates the passed parameter's InitBlock and Contract fields.
func (*Client) NewTransactor ¶
NewTransactor creates a new transactor.
func (*Client) OnlyErdstallReceipts ¶
func (cl *Client) OnlyErdstallReceipts()
OnlyErdstallReceipts can be called during client setup to skip requesting transaction receipts. This affects all methods that create tee.Blocks.
func (*Client) SubscribeBlocks ¶
func (cl *Client) SubscribeBlocks() (*BlockSubscription, error)
SubscribeBlocks subscribes the client to the mined Ethereum blocks.
func (*Client) SubscribeEpochs ¶
func (cl *Client) SubscribeEpochs(ctx context.Context, params tee.Parameters, sink chan uint64, blockSink chan uint64) error
SubscribeEpochs writes new epochs into `sink`. Can be cancelled via ctx. Should be called in a go-routine, since it blocks. Future InitBlock numbers are not supported, so it will not return the 0. th epoch.
func (*Client) SubscribeExiting ¶
func (cl *Client) SubscribeExiting(ctx context.Context, contract *bindings.Erdstall, epochs []uint64, accs []common.Address) (*ExitingSubscription, error)
SubscribeExiting writes received Exiting events into the Subscription. The `epochs` and `accs` arguments can be used to filter for specific events. Passing `nil` will skip the filtering. Can be cancelled via Unsubscribe.
func (*Client) SubscribeFrozen ¶
func (cl *Client) SubscribeFrozen(ctx context.Context, contract *bindings.Erdstall, epochs []uint64) (*FrozenSubscription, error)
SubscribeFrozen writes received Frozen events into the Subscription. The `epochs` argument can be used to filter for specific events. Passing `nil` will skip the filtering. Can be cancelled via Unsubscribe.
func (*Client) SubscribeVerifiedBlocksFrom ¶
func (cl *Client) SubscribeVerifiedBlocksFrom(start uint64) (*BlockSubscription2, error)
SubscribeVerifiedBlocksFrom subscribes the client to newly mined blocks starting from the given block number.
It only pushes blocks onto the subscription that are pow-depth deep from the tip of the chain.
type DefaultTransactor ¶
type DefaultTransactor struct {
// contains filtered or unexported fields
}
DefaultTransactor can be used to make TransactOpts for accounts stored in a HD wallet.
func NewDefaultTransactor ¶
func NewDefaultTransactor(w accounts.Wallet) *DefaultTransactor
NewDefaultTransactor returns a backend that can make TransactOpts for accounts contained in the given HD wallet.
func (*DefaultTransactor) NewTransactor ¶
func (t *DefaultTransactor) NewTransactor(account accounts.Account) (*bind.TransactOpts, error)
NewTransactor returns a TransactOpts for the given account. It errors if the account is not contained in the wallet used for initializing transactor backend.
type ExitingSubscription ¶
type ExitingSubscription struct {
// contains filtered or unexported fields
}
func (*ExitingSubscription) Err ¶
func (s *ExitingSubscription) Err() <-chan error
func (*ExitingSubscription) Events ¶
func (s *ExitingSubscription) Events() <-chan *bindings.ErdstallExiting
func (*ExitingSubscription) Unsubscribe ¶
func (s *ExitingSubscription) Unsubscribe()
type FrozenSubscription ¶
type FrozenSubscription struct {
// contains filtered or unexported fields
}
func (*FrozenSubscription) Err ¶
func (s *FrozenSubscription) Err() <-chan error
func (*FrozenSubscription) Events ¶
func (s *FrozenSubscription) Events() <-chan *bindings.ErdstallFrozen
func (*FrozenSubscription) Unsubscribe ¶
func (s *FrozenSubscription) Unsubscribe()
type SimSetup ¶
type SimSetup struct { SimBackend *chtest.SimulatedBackend // A simulated blockchain backend Accounts []accounts.Account // funded accounts CB *ethchannel.ContractBackend // contract backend that can transact for all accounts Wallet *hd.Wallet // Wallet containing accounts (Perun wrapper) HdWallet *hdwallet.Wallet // Wallet containing accounts (original) }