blockchain

package
v3.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2020 License: MIT Imports: 21 Imported by: 20

Documentation

Index

Constants

View Source
const IpfsPrefix = "ipfs://"
{
    "version": 1,
    "display_name": "Entity Disambiguation",
    "encoding": "proto",
    "service_type": "grpc",
    "model_ipfs_hash": "Qmd21xqgX8fkU4fD2bFMNG2Q86wAB4GmGBekQfLoiLtXYv",
    "mpe_address": "0x34E2EeE197EfAAbEcC495FdF3B1781a3b894eB5f",
    "groups": [
        {
            "group_name": "default_group",
            "free_calls": 12,
            "free_call_signer_address": "0x7DF35C98f41F3Af0df1dc4c7F7D4C19a71Dd059F",
            "pricing": [
                {
                    "price_model": "fixed_price",
                    "price_in_cogs": 1,
                    "default": true
                }
            ],
            "endpoints": [
                "https://tz-services-1.snet.sh:8005"
            ],
            "group_id": "EoFmN3nvaXpf6ew8jJbIPVghE5NXfYupFF7PkRmVyGQ="
        }
    ],
    "assets": {
        "hero_image": "Qmb1n3LxPXLHTUMu7afrpZdpug4WhhcmVVCEwUxjLQafq1/hero_named-entity-disambiguation.png"
    },
    "service_description": {
        "url": "https://singnet.github.io/nlp-services-misc/users_guide/named-entity-disambiguation-service.html",
        "description": "Provide further clearity regaridng entities named within a piece of text. For example, \"Paris is the capital of France\", we would want to link \"Paris\" to Paris the city not Paris Hilton in this case.",
        "short_description": "text of 180 chars"
    },
    "contributors": [
            {
                "name": "dummy dummy",
                "email_id": "dummy@dummy.io"
            }
        ]
}

Variables

View Source
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 AddressToHex added in v0.1.2

func AddressToHex(address *common.Address) string

AddressToHex converts Ethereum address to hex string representation.

func BytesToBase64 added in v0.1.2

func BytesToBase64(bytes []byte) string

BytesToBase64 converts array of bytes to base64 string.

func ConvertBase64Encoding added in v0.1.3

func ConvertBase64Encoding(str string) ([32]byte, error)

func EstimateGas added in v0.1.2

func EstimateGas(wallet *bind.TransactOpts) (opts *bind.TransactOpts)

func FormatHash added in v0.1.3

func FormatHash(ipfsHash string) string

func HexToAddress added in v0.1.2

func HexToAddress(str string) common.Address

HexToAddress converts hex string to Ethreum address.

func HexToBytes added in v0.1.2

func HexToBytes(str string) []byte

HexToBytes converts hex string to bytes array.

func ParseSignature added in v0.1.2

func ParseSignature(jobSignatureBytes []byte) (uint8, [32]byte, [32]byte, error)

ParseSignature parses Ethereum signature.

func RemoveSpecialCharactersfromHash added in v0.1.3

func RemoveSpecialCharactersfromHash(pString string) string

func SetGas added in v0.1.2

func SetGas(wallet *bind.TransactOpts, gasLimit uint64) (opts *bind.TransactOpts)

func StringToBytes32 added in v0.1.2

func StringToBytes32(str string) [32]byte

func ToChecksumAddress added in v1.1.1

func ToChecksumAddress(hexAddress string) string

Types

type EthereumClient added in v0.1.3

type EthereumClient struct {
	EthClient *ethclient.Client
	RawClient *rpc.Client
}

func GetEthereumClient added in v0.1.3

func GetEthereumClient() (*EthereumClient, error)

func (*EthereumClient) Close added in v0.1.3

func (ethereumClient *EthereumClient) Close()

type Group added in v1.1.0

type Group struct {
	GroupName      string  `json:"group_name"`
	GroupID        string  `json:"group_id"`
	PaymentDetails Payment `json:"payment"`
}

Structure to hold the individual group details , an Organization can have multiple groups

type MethodPricing added in v1.1.0

type MethodPricing struct {
	MethodName  string   `json:"method_name"`
	PriceInCogs *big.Int `json:"price_in_cogs"`
}

type MultiPartyEscrowChannel added in v0.1.2

type MultiPartyEscrowChannel struct {
	Sender     common.Address
	Recipient  common.Address
	GroupId    [32]byte
	Value      *big.Int
	Nonce      *big.Int
	Expiration *big.Int
	Signer     common.Address
}

type OrganizationGroup added in v1.1.0

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"`
}

type OrganizationMetaData added in v1.1.0

type OrganizationMetaData struct {
	OrgName string  `json:"org_name"`
	OrgID   string  `json:"org_id"`
	Groups  []Group `json:"groups"`
	// contains filtered or unexported fields
}

func GetOrganizationMetaData added in v1.1.0

func GetOrganizationMetaData() *OrganizationMetaData

Will be used to load the Organization metadata when Daemon starts To be part of components

func GetOrganizationMetaDataFromIPFS added in v1.1.0

func GetOrganizationMetaDataFromIPFS(hash string) (*OrganizationMetaData, error)

func InitOrganizationMetaDataFromJson added in v1.1.0

func InitOrganizationMetaDataFromJson(jsonData string) (metaData *OrganizationMetaData, err error)

Construct the Organization metadata from the JSON Passed

func (OrganizationMetaData) GetConnectionTimeOut added in v1.1.0

func (metaData OrganizationMetaData) GetConnectionTimeOut() (connectionTimeOut time.Duration)

Get the connection time out defined

func (OrganizationMetaData) GetGroupId added in v1.1.0

func (metaData OrganizationMetaData) GetGroupId() [32]byte

Return the group id in bytes

func (OrganizationMetaData) GetGroupIdString added in v1.1.0

func (metaData OrganizationMetaData) GetGroupIdString() string

Get the Group ID the Daemon needs to associate itself to , requests belonging to a different group if will be rejected

func (OrganizationMetaData) GetPaymentAddress added in v1.1.0

func (metaData OrganizationMetaData) GetPaymentAddress() common.Address

Pass the group Name and retrieve the details of the payment address/ recipient address.

func (*OrganizationMetaData) GetPaymentExpirationThreshold added in v1.1.0

func (metaData *OrganizationMetaData) GetPaymentExpirationThreshold() *big.Int

Payment expiration threshold

func (OrganizationMetaData) GetPaymentStorageEndPoints added in v1.1.0

func (metaData OrganizationMetaData) GetPaymentStorageEndPoints() []string

Get the End points of the Payment Storage used to update the storage state

func (OrganizationMetaData) GetRequestTimeOut added in v1.1.0

func (metaData OrganizationMetaData) GetRequestTimeOut() time.Duration

Get the Request time out defined

type Payment added in v1.1.0

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 added in v1.1.0

type PaymentChannelStorageClient struct {
	ConnectionTimeout string   `json:"connection_timeout" mapstructure:"connection_timeout"`
	RequestTimeout    string   `json:"request_timeout" mapstructure:"request_timeout"`
	Endpoints         []string `json:"endpoints"`
}

Structure to hold the storage details of the payment

type Pricing added in v1.1.0

type Pricing struct {
	PriceModel     string           `json:"price_model"`
	PriceInCogs    *big.Int         `json:"price_in_cogs,omitempty"`
	PackageName    string           `json:"package_name,omitempty"`
	Default        bool             `json:"default,omitempty"`
	PricingDetails []PricingDetails `json:"details,omitempty"`
}

type PricingDetails added in v1.1.0

type PricingDetails struct {
	ServiceName   string          `json:"service_name"`
	MethodPricing []MethodPricing `json:"method_pricing"`
}

type Processor

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

func NewProcessor

func NewProcessor(metadata *ServiceMetadata) (Processor, error)

NewProcessor creates a new blockchain processor

func (*Processor) Close added in v0.1.3

func (processor *Processor) Close()

func (*Processor) CurrentBlock added in v0.1.2

func (processor *Processor) CurrentBlock() (currentBlock *big.Int, err error)

func (*Processor) Enabled added in v0.1.2

func (processor *Processor) Enabled() (enabled bool)

func (*Processor) EscrowContractAddress added in v0.1.2

func (processor *Processor) EscrowContractAddress() common.Address

func (*Processor) HasIdentity added in v0.1.3

func (processor *Processor) HasIdentity() bool

func (*Processor) MultiPartyEscrow added in v0.1.2

func (processor *Processor) MultiPartyEscrow() *MultiPartyEscrow

func (*Processor) MultiPartyEscrowChannel added in v0.1.2

func (processor *Processor) MultiPartyEscrowChannel(channelID *big.Int) (channel *MultiPartyEscrowChannel, ok bool, err error)

type ServiceMetadata added in v0.1.2

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"`
	MpeAddress    string              `json:"mpe_address"`
	// contains filtered or unexported fields
}

func GetServiceMetaDataFromIPFS added in v0.1.3

func GetServiceMetaDataFromIPFS(hash string) (*ServiceMetadata, error)

func InitServiceMetaDataFromJson added in v0.1.3

func InitServiceMetaDataFromJson(jsonData string) (*ServiceMetadata, error)

func ReadServiceMetaDataFromLocalFile added in v1.1.0

func ReadServiceMetaDataFromLocalFile(filename string) (*ServiceMetadata, error)

func ServiceMetaData added in v0.1.3

func ServiceMetaData() *ServiceMetadata

func (*ServiceMetadata) FreeCallSignerAddress

func (metaData *ServiceMetadata) FreeCallSignerAddress() common.Address

func (ServiceMetadata) GetDefaultPricing added in v1.1.0

func (metaData ServiceMetadata) GetDefaultPricing() Pricing

func (*ServiceMetadata) GetDisplayName added in v0.1.3

func (metaData *ServiceMetadata) GetDisplayName() string

func (*ServiceMetadata) GetFreeCallsAllowed

func (metaData *ServiceMetadata) GetFreeCallsAllowed() int

func (*ServiceMetadata) GetMpeAddress added in v0.1.3

func (metaData *ServiceMetadata) GetMpeAddress() common.Address

func (*ServiceMetadata) GetServiceType added in v0.1.3

func (metaData *ServiceMetadata) GetServiceType() string

func (*ServiceMetadata) GetVersion added in v0.1.3

func (metaData *ServiceMetadata) GetVersion() int

func (*ServiceMetadata) GetWireEncoding added in v0.1.3

func (metaData *ServiceMetadata) GetWireEncoding() string

func (*ServiceMetadata) IsFreeCallAllowed

func (metaData *ServiceMetadata) IsFreeCallAllowed() bool

type SimulatedEthereumEnvironment added in v0.1.2

type SimulatedEthereumEnvironment struct {
	SingnetPrivateKey       *ecdsa.PrivateKey
	SingnetWallet           *bind.TransactOpts
	ClientWallet            *bind.TransactOpts
	ClientPrivateKey        *ecdsa.PrivateKey
	ServerWallet            *bind.TransactOpts
	ServerPrivateKey        *ecdsa.PrivateKey
	Backend                 *backends.SimulatedBackend
	SingularityNetToken     *SingularityNetToken
	MultiPartyEscrowAddress common.Address
	MultiPartyEscrow        *MultiPartyEscrow
}

func GetSimulatedEthereumEnvironment added in v0.1.2

func GetSimulatedEthereumEnvironment() (env SimulatedEthereumEnvironment)

func (*SimulatedEthereumEnvironment) Commit added in v0.1.2

func (*SimulatedEthereumEnvironment) MpeDeposit added in v0.1.2

func (*SimulatedEthereumEnvironment) MpeOpenChannel added in v0.1.2

func (env *SimulatedEthereumEnvironment) MpeOpenChannel(from *bind.TransactOpts, to *bind.TransactOpts, amount int64, expiration int64, groupId [32]byte) *SimulatedEthereumEnvironment

func (*SimulatedEthereumEnvironment) SnetApproveMpe added in v0.1.2

func (*SimulatedEthereumEnvironment) SnetTransferTokens added in v0.1.2

Jump to

Keyboard shortcuts

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