evm

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CACHE_PRICE = "1192092895"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheProtoContract

type CacheProtoContract struct {
	Address common.Address
	Node    common.Address

	NewOption  NewTransactionOption
	LogFilter  LogFilter[ethereum.FilterQuery]
	CacheProto *contract.CacheProto
	// contains filtered or unexported fields
}

func NewProtoContract

func NewProtoContract(cli *ethclient.Client, hexAddr, nodeSk string, optFunc NewTransactionOption, filter LogFilter[ethereum.FilterQuery]) (*CacheProtoContract, error)

func (*CacheProtoContract) CallFunc

func (pc *CacheProtoContract) CallFunc(funcName string, args ...any) (any, error)

func (*CacheProtoContract) ClaimOrder

func (pc *CacheProtoContract) ClaimOrder(ctx context.Context, orderId [32]byte) error

func (*CacheProtoContract) ClaimWorkReward

func (pc *CacheProtoContract) ClaimWorkReward(ctx context.Context, nodeAcc common.Address) (string, error)

func (*CacheProtoContract) ClaimWorkRewardServer

func (pc *CacheProtoContract) ClaimWorkRewardServer(ctx context.Context, nodeAcc common.Address) error

func (*CacheProtoContract) CreateCacheOrder

func (pc *CacheProtoContract) CreateCacheOrder(ctx context.Context, teeAcc common.Address, traffic string) (string, error)

func (*CacheProtoContract) ExitNetwork

func (pc *CacheProtoContract) ExitNetwork(ctx context.Context, nodeAcc common.Address) error

func (*CacheProtoContract) QueryCacheOrder

func (pc *CacheProtoContract) QueryCacheOrder(orderId [32]byte) (Order, error)

func (*CacheProtoContract) QueryCdnL1NodeByIndex

func (pc *CacheProtoContract) QueryCdnL1NodeByIndex(index int64) (common.Address, error)

func (*CacheProtoContract) QueryCurrencyTerm

func (pc *CacheProtoContract) QueryCurrencyTerm() (*big.Int, error)

func (*CacheProtoContract) QueryNodeReward

func (pc *CacheProtoContract) QueryNodeReward(nodeAcc common.Address) (string, error)

func (*CacheProtoContract) QueryRegisterInfo

func (pc *CacheProtoContract) QueryRegisterInfo(nodeAcc common.Address) (NodeInfo, error)

func (*CacheProtoContract) RegisterNode

func (pc *CacheProtoContract) RegisterNode(ctx context.Context, req RegisterReq) error

func (*CacheProtoContract) Signature

func (pc *CacheProtoContract) Signature(data []byte) ([]byte, error)

func (*CacheProtoContract) VerifySign

func (pc *CacheProtoContract) VerifySign(hash []byte, sign []byte) bool

type Client

type Client struct {
	RpcAddrs  []string
	ChainID   int64
	GasFeeCap *big.Int
	GasLimit  uint64

	Account common.Address

	Contracts map[string]Contract
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts ...Option) (*Client, error)

func (*Client) AddWorkContract

func (cli *Client) AddWorkContract(name string, contract Contract)

func (Client) GetContractAddress

func (cli Client) GetContractAddress(name string) Contract

func (Client) GetEthClient

func (cli Client) GetEthClient() *ethclient.Client

func (Client) GetPrivateKey

func (cli Client) GetPrivateKey() ecdsa.PrivateKey

func (Client) GetSignature

func (cli Client) GetSignature(data []byte) ([]byte, error)

func (Client) NewTransactionOption

func (cli Client) NewTransactionOption(ctx context.Context, value string) (*bind.TransactOpts, error)

func (Client) ParsingTransactionLogs

func (cli Client) ParsingTransactionLogs(ctx context.Context, tx *types.Transaction, callback func(types.Log) bool) error

func (Client) SubscribeFilterLogs

func (cli Client) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, callback func(types.Log) bool) error

func (*Client) UpdateClient

func (cli *Client) UpdateClient() error

func (Client) VerifySign

func (cli Client) VerifySign(data []byte, sign []byte) bool

type Contract

type Contract interface {
	CallFunc(funcName string, args ...any) (any, error)
}

type LogFilter

type LogFilter[T any] func(ctx context.Context, t T, callback func(types.Log) bool) error

type NewTransactionOption

type NewTransactionOption func(ctx context.Context, value string) (*bind.TransactOpts, error)

type NodeInfo

type NodeInfo struct {
	Created   bool
	Collerate *big.Int
	TokenId   *big.Int
	Endpoint  string
	TeeEth    common.Address
	TeeCess   []byte
}

type Option

type Option func(*Client) error

func AccountPrivateKey

func AccountPrivateKey(hexKey string) Option

func ChainID

func ChainID(id int64) Option

func ConnectionRpcAddresss

func ConnectionRpcAddresss(rpcs []string) Option

func EthereumGas

func EthereumGas(gasFeeCap int64, gasLimit uint64) Option

func NodeEthAccount

func NodeEthAccount(hexAcc string) Option

type Order

type Order struct {
	Value   *big.Int
	Creater common.Address
	Node    common.Address
	Term    *big.Int
}

type RegisterReq

type RegisterReq struct {
	NodeAcc   common.Address
	TokenAcc  common.Address
	TokenId   string
	Endpoint  string
	Signature []byte
	TeeEth    common.Address
	TeeCess   []byte
}

Jump to

Keyboard shortcuts

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