client_utils

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2020 License: GPL-3.0 Imports: 23 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BCAddressToEthAddress

func BCAddressToEthAddress(address string) [20]byte

func ECRecoverFromTx

func ECRecoverFromTx(data GetTxByHashResult) (retKey [64]byte, err error)

func EthAddressToBCAddress

func EthAddressToBCAddress(address [20]byte) string

func GetBalance

func GetBalance(ethAddress [20]byte) (big.Int, error)

called by CheckTxCostAgainstBalance

func GetEarnings

func GetEarnings(ethAddress [20]byte) (big.Int, error)

utility function for sp to list its earnings

func GetNodeID2Address

func GetNodeID2Address(nodeID [32]byte) ([20]byte, error)

called by routines in archon-dht since in the smart contract nodeID -> address -> spProfile

func GetPublickeyFromContract

func GetPublickeyFromContract(username string, timeout time.Duration) (pubkey [64]byte, err error)

This function is available to client that downloads an archon file, so that they may validate the ContainerSignature associated with the download

func GetRegisteredSP

func GetRegisteredSP(ethAddress [20]byte) (sp *RegisteredSp, err error)

An sp participating in archon network makes available to archon clients its cache of registeredSp profiles. The sp fills this cache by taking census of the nodeIDs of its "neighbors" in the overlay, then retrieving the sp profile associated with each of thes nodeIDs

func GetUsernameFromContract

func GetUsernameFromContract(address [20]byte) (username [32]byte, err error)

An uploader needs to first have their username registered with the sc before they can upload to the archon cloud. The primary use of this function is that the sp calls this during GetUploadTx so that the sp will store the corresponding upload in the registered namespace. this registered namespace prevents the uploader from cheating and overwriting files in other namespaces

func IsTxAcceptedByBlockchain

func IsTxAcceptedByBlockchain(txid string) (bool, error)

Note this is designed for registerSP and proposeUpload tx only. Other txs will not necessarily return correct bool.

func ProposeUpload

func ProposeUpload(params *UploadParams) (txid string, err error)

To upload shards to sps, the uploader must make ProposeUpload tx to the smart contract with "SPsToUploadTo" being the result of the local marketplace instance with the upload as input. When the uploader sends the shards to the sps with the resultant txid, the sps will check that the txid has has data that matches the upload.. i.e. correct upload size, containerSignature, etc.

func RegisterUsername

func RegisterUsername(params *RegisterUsernameParams) (txid string, err error)

func Unpack

func Unpack(methodName string, input []byte) (inter interface{}, err error)

Types

type GetTxByHashResult

type GetTxByHashResult struct {
	BlockHash        string `json:blockHash`
	BlockNumber      string `json:blockNumber`
	From             string `json:from`
	Gas              string `json:gas`
	GasPrice         string `json:gasPrice`
	Hash             string `json:hash`
	Input            string `json:input`
	Nonce            string `json:nonce`
	R                string `json:r`
	S                string `json:s`
	To               string `json:to`
	TransactionIndex string `json:transactionIndex`
	V                string `json:v`
	Value            string `json:value`
}

type InputDeconstruct

type InputDeconstruct struct {
	HashedArchonFilepath [32]byte
	ContainerSignature   [ethcrypto.SignatureLength]byte
	Params               encodings.ProposeUploadParams
	Shardsize            uint64
	ArchonSPs            [][20]byte
}

type ProposeUploadArgs

type ProposeUploadArgs struct {
	HashedArchonFilepath [32]byte
	ContainerSignatureR  [32]byte
	ContainerSignatureS  [32]byte
	Params               [32]byte
	Shardsize            uint64
	ArchonSPs            [][20]byte
}

type RegisterUsernameParams

type RegisterUsernameParams struct {
	Username string
	Wallet   wallet.EthereumKeyset
}

type TxLog

type TxLog rpc_utils.TxLog

type TxLogs

type TxLogs rpc_utils.TxLogs

func GetTxLogs

func GetTxLogs(txid string) (TxLogs, error)

type TxReceipt

type TxReceipt rpc_utils.TxReceipt

type UploadAccessControlLevel added in v0.0.26

type UploadAccessControlLevel uint8
const (
	Priv_UploaderOnly UploadAccessControlLevel = iota
	Priv_RestrictedGroup
	Public
)

type UploadParams

type UploadParams struct {
	Wallet wallet.EthereumKeyset

	ServiceDuration    uint32
	MinSLARequirements int
	UploadPmt          uint64 // bid in marketplace, defaults to flat payment
	ArchonFilepath     string
	Filesize           uint64
	Shardsize          uint64
	FileContainerType  uint8
	EncryptionType     uint8
	CompressionType    uint8
	ShardContainerType uint8
	ErasureCodeType    uint8
	AccessControlLevel UploadAccessControlLevel
	CustomField        uint8

	ContainerSignature [ethcrypto.SignatureLength]byte
	SPsToUploadTo      [][20]byte // sps to whom the shards are to go
}

type UploadTx

type UploadTx struct {
	BlockHash          string `json:blockHash`
	BlockNumber        string `json:blockNumber`
	From               string `json:from`
	Gas                string `json:gas`
	GasPrice           string `json:gasPrice`
	Hash               string `json:hash`
	InputDeconstructed InputDeconstruct
	Input              string `json:input`
	Nonce              string `json:nonce`
	R                  string `json:r`
	S                  string `json:s`
	To                 string `json:to`
	TransactionIndex   string `json:transactionIndex`
	V                  string `json:v`
	AmountPaid         string
	PublicKey          [64]byte
	UsernameCompressed [32]byte
}

func GetUploadTx

func GetUploadTx(txHash [32]byte) (uploadTx UploadTx, err error)

Called by sp. When uploader sends shards (and associated txid) to an sp, the sp checks the data and validity of the tx associated with the txid

Jump to

Keyboard shortcuts

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