blockchain

package
v0.1.10-64-g7180dea Latest Latest
Warning

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

Go to latest
Published: May 27, 2019 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const IpfsPrefix = "ipfs://"

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

func AddressToHex(address *common.Address) string

AddressToHex converts Ethereum address to hex string representation.

func BytesToBase64

func BytesToBase64(bytes []byte) string

BytesToBase64 converts array of bytes to base64 string.

func ConvertBase64Encoding

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

func EstimateGas

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

func FormatHash

func FormatHash(ipfsHash string) string

func HexToAddress

func HexToAddress(str string) common.Address

HexToAddress converts hex string to Ethreum address.

func HexToBytes

func HexToBytes(str string) []byte

HexToBytes converts hex string to bytes array.

func ParseSignature

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

ParseSignature parses Ethereum signature.

func RemoveSpecialCharactersfromHash

func RemoveSpecialCharactersfromHash(pString string) string

func SetGas

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

func StringToBytes32

func StringToBytes32(str string) [32]byte

Types

type EthereumClient

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

func GetEthereumClient

func GetEthereumClient() (*EthereumClient, error)

func (*EthereumClient) Close

func (ethereumClient *EthereumClient) Close()

type MultiPartyEscrowChannel

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 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

func (processor *Processor) Close()

func (*Processor) CurrentBlock

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

func (*Processor) Enabled

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

func (*Processor) EscrowContractAddress

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

func (*Processor) HasIdentity

func (processor *Processor) HasIdentity() bool

func (*Processor) MultiPartyEscrow

func (processor *Processor) MultiPartyEscrow() *MultiPartyEscrow

func (*Processor) MultiPartyEscrowChannel

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

type ServiceMetadata

type ServiceMetadata struct {
	Version                    int      `json:"version"`
	DisplayName                string   `json:"display_name"`
	Encoding                   string   `json:"encoding"`
	ServiceType                string   `json:"service_type"`
	PaymentExpirationThreshold *big.Int `json:"payment_expiration_threshold"`
	ModelIpfsHash              string   `json:"model_ipfs_hash"`
	MpeAddress                 string   `json:"mpe_address"`
	Pricing                    struct {
		PriceModel  string   `json:"price_model"`
		PriceInCogs *big.Int `json:"price_in_cogs"`
	} `json:"pricing"`
	Groups []struct {
		GroupName      string `json:"group_name"`
		GroupID        string `json:"group_id"`
		PaymentAddress string `json:"payment_address"`
	} `json:"groups"`
	Endpoints []struct {
		GroupName string `json:"group_name"`
		Endpoint  string `json:"endpoint"`
	} `json:"endpoints"`
	// contains filtered or unexported fields
}

func GetServiceMetaDataFromIPFS

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

func InitServiceMetaDataFromJson

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

func ServiceMetaData

func ServiceMetaData() *ServiceMetadata

func (*ServiceMetadata) GetDaemonEndPoint

func (metaData *ServiceMetadata) GetDaemonEndPoint() string

func (*ServiceMetadata) GetDaemonGroupID

func (metaData *ServiceMetadata) GetDaemonGroupID() [32]byte

func (*ServiceMetadata) GetDaemonGroupIDString

func (metaData *ServiceMetadata) GetDaemonGroupIDString() string

func (*ServiceMetadata) GetDaemonGroupName

func (metaData *ServiceMetadata) GetDaemonGroupName() string

func (*ServiceMetadata) GetDisplayName

func (metaData *ServiceMetadata) GetDisplayName() string

func (*ServiceMetadata) GetMpeAddress

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

func (*ServiceMetadata) GetPaymentAddress

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

func (*ServiceMetadata) GetPaymentExpirationThreshold

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

func (*ServiceMetadata) GetPriceInCogs

func (metaData *ServiceMetadata) GetPriceInCogs() *big.Int

func (*ServiceMetadata) GetServiceType

func (metaData *ServiceMetadata) GetServiceType() string

func (*ServiceMetadata) GetVersion

func (metaData *ServiceMetadata) GetVersion() int

func (*ServiceMetadata) GetWireEncoding

func (metaData *ServiceMetadata) GetWireEncoding() string

type SimulatedEthereumEnvironment

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

func GetSimulatedEthereumEnvironment() (env SimulatedEthereumEnvironment)

func (*SimulatedEthereumEnvironment) Commit

func (*SimulatedEthereumEnvironment) MpeDeposit

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 (*SimulatedEthereumEnvironment) SnetTransferTokens

Jump to

Keyboard shortcuts

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