zcncore

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	REGISTER_CLIENT                  = `/v1/client/put`
	GET_CLIENT                       = `/v1/client/get`
	PUT_TRANSACTION                  = `/v1/transaction/put`
	TXN_VERIFY_URL                   = `/v1/transaction/get/confirmation?hash=`
	GET_BALANCE                      = `/v1/client/get/balance?client_id=`
	GET_LOCK_CONFIG                  = `/v1/screst/` + InterestPoolSmartContractAddress + `/getLockConfig`
	GET_LOCKED_TOKENS                = `/v1/screst/` + InterestPoolSmartContractAddress + `/getPoolsStats?client_id=`
	GET_BLOCK_INFO                   = `/v1/block/get?`
	GET_MAGIC_BLOCK_INFO             = `/v1/block/magic/get?`
	GET_LATEST_FINALIZED             = `/v1/block/get/latest_finalized`
	GET_LATEST_FINALIZED_MAGIC_BLOCK = `/v1/block/get/latest_finalized_magic_block`
	GET_CHAIN_STATS                  = `/v1/chain/get/stats`

	VESTINGSC_PFX = `/v1/screst/` + VestingSmartContractAddress

	GET_VESTING_CONFIG       = VESTINGSC_PFX + `/getConfig`
	GET_VESTING_POOL_INFO    = VESTINGSC_PFX + `/getPoolInfo`
	GET_VESTING_CLIENT_POOLS = VESTINGSC_PFX + `/getClientPools`

	INTERESTPOOLSC_PFX        = `/v1/screst/` + InterestPoolSmartContractAddress
	GET_INTERESTPOOLSC_CONFIG = INTERESTPOOLSC_PFX + `/getConfig`

	FAUCETSC_PFX        = `/v1/screst/` + FaucetSmartContractAddress
	GET_FAUCETSC_CONFIG = FAUCETSC_PFX + `/getConfig`

	MINERSC_PFX          = `/v1/screst/` + MinerSmartContractAddress
	GET_MINERSC_NODE     = MINERSC_PFX + "/nodeStat"
	GET_MINERSC_POOL     = MINERSC_PFX + "/nodePoolStat"
	GET_MINERSC_CONFIG   = MINERSC_PFX + "/configs"
	GET_MINERSC_GLOBALS  = MINERSC_PFX + "/globalSettings"
	GET_MINERSC_USER     = MINERSC_PFX + "/getUserPools"
	GET_MINERSC_MINERS   = MINERSC_PFX + "/getMinerList"
	GET_MINERSC_SHARDERS = MINERSC_PFX + "/getSharderList"
	GET_MINERSC_EVENTS   = MINERSC_PFX + "/getEvents"

	STORAGESC_PFX = "/v1/screst/" + StorageSmartContractAddress

	STORAGESC_GET_SC_CONFIG            = STORAGESC_PFX + "/getConfig"
	STORAGESC_GET_CHALLENGE_POOL_INFO  = STORAGESC_PFX + "/getChallengePoolStat"
	STORAGESC_GET_ALLOCATION           = STORAGESC_PFX + "/allocation"
	STORAGESC_GET_ALLOCATIONS          = STORAGESC_PFX + "/allocations"
	STORAGESC_GET_READ_POOL_INFO       = STORAGESC_PFX + "/getReadPoolStat"
	STORAGESC_GET_STAKE_POOL_INFO      = STORAGESC_PFX + "/getStakePoolStat"
	STORAGESC_GET_STAKE_POOL_USER_INFO = STORAGESC_PFX + "/getUserStakePoolStat"
	STORAGESC_GET_BLOBBERS             = STORAGESC_PFX + "/getblobbers"
	STORAGESC_GET_BLOBBER              = STORAGESC_PFX + "/getBlobber"
	STORAGESC_GET_WRITE_POOL_INFO      = STORAGESC_PFX + "/getWritePoolStat"
)
View Source
const (
	StorageSmartContractAddress      = `6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d7`
	VestingSmartContractAddress      = `2bba5b05949ea59c80aed3ac3474d7379d3be737e8eb5a968c52295e48333ead`
	FaucetSmartContractAddress       = `6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d3`
	InterestPoolSmartContractAddress = `cf8d0df9bd8cc637a4ff4e792ffe3686da6220c45f0e1103baa609f3f1751ef4`
	MultiSigSmartContractAddress     = `27b5ef7120252b79f9dd9c05505dd28f328c80f6863ee446daede08a84d651a7`
	MinerSmartContractAddress        = `6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d9`
	MultiSigRegisterFuncName         = "register"
	MultiSigVoteFuncName             = "vote"
)
View Source
const (
	StatusSuccess      int = 0
	StatusNetworkError int = 1
	// TODO: Change to specific error
	StatusError            int = 2
	StatusRejectedByUser   int = 3
	StatusInvalidSignature int = 4
	StatusAuthError        int = 5
	StatusAuthVerifyFailed int = 6
	StatusAuthTimeout      int = 7
	StatusUnknown          int = -1
)
View Source
const (
	OpGetTokenLockConfig int = iota
	OpGetLockedTokens
	OpGetUserPools
	OpGetUserPoolDetail
	// storage SC ops
	OpStorageSCGetConfig
	OpStorageSCGetChallengePoolInfo
	OpStorageSCGetAllocation
	OpStorageSCGetAllocations
	OpStorageSCGetReadPoolInfo
	OpStorageSCGetStakePoolInfo
	OpStorageSCGetBlobbers
	OpStorageSCGetBlobber
	OpStorageSCGetWritePoolInfo
)
View Source
const NETWORK_ENDPOINT = "/network"
View Source
const TOKEN_UNIT int64 = 1e10

Variables

Functions

func CheckConfig

func CheckConfig() error

func CloseLog

func CloseLog()

CloseLog closes log file

func ConvertTokenToUSD

func ConvertTokenToUSD(token float64) (float64, error)

func ConvertUSDToToken

func ConvertUSDToToken(usd float64) (float64, error)

func Decrypt

func Decrypt(key, text string) (string, error)

func Encrypt

func Encrypt(key, text string) (string, error)

func GetAllocation

func GetAllocation(allocID string, cb GetInfoCallback) (err error)

GetAllocation obtains allocation information.

func GetAllocations

func GetAllocations(clientID string, cb GetInfoCallback) (err error)

GetAllocations obtains list of allocations of a user.

func GetBalanceFromSharders

func GetBalanceFromSharders(clientID string) (int64, string, error)

func GetBalanceWallet

func GetBalanceWallet(walletStr string, cb models.GetBalanceCallback) error

GetBalance retreives wallet balance from sharders

func GetBlobber

func GetBlobber(blobberID string, cb GetInfoCallback) (err error)

GetBlobber obtains blobber information.

func GetBlobbers

func GetBlobbers(cb GetInfoCallback) (err error)

GetBlobbers obtains list of all active blobbers.

func GetBlockByRound

func GetBlockByRound(ctx context.Context, numSharders int, round int64) (b *block.Block, err error)

func GetChainStats

func GetChainStats(ctx context.Context) (b *block.ChainStats, err error)

func GetChallengePoolInfo

func GetChallengePoolInfo(allocID string, cb GetInfoCallback) (err error)

GetChallengePoolInfo obtains challenge pool information for an allocation.

func GetConfig

func GetConfig() localConfig

func GetEvents

func GetEvents(cb GetInfoCallback, filters map[string]string) (err error)

func GetFaucetSCConfig

func GetFaucetSCConfig(cb GetInfoCallback) (err error)

func GetIdForUrl

func GetIdForUrl(url string) string

func GetInterestPoolSCConfig

func GetInterestPoolSCConfig(cb GetInfoCallback) (err error)

func GetLatestFinalized

func GetLatestFinalized(ctx context.Context, numSharders int) (b *block.Header, err error)

func GetLatestFinalizedMagicBlock

func GetLatestFinalizedMagicBlock(ctx context.Context, numSharders int) (m *block.MagicBlock, err error)

func GetLockConfig

func GetLockConfig(cb GetInfoCallback) error

GetLockConfig returns the lock token configuration information such as interest rate from blockchain

func GetLockedTokens

func GetLockedTokens(cb GetInfoCallback) error

GetLockedTokens returns the ealier locked token pool stats

func GetLogger

func GetLogger() *logger.Logger

func GetMagicBlockByNumber

func GetMagicBlockByNumber(ctx context.Context, numSharders int, number int64) (m *block.MagicBlock, err error)

func GetMinShardersVerify

func GetMinShardersVerify() int

func GetMinerSCConfig

func GetMinerSCConfig(cb GetInfoCallback) (err error)

func GetMinerSCGlobals

func GetMinerSCGlobals(cb GetInfoCallback) (err error)

func GetMinerSCNodeInfo

func GetMinerSCNodeInfo(id string, cb GetInfoCallback) (err error)

func GetMinerSCNodePool

func GetMinerSCNodePool(id, poolID string, cb GetInfoCallback) (err error)

func GetMinerSCUserInfo

func GetMinerSCUserInfo(clientID string, cb GetInfoCallback) (err error)

func GetMiners

func GetMiners(cb GetInfoCallback) (err error)

GetMiners obtains list of all active miners.

func GetNetworkJSON

func GetNetworkJSON() string

func GetReadPoolInfo

func GetReadPoolInfo(clientID string, cb GetInfoCallback) (err error)

GetReadPoolInfo obtains information about read pool of a user.

func GetSharders

func GetSharders(cb GetInfoCallback) (err error)

GetSharders obtains list of all active sharders.

func GetStakePoolInfo

func GetStakePoolInfo(blobberID string, cb GetInfoCallback) (err error)

GetStakePoolInfo obtains information about stake pool of a blobber and related validator.

func GetStakePoolUserInfo

func GetStakePoolUserInfo(clientID string, cb GetInfoCallback) (err error)

GetStakePoolUserInfo for a user.

func GetStorageSCConfig

func GetStorageSCConfig(cb GetInfoCallback) (err error)

GetStorageSCConfig obtains Storage SC configurations.

func GetTokenRateByCurrency

func GetTokenRateByCurrency(currency string) (float64, error)

func GetVestingClientList

func GetVestingClientList(clientID string, cb GetInfoCallback) (err error)

func GetVestingPoolInfo

func GetVestingPoolInfo(poolID string, cb GetInfoCallback) (err error)

func GetVestingSCConfig

func GetVestingSCConfig(cb GetInfoCallback) (err error)

func GetWallet

func GetWallet(walletStr string) (*zcncrypto.Wallet, error)

GetWallet get a wallet object from a wallet string

func GetWalletClientID

func GetWalletClientID(walletStr string) (string, error)

GetWalletClientID -- given a walletstr return ClientID

func GetWritePoolInfo

func GetWritePoolInfo(clientID string, cb GetInfoCallback) (err error)

GetWritePoolInfo obtains information about all write pools of a user. If given clientID is empty, then current user used.

func GetZcnUSDInfo

func GetZcnUSDInfo(cb GetUSDInfoCallback) error

GetZcnUSDInfo returns USD value for ZCN token from coinmarketcap.com

func Init

func Init(chainConfigJSON string) error

Init inializes the SDK with miner, sharder and signature scheme provided in configuration provided in JSON format It is used for 0proxy, 0box, 0explorer, andorid, ios : walletJSON is ChainConfig

	 {
     "chain_id":"0afc093ffb509f059c55478bc1a60351cef7b4e9c008a53a6cc8241ca8617dfe",
		"signature_scheme" : "bls0chain",
		"block_worker" : "http://localhost/dns",
		"min_submit" : 50,
		"min_confirmation" : 50,
		"confirmation_chain_length" : 3,
		"num_keys" : 1,
		"eth_node" : "https://ropsten.infura.io/v3/xxxxxxxxxxxxxxx"
	 }

func InitZCNSDK

func InitZCNSDK(blockWorker string, signscheme string, configs ...func(*ChainConfig) error) error

InitZCNSDK initializes the SDK with miner, sharder and signature scheme provided.

func RegisterToMiners

func RegisterToMiners(wallet *zcncrypto.Wallet, statusCb models.WalletCallback) error

RegisterToMiners can be used to register the wallet.

func SetAuthUrl

func SetAuthUrl(url string) error

SetAuthUrl will be called by app to set zauth URL to SDK.

func SetLogFile

func SetLogFile(logFile string, verbose bool)

SetLogFile - sets file path to write log verbose - true - console output; false - no console output

func SetNetwork

func SetNetwork(miners []string, sharders []string)

func SetupAuth

func SetupAuth(authHost, clientID, clientKey, publicKey, privateKey, localPublicKey string, cb AuthCallback) error

SetupAuth prepare auth app with clientid, key and a set of public, private key and local publickey which is running on PC/Mac.

func SplitKeys

func SplitKeys(privateKey string, numSplits int) (string, error)

Split keys from the primary master key

func UpdateNetworkDetails

func UpdateNetworkDetails() error

func UpdateNetworkDetailsWorker

func UpdateNetworkDetailsWorker(ctx context.Context)

func UpdateRequired

func UpdateRequired(networkDetails *Network) bool

func VerifyContentHash

func VerifyContentHash(metaTxnDataJSON string) (bool, error)

func WithChainID

func WithChainID(id string) func(c *ChainConfig) error

func WithConfirmationChainLength

func WithConfirmationChainLength(m int) func(c *ChainConfig) error

func WithEthereumNode

func WithEthereumNode(uri string) func(c *ChainConfig) error

func WithMinConfirmation

func WithMinConfirmation(m int) func(c *ChainConfig) error

func WithMinSubmit

func WithMinSubmit(m int) func(c *ChainConfig) error

Types

type AuthCallback

type AuthCallback interface {
	// This call back gives the status of the Two factor authenticator(zauth) setup.
	OnSetupComplete(status int, err string)
}

AuthCallback needs to be implemented by the caller SetupAuth()

type Blobber

type Blobber struct {
	ID                common.Key        `json:"id"`
	BaseURL           string            `json:"url"`
	Terms             Terms             `json:"terms"`
	Capacity          common.Size       `json:"capacity"`
	Used              common.Size       `json:"used"`
	LastHealthCheck   common.Timestamp  `json:"last_health_check"`
	StakePoolSettings StakePoolSettings `json:"stake_pool_settings"`
}

type ChainConfig

type ChainConfig struct {
	ChainID                 string   `json:"chain_id,omitempty"`
	BlockWorker             string   `json:"block_worker"`
	Miners                  []string `json:"miners"`
	Sharders                []string `json:"sharders"`
	SignatureScheme         string   `json:"signature_scheme"`
	MinSubmit               int      `json:"min_submit"`
	MinConfirmation         int      `json:"min_confirmation"`
	ConfirmationChainLength int      `json:"confirmation_chain_length"`
	EthNode                 string   `json:"eth_node"`
}

type ConfirmationStatus

type ConfirmationStatus int
const (
	Undefined ConfirmationStatus = iota
	Success
	ChargeableError
)

type CreateAllocationRequest

type CreateAllocationRequest struct {
	DataShards                 int              `json:"data_shards"`
	ParityShards               int              `json:"parity_shards"`
	Size                       common.Size      `json:"size"`
	Expiration                 common.Timestamp `json:"expiration_date"`
	Owner                      string           `json:"owner_id"`
	OwnerPublicKey             string           `json:"owner_public_key"`
	PreferredBlobbers          []string         `json:"preferred_blobbers"`
	ReadPriceRange             PriceRange       `json:"read_price_range"`
	WritePriceRange            PriceRange       `json:"write_price_range"`
	MaxChallengeCompletionTime time.Duration    `json:"max_challenge_completion_time"`
}

CreateAllocationRequest is information to create allocation.

type GetClientResponse

type GetClientResponse struct {
	ID           string `json:"id"`
	Version      string `json:"version"`
	CreationDate int    `json:"creation_date"`
	PublicKey    string `json:"public_key"`
}

func GetClientDetails

func GetClientDetails(clientID string) (*GetClientResponse, error)

type GetInfoCallback

type GetInfoCallback interface {
	// OnInfoAvailable will be called when GetLockTokenConfig is complete
	// if status == StatusSuccess then info is valid
	// is status != StatusSuccess then err will give the reason
	OnInfoAvailable(op int, status int, info string, err string)
}

GetInfoCallback needs to be implemented by the caller of GetLockTokenConfig() and GetLockedTokens()

type GetUSDInfoCallback

type GetUSDInfoCallback interface {
	// This will be called when GetZcnUSDInfo completes.
	// if status == StatusSuccess then info is valid
	// is status != StatusSuccess then err will give the reason
	OnUSDInfoAvailable(status int, info string, err string)
}

GetUSDInfoCallback needs to be implemented by the caller of GetZcnUSDInfo()

type InputMap

type InputMap struct {
	Fields map[string]string `json:"fields"`
}

type Miner

type Miner struct {
	ID                string      `json:"id"`
	N2NHost           string      `json:"n2n_host"`
	Host              string      `json:"host"`
	Port              int         `json:"port"`
	PublicKey         string      `json:"public_key"`
	ShortName         string      `json:"short_name"`
	BuildTag          string      `json:"build_tag"`
	TotalStake        int         `json:"total_stake"`
	DelegateWallet    string      `json:"delegate_wallet"`
	ServiceCharge     float64     `json:"service_charge"`
	NumberOfDelegates int         `json:"number_of_delegates"`
	MinStake          int64       `json:"min_stake"`
	MaxStake          int64       `json:"max_stake"`
	Stat              interface{} `json:"stat"`
}

type MinerSCDelegatePool

type MinerSCDelegatePool struct {
	MinerSCPoolStats `json:"stats"`
	MinerSCPool      `json:"pool"`
}

type MinerSCDelegatePoolInfo

type MinerSCDelegatePoolInfo struct {
	ID           common.Key     `json:"id"`            // pool ID
	Balance      common.Balance `json:"balance"`       //
	InterestPaid common.Balance `json:"interest_paid"` //
	RewardPaid   common.Balance `json:"reward_paid"`   //
	Status       string         `json:"status"`        //
	High         common.Balance `json:"high"`          // }
	Low          common.Balance `json:"low"`           // }
}

type MinerSCLock

type MinerSCLock struct {
	ID string `json:"id"`
}

type MinerSCMinerInfo

type MinerSCMinerInfo struct {
	*SimpleMinerSCMinerInfo `json:"simple_miner"`
	Pending                 map[string]MinerSCDelegatePool `json:"pending"`
	Active                  map[string]MinerSCDelegatePool `json:"active"`
	Deleting                map[string]MinerSCDelegatePool `json:"deleting"`
}

type MinerSCMinerStat

type MinerSCMinerStat struct {
	// for miner (totals)
	BlockReward      common.Balance `json:"block_reward,omitempty"`
	ServiceCharge    common.Balance `json:"service_charge,omitempty"`
	UsersFee         common.Balance `json:"users_fee,omitempty"`
	BlockShardersFee common.Balance `json:"block_sharders_fee,omitempty"`
	// for sharder (total)
	SharderRewards common.Balance `json:"sharder_rewards,omitempty"`
}

type MinerSCNodes

type MinerSCNodes struct {
	Nodes []Node `json:"Nodes"`
}

type MinerSCPool

type MinerSCPool struct {
	ID      string         `json:"id"`
	Balance common.Balance `json:"balance"`
}

type MinerSCPoolStats

type MinerSCPoolStats struct {
	DelegateID   string         `json:"delegate_id"`
	High         common.Balance `json:"high"`
	Low          common.Balance `json:"low"`
	InterestRate float64        `json:"interest_rate"`
	TotalPaid    common.Balance `json:"total_paid"`
	NumRounds    int64          `json:"number_rounds"`
}

type MinerSCUnlock

type MinerSCUnlock struct {
	ID     string `json:"id"`
	PoolID string `json:"pool_id"`
}

type MinerSCUserPoolsInfo

type MinerSCUserPoolsInfo struct {
	Pools map[string]map[string][]*MinerSCDelegatePoolInfo `json:"pools"`
}

type Network

type Network struct {
	Miners   []string `json:"miners"`
	Sharders []string `json:"sharders"`
}

func GetNetwork

func GetNetwork() *Network

func GetNetworkDetails

func GetNetworkDetails() (*Network, error)

type Node

type Node struct {
	Miner Miner `json:"simple_miner"`
}

type Params

type Params map[string]string

func (Params) Query

func (p Params) Query() string

type PriceRange

type PriceRange struct {
	Min common.Balance `json:"min"`
	Max common.Balance `json:"max"`
}

PriceRange represents a price range allowed by user to filter blobbers.

type SendTxnData

type SendTxnData struct {
	Note string `json:"note"`
}

type SimpleMinerSCMinerInfo

type SimpleMinerSCMinerInfo struct {
	ID      string `json:"id"`
	BaseURL string `json:"url"`

	DelegateWallet    string         `json:"delegate_wallet"`     //
	ServiceCharge     float64        `json:"service_charge"`      // %
	NumberOfDelegates int            `json:"number_of_delegates"` //
	MinStake          common.Balance `json:"min_stake"`           //
	MaxStake          common.Balance `json:"max_stake"`           //

	Stat MinerSCMinerStat `json:"stat"`
}

type StakePoolSettings

type StakePoolSettings struct {
	DelegateWallet string         `json:"delegate_wallet"`
	MinStake       common.Balance `json:"min_stake"`
	MaxStake       common.Balance `json:"max_stake"`
	NumDelegates   int            `json:"num_delegates"`
}

type Terms

type Terms struct {
	ReadPrice               common.Balance `json:"read_price"`  // tokens / GB
	WritePrice              common.Balance `json:"write_price"` // tokens / GB
	MinLockDemand           float64        `json:"min_lock_demand"`
	MaxOfferDuration        time.Duration  `json:"max_offer_duration"`
	ChallengeCompletionTime time.Duration  `json:"challenge_completion_time"`
}

type Transaction

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

func NewMSTransaction

func NewMSTransaction(walletstr string, cb TransactionCallback) (*Transaction, error)

NewMSTransaction new transaction object for multisig operation

func (*Transaction) CancelAllocation

func (t *Transaction) CancelAllocation(allocID string, fee int64) (
	err error)

CancelAllocation transaction.

func (*Transaction) CreateAllocation

func (t *Transaction) CreateAllocation(car *CreateAllocationRequest,
	lock, fee int64) (err error)

CreateAllocation transaction.

func (*Transaction) CreateReadPool

func (t *Transaction) CreateReadPool(fee int64) (err error)

CreateReadPool for current user.

func (*Transaction) ExecuteFaucetSCWallet

func (t *Transaction) ExecuteFaucetSCWallet(walletStr string, methodName string, input []byte) error

ExecuteFaucetSCWallet impements the Faucet Smart contract for a given wallet

func (*Transaction) ExecuteSmartContract

func (t *Transaction) ExecuteSmartContract(address, methodName, jsoninput string, val int64) error

func (*Transaction) FaucetUpdateConfig

func (t *Transaction) FaucetUpdateConfig(ip *InputMap) (err error)

func (*Transaction) FinalizeAllocation

func (t *Transaction) FinalizeAllocation(allocID string, fee int64) (
	err error)

FinalizeAllocation transaction.

func (*Transaction) GetTransactionError

func (t *Transaction) GetTransactionError() string

func (*Transaction) GetTransactionHash

func (t *Transaction) GetTransactionHash() string

func (*Transaction) GetVerifyConfirmationStatus

func (t *Transaction) GetVerifyConfirmationStatus() ConfirmationStatus

func (*Transaction) GetVerifyError

func (t *Transaction) GetVerifyError() string

func (*Transaction) GetVerifyOutput

func (t *Transaction) GetVerifyOutput() string

func (*Transaction) InterestPoolUpdateConfig

func (t *Transaction) InterestPoolUpdateConfig(ip *InputMap) (err error)

func (*Transaction) LockTokens

func (t *Transaction) LockTokens(val int64, durationHr int64, durationMin int) error

func (*Transaction) MienrSCUnlock

func (t *Transaction) MienrSCUnlock(nodeID, poolID string) (err error)

func (*Transaction) MinerSCDeleteMiner

func (t *Transaction) MinerSCDeleteMiner(info *MinerSCMinerInfo) (err error)

func (*Transaction) MinerSCDeleteSharder

func (t *Transaction) MinerSCDeleteSharder(info *MinerSCMinerInfo) (err error)

func (*Transaction) MinerSCLock

func (t *Transaction) MinerSCLock(nodeID string, lock int64) (err error)

func (*Transaction) MinerSCMinerSettings

func (t *Transaction) MinerSCMinerSettings(info *MinerSCMinerInfo) (err error)

func (*Transaction) MinerSCSharderSettings

func (t *Transaction) MinerSCSharderSettings(info *MinerSCMinerInfo) (err error)

func (*Transaction) MinerScUpdateConfig

func (t *Transaction) MinerScUpdateConfig(ip *InputMap) (err error)

func (*Transaction) MinerScUpdateGlobals

func (t *Transaction) MinerScUpdateGlobals(ip *InputMap) (err error)

func (*Transaction) Output

func (t *Transaction) Output() []byte

func (*Transaction) ReadPoolLock

func (t *Transaction) ReadPoolLock(allocID, blobberID string,
	duration int64, lock, fee int64) (err error)

ReadPoolLock locks tokens for current user and given allocation, using given duration. If blobberID is not empty, then tokens will be locked for given allocation->blobber only.

func (*Transaction) ReadPoolUnlock

func (t *Transaction) ReadPoolUnlock(poolID string, fee int64) (err error)

ReadPoolUnlock for current user and given pool.

func (*Transaction) RegisterMultiSig

func (t *Transaction) RegisterMultiSig(walletstr string, mswallet string) error

RegisterMultiSig register a multisig wallet with the SC.

func (*Transaction) RegisterVote

func (t *Transaction) RegisterVote(signerwalletstr string, msvstr string) error

RegisterVote register a multisig wallet with the SC.

func (*Transaction) Send

func (t *Transaction) Send(toClientID string, val int64, desc string) error

func (*Transaction) SendWithSignatureHash

func (t *Transaction) SendWithSignatureHash(toClientID string, val int64, desc string, sig string, CreationDate int64, hash string) error

func (*Transaction) SetTransactionCallback

func (t *Transaction) SetTransactionCallback(cb TransactionCallback) error

func (*Transaction) SetTransactionFee

func (t *Transaction) SetTransactionFee(txnFee int64) error

func (*Transaction) SetTransactionHash

func (t *Transaction) SetTransactionHash(hash string) error

func (*Transaction) StakePoolLock

func (t *Transaction) StakePoolLock(blobberID string, lock, fee int64) (
	err error)

StakePoolLock used to lock tokens in a stake pool of a blobber.

func (*Transaction) StakePoolUnlock

func (t *Transaction) StakePoolUnlock(blobberID, poolID string,
	fee int64) (err error)

StakePoolUnlock by blobberID and poolID.

func (*Transaction) StorageScUpdateConfig

func (t *Transaction) StorageScUpdateConfig(ip *InputMap) (err error)

func (*Transaction) StoreData

func (t *Transaction) StoreData(data string) error

func (*Transaction) UnlockTokens

func (t *Transaction) UnlockTokens(poolID string) error

func (*Transaction) UpdateAllocation

func (t *Transaction) UpdateAllocation(allocID string, sizeDiff int64,
	expirationDiff int64, lock, fee int64) (err error)

UpdateAllocation transaction.

func (*Transaction) UpdateBlobberSettings

func (t *Transaction) UpdateBlobberSettings(b *Blobber, fee int64) (err error)

UpdateBlobberSettings update settings of a blobber.

func (*Transaction) Verify

func (t *Transaction) Verify() error

func (*Transaction) VestingAdd

func (t *Transaction) VestingAdd(ar *VestingAddRequest, value int64) (
	err error)

func (*Transaction) VestingDelete

func (t *Transaction) VestingDelete(poolID string) (err error)

func (*Transaction) VestingStop

func (t *Transaction) VestingStop(sr *VestingStopRequest) (err error)

func (*Transaction) VestingTrigger

func (t *Transaction) VestingTrigger(poolID string) (err error)

func (*Transaction) VestingUnlock

func (t *Transaction) VestingUnlock(poolID string) (err error)

func (*Transaction) VestingUpdateConfig

func (t *Transaction) VestingUpdateConfig(vscc *InputMap) (err error)

func (*Transaction) WritePoolLock

func (t *Transaction) WritePoolLock(allocID, blobberID string, duration int64,
	lock, fee int64) (err error)

WritePoolLock locks tokens for current user and given allocation, using given duration. If blobberID is not empty, then tokens will be locked for given allocation->blobber only.

func (*Transaction) WritePoolUnlock

func (t *Transaction) WritePoolUnlock(poolID string, fee int64) (
	err error)

WritePoolUnlock for current user and given pool.

type TransactionCallback

type TransactionCallback interface {
	OnTransactionComplete(t *Transaction, status int)
	OnVerifyComplete(t *Transaction, status int)
	OnAuthComplete(t *Transaction, status int)
}

TransactionCallback needs to be implemented by the caller for transaction related APIs

type TransactionScheme

type TransactionScheme interface {
	// SetTransactionCallback implements storing the callback
	// used to call after the transaction or verification is completed
	SetTransactionCallback(cb TransactionCallback) error
	// Send implements sending token to a given clientid
	Send(toClientID string, val int64, desc string) error
	// StoreData implements store the data to blockchain
	StoreData(data string) error
	// ExecuteSmartContract impements the Faucet Smart contract
	ExecuteSmartContract(address, methodName, jsoninput string, val int64) error
	// ExecuteFaucetSCWallet impements the Faucet Smart contract for a given wallet
	ExecuteFaucetSCWallet(walletStr string, methodName string, input []byte) error
	// GetTransactionHash implements retrieval of hash of the submitted transaction
	GetTransactionHash() string
	// LockTokens implements the lock token.
	LockTokens(val int64, durationHr int64, durationMin int) error
	// UnlockTokens implements unlocking of earlier locked tokens.
	UnlockTokens(poolID string) error
	//RegisterMultiSig registers a group wallet and subwallets with MultisigSC
	RegisterMultiSig(walletstr, mswallet string) error
	// SetTransactionHash implements verify a previous transation status
	SetTransactionHash(hash string) error
	// SetTransactionFee implements method to set the transaction fee
	SetTransactionFee(txnFee int64) error
	// Verify implements verify the transaction
	Verify() error
	// GetVerifyConfirmationStatus implements the verification status from sharders
	GetVerifyConfirmationStatus() ConfirmationStatus
	// GetVerifyOutput implements the verifcation output from sharders
	GetVerifyOutput() string
	// GetTransactionError implements error string incase of transaction failure
	GetTransactionError() string
	// GetVerifyError implements error string incase of verify failure error
	GetVerifyError() string

	// Output of transaction.
	Output() []byte

	// vesting SC
	VestingTrigger(poolID string) error
	VestingStop(sr *VestingStopRequest) error
	VestingUnlock(poolID string) error
	VestingAdd(ar *VestingAddRequest, value int64) error
	VestingDelete(poolID string) error
	VestingUpdateConfig(*InputMap) error

	MinerSCMinerSettings(*MinerSCMinerInfo) error
	MinerSCSharderSettings(*MinerSCMinerInfo) error
	MinerSCLock(minerID string, lock int64) error
	MienrSCUnlock(minerID, poolID string) error
	MinerScUpdateConfig(*InputMap) error
	MinerScUpdateGlobals(*InputMap) error
	MinerSCDeleteMiner(*MinerSCMinerInfo) error
	MinerSCDeleteSharder(*MinerSCMinerInfo) error

	FinalizeAllocation(allocID string, fee int64) error
	CancelAllocation(allocID string, fee int64) error
	CreateAllocation(car *CreateAllocationRequest, lock, fee int64) error //
	CreateReadPool(fee int64) error
	ReadPoolLock(allocID string, blobberID string, duration int64, lock, fee int64) error
	ReadPoolUnlock(poolID string, fee int64) error
	StakePoolLock(blobberID string, lock, fee int64) error
	StakePoolUnlock(blobberID string, poolID string, fee int64) error
	UpdateBlobberSettings(blobber *Blobber, fee int64) error
	UpdateAllocation(allocID string, sizeDiff int64, expirationDiff int64, lock, fee int64) error
	WritePoolLock(allocID string, blobberID string, duration int64, lock, fee int64) error
	WritePoolUnlock(poolID string, fee int64) error
	StorageScUpdateConfig(*InputMap) error

	// Interest pool SC
	InterestPoolUpdateConfig(*InputMap) error

	// Faucet
	FaucetUpdateConfig(*InputMap) error
}

TransactionScheme implements few methods for block chain.

Note: to be buildable on MacOSX all arguments should have names.

func NewTransaction

func NewTransaction(cb TransactionCallback, txnFee int64) (TransactionScheme, error)

NewTransaction allocation new generic transaction object for any operation

type TransactionWithAuth

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

func (*TransactionWithAuth) CancelAllocation

func (ta *TransactionWithAuth) CancelAllocation(allocID string, fee int64) (
	err error)

CancelAllocation transaction.

func (*TransactionWithAuth) CreateAllocation

func (ta *TransactionWithAuth) CreateAllocation(car *CreateAllocationRequest,
	lock, fee int64) (err error)

CreateAllocation transaction.

func (*TransactionWithAuth) CreateReadPool

func (ta *TransactionWithAuth) CreateReadPool(fee int64) (err error)

CreateReadPool for current user.

func (*TransactionWithAuth) ExecuteFaucetSCWallet

func (ta *TransactionWithAuth) ExecuteFaucetSCWallet(walletStr string, methodName string, input []byte) error

ExecuteFaucetSCWallet impements the Faucet Smart contract for a given wallet

func (*TransactionWithAuth) ExecuteSmartContract

func (ta *TransactionWithAuth) ExecuteSmartContract(address, methodName, jsoninput string, val int64) error

func (*TransactionWithAuth) FaucetUpdateConfig

func (ta *TransactionWithAuth) FaucetUpdateConfig(
	ip *InputMap,
) (err error)

func (*TransactionWithAuth) FinalizeAllocation

func (ta *TransactionWithAuth) FinalizeAllocation(allocID string, fee int64) (
	err error)

FinalizeAllocation transaction.

func (*TransactionWithAuth) GetTransactionError

func (ta *TransactionWithAuth) GetTransactionError() string

func (*TransactionWithAuth) GetTransactionHash

func (ta *TransactionWithAuth) GetTransactionHash() string

func (*TransactionWithAuth) GetVerifyConfirmationStatus

func (ta *TransactionWithAuth) GetVerifyConfirmationStatus() ConfirmationStatus

func (*TransactionWithAuth) GetVerifyError

func (ta *TransactionWithAuth) GetVerifyError() string

func (*TransactionWithAuth) GetVerifyOutput

func (ta *TransactionWithAuth) GetVerifyOutput() string

func (*TransactionWithAuth) InterestPoolUpdateConfig

func (ta *TransactionWithAuth) InterestPoolUpdateConfig(
	ip *InputMap,
) (err error)

func (*TransactionWithAuth) LockTokens

func (ta *TransactionWithAuth) LockTokens(val int64, durationHr int64, durationMin int) error

func (*TransactionWithAuth) MienrSCUnlock

func (ta *TransactionWithAuth) MienrSCUnlock(nodeID, poolID string) (
	err error)

func (*TransactionWithAuth) MinerSCDeleteMiner

func (ta *TransactionWithAuth) MinerSCDeleteMiner(info *MinerSCMinerInfo) (
	err error)

func (*TransactionWithAuth) MinerSCDeleteSharder

func (ta *TransactionWithAuth) MinerSCDeleteSharder(info *MinerSCMinerInfo) (
	err error)

func (*TransactionWithAuth) MinerSCLock

func (ta *TransactionWithAuth) MinerSCLock(minerID string,
	lock int64) (err error)

func (*TransactionWithAuth) MinerSCMinerSettings

func (ta *TransactionWithAuth) MinerSCMinerSettings(info *MinerSCMinerInfo) (
	err error)

func (*TransactionWithAuth) MinerSCSharderSettings

func (ta *TransactionWithAuth) MinerSCSharderSettings(info *MinerSCMinerInfo) (
	err error)

func (*TransactionWithAuth) MinerScUpdateConfig

func (ta *TransactionWithAuth) MinerScUpdateConfig(
	ip *InputMap,
) (err error)

func (*TransactionWithAuth) MinerScUpdateGlobals

func (ta *TransactionWithAuth) MinerScUpdateGlobals(
	ip *InputMap,
) (err error)

func (*TransactionWithAuth) Output

func (ta *TransactionWithAuth) Output() []byte

func (*TransactionWithAuth) ReadPoolLock

func (ta *TransactionWithAuth) ReadPoolLock(allocID, blobberID string,
	duration int64, lock, fee int64) (err error)

ReadPoolLock locks tokens for current user and given allocation, using given duration. If blobberID is not empty, then tokens will be locked for given allocation->blobber only.

func (*TransactionWithAuth) ReadPoolUnlock

func (ta *TransactionWithAuth) ReadPoolUnlock(poolID string, fee int64) (
	err error)

ReadPoolUnlock for current user and given pool.

func (*TransactionWithAuth) RegisterMultiSig

func (ta *TransactionWithAuth) RegisterMultiSig(walletstr string, mswallet string) error

RegisterMultiSig register a multisig wallet with the SC.

func (*TransactionWithAuth) Send

func (ta *TransactionWithAuth) Send(toClientID string, val int64, desc string) error

func (*TransactionWithAuth) SetTransactionCallback

func (ta *TransactionWithAuth) SetTransactionCallback(cb TransactionCallback) error

func (*TransactionWithAuth) SetTransactionFee

func (ta *TransactionWithAuth) SetTransactionFee(txnFee int64) error

func (*TransactionWithAuth) SetTransactionHash

func (ta *TransactionWithAuth) SetTransactionHash(hash string) error

func (*TransactionWithAuth) StakePoolLock

func (ta *TransactionWithAuth) StakePoolLock(blobberID string,
	lock, fee int64) (err error)

StakePoolLock used to lock tokens in a stake pool of a blobber.

func (*TransactionWithAuth) StakePoolUnlock

func (ta *TransactionWithAuth) StakePoolUnlock(blobberID, poolID string,
	fee int64) (err error)

StakePoolUnlock by blobberID and poolID.

func (*TransactionWithAuth) StorageScUpdateConfig

func (ta *TransactionWithAuth) StorageScUpdateConfig(
	ip *InputMap,
) (err error)

func (*TransactionWithAuth) StoreData

func (ta *TransactionWithAuth) StoreData(data string) error

func (*TransactionWithAuth) UnlockTokens

func (ta *TransactionWithAuth) UnlockTokens(poolID string) error

func (*TransactionWithAuth) UpdateAllocation

func (ta *TransactionWithAuth) UpdateAllocation(allocID string, sizeDiff int64,
	expirationDiff int64, lock, fee int64) (err error)

UpdateAllocation transaction.

func (*TransactionWithAuth) UpdateBlobberSettings

func (ta *TransactionWithAuth) UpdateBlobberSettings(blob *Blobber, fee int64) (
	err error)

UpdateBlobberSettings update settings of a blobber.

func (*TransactionWithAuth) Verify

func (ta *TransactionWithAuth) Verify() error

func (*TransactionWithAuth) VestingAdd

func (ta *TransactionWithAuth) VestingAdd(ar *VestingAddRequest,
	value int64) (err error)

func (*TransactionWithAuth) VestingDelete

func (ta *TransactionWithAuth) VestingDelete(poolID string) (err error)

func (*TransactionWithAuth) VestingStop

func (ta *TransactionWithAuth) VestingStop(sr *VestingStopRequest) (err error)

func (*TransactionWithAuth) VestingTrigger

func (ta *TransactionWithAuth) VestingTrigger(poolID string) (err error)

func (*TransactionWithAuth) VestingUnlock

func (ta *TransactionWithAuth) VestingUnlock(poolID string) (err error)

func (*TransactionWithAuth) VestingUpdateConfig

func (ta *TransactionWithAuth) VestingUpdateConfig(
	ip *InputMap,
) (err error)

func (*TransactionWithAuth) WritePoolLock

func (ta *TransactionWithAuth) WritePoolLock(allocID, blobberID string,
	duration int64, lock, fee int64) (err error)

WritePoolLock locks tokens for current user and given allocation, using given duration. If blobberID is not empty, then tokens will be locked for given allocation->blobber only.

func (*TransactionWithAuth) WritePoolUnlock

func (ta *TransactionWithAuth) WritePoolUnlock(poolID string, fee int64) (
	err error)

WritePoolUnlock for current user and given pool.

type VestingAddRequest

type VestingAddRequest struct {
	Description  string           `json:"description"`  // allow empty
	StartTime    common.Timestamp `json:"start_time"`   //
	Duration     time.Duration    `json:"duration"`     //
	Destinations []*VestingDest   `json:"destinations"` //
}

type VestingClientList

type VestingClientList struct {
	Pools []common.Key `json:"pools"`
}

type VestingDest

type VestingDest struct {
	ID     common.Key     `json:"id"`     // destination ID
	Amount common.Balance `json:"amount"` // amount to vest for the destination
}

type VestingDestInfo

type VestingDestInfo struct {
	ID     common.Key       `json:"id"`     // identifier
	Wanted common.Balance   `json:"wanted"` // wanted amount for entire period
	Earned common.Balance   `json:"earned"` // can unlock
	Vested common.Balance   `json:"vested"` // already vested
	Last   common.Timestamp `json:"last"`   // last time unlocked
}

type VestingPoolInfo

type VestingPoolInfo struct {
	ID           common.Key         `json:"pool_id"`      // pool ID
	Balance      common.Balance     `json:"balance"`      // real pool balance
	Left         common.Balance     `json:"left"`         // owner can unlock
	Description  string             `json:"description"`  // description
	StartTime    common.Timestamp   `json:"start_time"`   // from
	ExpireAt     common.Timestamp   `json:"expire_at"`    // until
	Destinations []*VestingDestInfo `json:"destinations"` // receivers
	ClientID     common.Key         `json:"client_id"`    // owner
}

type VestingSCConfig

type VestingSCConfig struct {
	MinLock              common.Balance `json:"min_lock"`
	MinDuration          time.Duration  `json:"min_duration"`
	MaxDuration          time.Duration  `json:"max_duration"`
	MaxDestinations      int            `json:"max_destinations"`
	MaxDescriptionLength int            `json:"max_description_length"`
}

type VestingStopRequest

type VestingStopRequest struct {
	PoolID      common.Key `json:"pool_id"`
	Destination common.Key `json:"destination"`
}

Jump to

Keyboard shortcuts

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