Documentation
¶
Index ¶
- Constants
- Variables
- func CreateEventMapper(eventFactory EventFactory, abi *abi.ABI) func(log types.Log) (interface{}, error)
- func UnpackLog(out interface{}, event string, log types.Log, ab *abi.ABI) error
- func WatchContractEvents(ctx context.Context, client EthereumClient, contractAddr common.Address, ...) (*lib.Subscription, error)
- type CloseListererFunc
- type CloseReason
- type CloseoutType
- type DataAccess
- type EthereumClient
- type EventFactory
- type EventMapper
- type HashrateEthereum
- func (g *HashrateEthereum) ClaimValidatorReward(ctx context.Context, contractID string, privKey string) error
- func (g *HashrateEthereum) CloseContract(ctx context.Context, contractID string, closeoutType CloseoutType, ...) error
- func (s *HashrateEthereum) CreateCloneFactorySubscription(ctx context.Context, clonefactoryAddr common.Address) (*lib.Subscription, error)
- func (s *HashrateEthereum) CreateImplementationSubscription(ctx context.Context, contractAddr common.Address) (*lib.Subscription, error)
- func (g *HashrateEthereum) EarlyClose(ctx context.Context, contractID string, reason CloseReason, privKey string) error
- func (g *HashrateEthereum) GetContract(ctx context.Context, contractID string) (*hashrate.EncryptedTerms, error)
- func (g *HashrateEthereum) GetContractsIDs(ctx context.Context) ([]string, error)
- func (g *HashrateEthereum) GetLumerinAddress(ctx context.Context) (common.Address, error)
- func (g *HashrateEthereum) PurchaseContract(ctx context.Context, contractID string, privKey string, version int) error
- func (g *HashrateEthereum) SetLegacyTx(legacyTx bool)
Constants ¶
View Source
const RECONNECT_TIMEOUT = 2 * time.Second
Variables ¶
View Source
var ( ErrNoEventSignature = errors.New("no event signature") ErrEventSignatureMismatch = errors.New("event signature mismatch") )
View Source
var (
ErrNotRunning = fmt.Errorf("the contract is not in the running state")
)
View Source
var (
ErrUnknownEvent = errors.New("unknown event")
)
Functions ¶
func CreateEventMapper ¶
func UnpackLog ¶
UnpackLog unpacks the log into the provided struct, copied from go-ethereum implementation
func WatchContractEvents ¶
func WatchContractEvents(ctx context.Context, client EthereumClient, contractAddr common.Address, mapper EventMapper, log interfaces.ILogger) (*lib.Subscription, error)
WatchContractEvents watches for all events from the contract and converts them to the concrete type, using mapper
Types ¶
type CloseListererFunc ¶
type CloseListererFunc = func()
type CloseReason ¶
type CloseReason uint8
const ( CloseReasonUnspecified CloseReason = 0 CloseReasonUnderdelivery CloseReason = 1 )
type CloseoutType ¶
type CloseoutType uint8
const ( CloseoutTypeCancel CloseoutType = 0 // to be triggered by the buyer or validator if a contract needs to be canceled early for any reason CloseoutTypeOnlyWithdraw CloseoutType = 1 // to be triggered by the seller to withdraw funds at any time during the smart contracts lifecycle (contract is not closing) CloseoutTypeWithoutClaim CloseoutType = 2 // closeout without claiming funds CloseoutTypeWithClaim CloseoutType = 3 // closeout with claiming funds )
type DataAccess ¶
type DataAccess interface {
// string used as address cause different blockchains may return different type of addresses
GetContractsIDs() ([]string, error)
GetContract(contractID string) (interface{}, error)
CloseContract(contractID string, meta interface{}) error
OnNewContract(func(contractID string)) CloseListererFunc
OnContractUpdated(contractID string, cb func()) CloseListererFunc
OnContractClosed(contractID string, cb func()) CloseListererFunc
}
type EthereumClient ¶
type EthereumClient interface {
bind.ContractBackend
bind.DeployBackend
ChainID(ctx context.Context) (*big.Int, error)
BalanceAt(ctx context.Context, addr common.Address, blockNumber *big.Int) (*big.Int, error)
StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error)
}
type EventFactory ¶
type EventFactory func(name string) interface{}
type EventMapper ¶
type HashrateEthereum ¶
type HashrateEthereum struct {
// contains filtered or unexported fields
}
func NewHashrateEthereum ¶
func NewHashrateEthereum(clonefactoryAddr common.Address, client EthereumClient, log interfaces.ILogger) *HashrateEthereum
func (*HashrateEthereum) ClaimValidatorReward ¶
func (*HashrateEthereum) CloseContract ¶
func (g *HashrateEthereum) CloseContract(ctx context.Context, contractID string, closeoutType CloseoutType, privKey string) error
func (*HashrateEthereum) CreateCloneFactorySubscription ¶
func (s *HashrateEthereum) CreateCloneFactorySubscription(ctx context.Context, clonefactoryAddr common.Address) (*lib.Subscription, error)
func (*HashrateEthereum) CreateImplementationSubscription ¶
func (s *HashrateEthereum) CreateImplementationSubscription(ctx context.Context, contractAddr common.Address) (*lib.Subscription, error)
func (*HashrateEthereum) EarlyClose ¶
func (g *HashrateEthereum) EarlyClose(ctx context.Context, contractID string, reason CloseReason, privKey string) error
func (*HashrateEthereum) GetContract ¶
func (g *HashrateEthereum) GetContract(ctx context.Context, contractID string) (*hashrate.EncryptedTerms, error)
func (*HashrateEthereum) GetContractsIDs ¶
func (g *HashrateEthereum) GetContractsIDs(ctx context.Context) ([]string, error)
func (*HashrateEthereum) GetLumerinAddress ¶
func (*HashrateEthereum) PurchaseContract ¶
func (*HashrateEthereum) SetLegacyTx ¶
func (g *HashrateEthereum) SetLegacyTx(legacyTx bool)
Click to show internal directories.
Click to hide internal directories.