Documentation
¶
Index ¶
- Constants
- Variables
- func EstimateGas(wallet *bind.TransactOpts) (opts *bind.TransactOpts)
- func SetGas(wallet *bind.TransactOpts, gasLimit uint64) (opts *bind.TransactOpts)
- type AddOns
- type EthereumClient
- type Group
- type Licenses
- type MethodPricing
- type MockProcessor
- func (m *MockProcessor) Close()
- func (m *MockProcessor) CompareWithLatestBlockNumber(blockNumberPassed *big.Int, allowedBlockChainDifference uint64) error
- func (m *MockProcessor) ConnectToWsClient() error
- func (m *MockProcessor) CurrentBlock() (*big.Int, error)
- func (m *MockProcessor) Enabled() bool
- func (m *MockProcessor) EscrowContractAddress() common.Address
- func (m *MockProcessor) GetEthHttpClient() *ethclient.Client
- func (m *MockProcessor) GetEthWSClient() *ethclient.Client
- func (m *MockProcessor) HasIdentity() bool
- func (m *MockProcessor) MultiPartyEscrow() *MultiPartyEscrow
- func (m *MockProcessor) MultiPartyEscrowChannel(channelID *big.Int) (channel *MultiPartyEscrowChannel, ok bool, err error)
- func (m *MockProcessor) ReconnectToWsClient() error
- type MultiPartyEscrowChannel
- type OrganizationGroup
- type OrganizationMetaData
- func (metaData *OrganizationMetaData) GetConnectionTimeOut() (connectionTimeOut time.Duration)
- func (metaData *OrganizationMetaData) GetGroupId() [32]byte
- func (metaData *OrganizationMetaData) GetGroupIdString() string
- func (metaData *OrganizationMetaData) GetLicenseEndPoints() []string
- func (metaData *OrganizationMetaData) GetPaymentAddress() common.Address
- func (metaData *OrganizationMetaData) GetPaymentExpirationThreshold() *big.Int
- func (metaData *OrganizationMetaData) GetPaymentStorageEndPoints() []string
- func (metaData *OrganizationMetaData) GetRequestTimeOut() time.Duration
- type Payment
- type PaymentChannelStorageClient
- type Pricing
- type PricingDetails
- type Processor
- type ServiceMetadata
- func (metaData *ServiceMetadata) FreeCallSignerAddress() common.Address
- func (metaData *ServiceMetadata) GetDefaultPricing() Pricing
- func (metaData *ServiceMetadata) GetDisplayName() string
- func (metaData *ServiceMetadata) GetDynamicPricingMethodAssociated(methodFullName string) (pricingMethod string, isDynamicPricingEligible bool)
- func (metaData *ServiceMetadata) GetFreeCallsAllowed() int
- func (metaData *ServiceMetadata) GetLicenses() Licenses
- func (metaData *ServiceMetadata) GetMpeAddress() common.Address
- func (metaData *ServiceMetadata) GetServiceType() string
- func (metaData *ServiceMetadata) GetVersion() int
- func (metaData *ServiceMetadata) GetWireEncoding() string
- func (metaData *ServiceMetadata) IsFreeCallAllowed() bool
- func (metaData *ServiceMetadata) IsModelTraining(methodFullName string) (useModelTrainingEndPoint bool)
- type SimulatedEthereumEnvironment
- func (env *SimulatedEthereumEnvironment) Commit() *SimulatedEthereumEnvironment
- func (env *SimulatedEthereumEnvironment) MpeDeposit(from *bind.TransactOpts, amount int64) *SimulatedEthereumEnvironment
- func (env *SimulatedEthereumEnvironment) MpeOpenChannel(from *bind.TransactOpts, to *bind.TransactOpts, amount int64, expiration int64, ...) *SimulatedEthereumEnvironment
- func (env *SimulatedEthereumEnvironment) SnetApproveMpe(from *bind.TransactOpts, amount int64) *SimulatedEthereumEnvironment
- func (env *SimulatedEthereumEnvironment) SnetTransferTokens(to *bind.TransactOpts, amount int64) *SimulatedEthereumEnvironment
- type Subscription
- type Subscriptions
- type Tier
- type TierRange
- type Tiers
Constants ¶
const MockedCurrentBlock = 100
Variables ¶
var ( // HashPrefix32Bytes is an Ethereum signature prefix: see https://github.com/ethereum/go-ethereum/blob/bf468a81ec261745b25206b2a596eb0ee0a24a74/internal/ethapi/api.go#L361 HashPrefix32Bytes = []byte("\x19Ethereum Signed Message:\n32") )
Functions ¶
func EstimateGas ¶
func EstimateGas(wallet *bind.TransactOpts) (opts *bind.TransactOpts)
func SetGas ¶
func SetGas(wallet *bind.TransactOpts, gasLimit uint64) (opts *bind.TransactOpts)
Types ¶
type EthereumClient ¶
func CreateHTTPEthereumClient ¶
func CreateHTTPEthereumClient() (*EthereumClient, error)
func CreateWSEthereumClient ¶
func CreateWSEthereumClient() (*EthereumClient, error)
func (*EthereumClient) Close ¶
func (ethereumClient *EthereumClient) Close()
type Group ¶
type Group struct {
GroupName string `json:"group_name"`
GroupID string `json:"group_id"`
PaymentDetails Payment `json:"payment"`
LicenseEndpoints []string `json:"license_server_endpoints"`
}
Group Structure to hold the individual group details, an Organization can have multiple groups
type Licenses ¶
type Licenses struct {
Subscriptions Subscriptions `json:"subscriptions,omitempty"`
Tiers []Tier `json:"tiers"`
}
type MethodPricing ¶
type MockProcessor ¶
func NewMockProcessor ¶
func NewMockProcessor(enabled bool) *MockProcessor
func (*MockProcessor) Close ¶
func (m *MockProcessor) Close()
func (*MockProcessor) CompareWithLatestBlockNumber ¶
func (m *MockProcessor) CompareWithLatestBlockNumber(blockNumberPassed *big.Int, allowedBlockChainDifference uint64) error
func (*MockProcessor) ConnectToWsClient ¶
func (m *MockProcessor) ConnectToWsClient() error
func (*MockProcessor) CurrentBlock ¶
func (m *MockProcessor) CurrentBlock() (*big.Int, error)
func (*MockProcessor) Enabled ¶
func (m *MockProcessor) Enabled() bool
func (*MockProcessor) EscrowContractAddress ¶
func (m *MockProcessor) EscrowContractAddress() common.Address
func (*MockProcessor) GetEthHttpClient ¶
func (m *MockProcessor) GetEthHttpClient() *ethclient.Client
func (*MockProcessor) GetEthWSClient ¶
func (m *MockProcessor) GetEthWSClient() *ethclient.Client
func (*MockProcessor) HasIdentity ¶
func (m *MockProcessor) HasIdentity() bool
func (*MockProcessor) MultiPartyEscrow ¶
func (m *MockProcessor) MultiPartyEscrow() *MultiPartyEscrow
func (*MockProcessor) MultiPartyEscrowChannel ¶
func (m *MockProcessor) MultiPartyEscrowChannel(channelID *big.Int) (channel *MultiPartyEscrowChannel, ok bool, err error)
func (*MockProcessor) ReconnectToWsClient ¶
func (m *MockProcessor) ReconnectToWsClient() error
type MultiPartyEscrowChannel ¶
type OrganizationGroup ¶
type OrganizationGroup struct {
Endpoints []string `json:"endpoints"`
GroupID string `json:"group_id"`
GroupName string `json:"group_name"`
Pricing []Pricing `json:"pricing"`
FreeCalls int `json:"free_calls"`
FreeCallSigner string `json:"free_call_signer_address"`
Licenses Licenses `json:"licenses,omitempty"`
AddOns []AddOns `json:"addOns,omitempty"`
}
type OrganizationMetaData ¶
type OrganizationMetaData struct {
OrgName string `json:"org_name"`
OrgID string `json:"org_id"`
Groups []Group `json:"groups"`
// contains filtered or unexported fields
}
func GetOrganizationMetaData ¶
func GetOrganizationMetaData() *OrganizationMetaData
GetOrganizationMetaData will be used to load the Organization metadata when Daemon starts To be part of components
func GetOrganizationMetaDataFromIPFS ¶
func GetOrganizationMetaDataFromIPFS(hash string) (*OrganizationMetaData, error)
func InitOrganizationMetaDataFromJson ¶
func InitOrganizationMetaDataFromJson(jsonData []byte) (metaData *OrganizationMetaData, err error)
InitOrganizationMetaDataFromJson Construct the Organization metadata from the JSON Passed
func (*OrganizationMetaData) GetConnectionTimeOut ¶
func (metaData *OrganizationMetaData) GetConnectionTimeOut() (connectionTimeOut time.Duration)
GetConnectionTimeOut Get the connection time out defined
func (*OrganizationMetaData) GetGroupId ¶
func (metaData *OrganizationMetaData) GetGroupId() [32]byte
GetGroupId Return the group id in bytes
func (*OrganizationMetaData) GetGroupIdString ¶
func (metaData *OrganizationMetaData) GetGroupIdString() string
GetGroupIdString Get the Group ID the Daemon needs to associate itself to, requests belonging to a different group if will be rejected
func (*OrganizationMetaData) GetLicenseEndPoints ¶
func (metaData *OrganizationMetaData) GetLicenseEndPoints() []string
func (*OrganizationMetaData) GetPaymentAddress ¶
func (metaData *OrganizationMetaData) GetPaymentAddress() common.Address
GetPaymentAddress retrieve the details of the payment address/ recipient address for current group.
func (*OrganizationMetaData) GetPaymentExpirationThreshold ¶
func (metaData *OrganizationMetaData) GetPaymentExpirationThreshold() *big.Int
GetPaymentExpirationThreshold get expiration threshold
func (*OrganizationMetaData) GetPaymentStorageEndPoints ¶
func (metaData *OrganizationMetaData) GetPaymentStorageEndPoints() []string
GetPaymentStorageEndPoints Get the End points of the Payment Storage used to update the storage state
func (*OrganizationMetaData) GetRequestTimeOut ¶
func (metaData *OrganizationMetaData) GetRequestTimeOut() time.Duration
GetRequestTimeOut Get the Request time out defined
type Payment ¶
type Payment struct {
PaymentAddress string `json:"payment_address"`
PaymentExpirationThreshold *big.Int `json:"payment_expiration_threshold"`
PaymentChannelStorageType string `json:"payment_channel_storage_type"`
PaymentChannelStorageClient PaymentChannelStorageClient `json:"payment_channel_storage_client"`
}
type PaymentChannelStorageClient ¶
type PaymentChannelStorageClient struct {
ConnectionTimeout string `json:"connection_timeout" mapstructure:"connection_timeout"`
RequestTimeout string `json:"request_timeout" mapstructure:"request_timeout"`
Endpoints []string `json:"endpoints"`
}
PaymentChannelStorageClient to hold the storage details of the payment
type PricingDetails ¶
type PricingDetails struct {
ServiceName string `json:"service_name"`
MethodPricing []MethodPricing `json:"method_pricing"`
}
type Processor ¶
type Processor interface {
ReconnectToWsClient() error
ConnectToWsClient() error
Enabled() bool
EscrowContractAddress() common.Address
MultiPartyEscrow() *MultiPartyEscrow
GetEthHttpClient() *ethclient.Client
GetEthWSClient() *ethclient.Client
CurrentBlock() (*big.Int, error)
CompareWithLatestBlockNumber(blockNumberPassed *big.Int, allowedBlockChainDifference uint64) error
HasIdentity() bool
Close()
MultiPartyEscrowChannel(channelID *big.Int) (channel *MultiPartyEscrowChannel, ok bool, err error)
}
func NewProcessor ¶
func NewProcessor(metadata *ServiceMetadata) (Processor, error)
NewProcessor creates a new blockchain processor
type ServiceMetadata ¶
type ServiceMetadata struct {
Version int `json:"version"`
DisplayName string `json:"display_name"`
Encoding string `json:"encoding"`
ServiceType string `json:"service_type"`
Groups []OrganizationGroup `json:"groups"`
ModelIpfsHash string `json:"model_ipfs_hash"`
ServiceApiSource string `json:"service_api_source"`
MpeAddress string `json:"mpe_address"`
DynamicPriceMethodMapping map[string]string `json:"dynamic_pricing"`
TrainingMethods []string `json:"training_methods"`
TrainingMetadata map[string]any `json:"training_metadata"`
ProtoDescriptors linker.Files `json:"-"`
ProtoFiles map[string]string `json:"-"`
// contains filtered or unexported fields
}
func GetServiceMetaDataFromIPFS ¶
func GetServiceMetaDataFromIPFS(hash string) (*ServiceMetadata, error)
func InitServiceMetaDataFromJson ¶
func InitServiceMetaDataFromJson(jsonData []byte) (*ServiceMetadata, error)
func ReadServiceMetaDataFromLocalFile ¶
func ReadServiceMetaDataFromLocalFile(filename string) (*ServiceMetadata, error)
func ServiceMetaData ¶
func ServiceMetaData() *ServiceMetadata
func (*ServiceMetadata) FreeCallSignerAddress ¶
func (metaData *ServiceMetadata) FreeCallSignerAddress() common.Address
func (*ServiceMetadata) GetDefaultPricing ¶
func (metaData *ServiceMetadata) GetDefaultPricing() Pricing
func (*ServiceMetadata) GetDisplayName ¶
func (metaData *ServiceMetadata) GetDisplayName() string
func (*ServiceMetadata) GetDynamicPricingMethodAssociated ¶
func (metaData *ServiceMetadata) GetDynamicPricingMethodAssociated(methodFullName string) (pricingMethod string, isDynamicPricingEligible bool)
GetDynamicPricingMethodAssociated accept methodFullName, example "/example_service.Calculator/add"
func (*ServiceMetadata) GetFreeCallsAllowed ¶
func (metaData *ServiceMetadata) GetFreeCallsAllowed() int
func (*ServiceMetadata) GetLicenses ¶
func (metaData *ServiceMetadata) GetLicenses() Licenses
func (*ServiceMetadata) GetMpeAddress ¶
func (metaData *ServiceMetadata) GetMpeAddress() common.Address
func (*ServiceMetadata) GetServiceType ¶
func (metaData *ServiceMetadata) GetServiceType() string
func (*ServiceMetadata) GetVersion ¶
func (metaData *ServiceMetadata) GetVersion() int
func (*ServiceMetadata) GetWireEncoding ¶
func (metaData *ServiceMetadata) GetWireEncoding() string
func (*ServiceMetadata) IsFreeCallAllowed ¶
func (metaData *ServiceMetadata) IsFreeCallAllowed() bool
func (*ServiceMetadata) IsModelTraining ¶
func (metaData *ServiceMetadata) IsModelTraining(methodFullName string) (useModelTrainingEndPoint bool)
IsModelTraining accept methodFullName, example "/example_service.Calculator/add"
type SimulatedEthereumEnvironment ¶
type SimulatedEthereumEnvironment struct {
SingnetPrivateKey *ecdsa.PrivateKey
SingnetWallet *bind.TransactOpts
ClientWallet *bind.TransactOpts
ClientPrivateKey *ecdsa.PrivateKey
ServerWallet *bind.TransactOpts
ServerPrivateKey *ecdsa.PrivateKey
Backend *simulated.Backend
FetToken *FetchToken
MultiPartyEscrowAddress common.Address
MultiPartyEscrow *MultiPartyEscrow
}
func GetSimulatedEthereumEnvironment ¶
func GetSimulatedEthereumEnvironment() (env SimulatedEthereumEnvironment)
func (*SimulatedEthereumEnvironment) Commit ¶
func (env *SimulatedEthereumEnvironment) Commit() *SimulatedEthereumEnvironment
func (*SimulatedEthereumEnvironment) MpeDeposit ¶
func (env *SimulatedEthereumEnvironment) MpeDeposit(from *bind.TransactOpts, amount int64) *SimulatedEthereumEnvironment
func (*SimulatedEthereumEnvironment) MpeOpenChannel ¶
func (env *SimulatedEthereumEnvironment) MpeOpenChannel(from *bind.TransactOpts, to *bind.TransactOpts, amount int64, expiration int64, groupId [32]byte) *SimulatedEthereumEnvironment
func (*SimulatedEthereumEnvironment) SnetApproveMpe ¶
func (env *SimulatedEthereumEnvironment) SnetApproveMpe(from *bind.TransactOpts, amount int64) *SimulatedEthereumEnvironment
func (*SimulatedEthereumEnvironment) SnetTransferTokens ¶
func (env *SimulatedEthereumEnvironment) SnetTransferTokens(to *bind.TransactOpts, amount int64) *SimulatedEthereumEnvironment
type Subscription ¶
type Subscription struct {
PeriodInDays int `json:"periodInDays"`
DiscountInPercentage float64 `json:"discountInPercentage"`
PlanName string `json:"planName"`
LicenseCost big.Int `json:"licenseCost"`
GrpcServiceName string `json:"grpcServiceName,omitempty"`
GrpcMethodName string `json:"grpcMethodName,omitempty"`
}
type Subscriptions ¶
type Subscriptions struct {
Type string `json:"type"`
DetailsURL string `json:"detailsUrl"`
IsActive string `json:"isActive"`
Subscription []Subscription `json:"subscription"`
}