gnfd

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GreenFieldChain = "GreenfieldChain"
	// UpdateClientInternal defines the period of updating the best chain client
	UpdateClientInternal = 60
	// ExpectedOutputBlockInternal defines the time of estimating output block time
	ExpectedOutputBlockInternal = 2
)
View Source
const (
	// ChainSuccessTotal defines the metrics label of successfully total chain rpc
	ChainSuccessTotal = "chain_total_success"
	// ChainFailureTotal defines the metrics label of unsuccessfully total chain rpc
	ChainFailureTotal = "chain_total_failure"
	// ChainSuccessCurrentHeight defines the metrics label of successfully get current block height
	ChainSuccessCurrentHeight = "get_current_height_success"
	// ChainFailureCurrentHeight defines the metrics label of unsuccessfully get current block height
	ChainFailureCurrentHeight = "get_current_height_failure"
	// ChainSuccessHasAccount defines the metrics label of successfully check has account
	ChainSuccessHasAccount = "has_account_success"
	// ChainFailureHasAccount defines the metrics label of unsuccessfully check has account
	ChainFailureHasAccount = "has_account_failure"
	// ChainSuccessListSPs defines the metrics label of successfully list all sp infos
	ChainSuccessListSPs = "list_sp_success"
	// ChainFailureListSPs defines the metrics label of unsuccessfully list all sp infos
	ChainFailureListSPs = "list_sp_failure"
	// ChainSuccessListBondedValidators defines the metrics label of successfully list bonded validators
	ChainSuccessListBondedValidators = "list_bonded_validators_success"
	// ChainFailureListBondedValidators defines the metrics label of unsuccessfully list bonded validators
	ChainFailureListBondedValidators = "list_bonded_validators_failure"
	// ChainSuccessQueryStorageParams defines the metrics label of successfully query storage params
	ChainSuccessQueryStorageParams = "query_storage_param_success"
	// ChainFailureQueryStorageParams defines the metrics label of unsuccessfully query storage params
	ChainFailureQueryStorageParams = "query_storage_param_failure"
	// ChainSuccessQueryStorageParamsByTimestamp defines the metrics label of successfully query storage params by time
	ChainSuccessQueryStorageParamsByTimestamp = "query_storage_param_by_timestamp_success"
	// ChainFailureQueryStorageParamsByTimestamp defines the metrics label of unsuccessfully query storage params by time
	ChainFailureQueryStorageParamsByTimestamp = "query_storage_param_by_timestamp_failure"
	// ChainSuccessQueryBucketInfo defines the metrics label of successfully query bucket info
	ChainSuccessQueryBucketInfo = "query_bucket_info_success"
	// ChainFailureQueryBucketInfo defines the metrics label of successfully query object info
	ChainFailureQueryBucketInfo = "query_bucket_info_failure"
	// ChainSuccessQueryObjectInfo defines the metrics label of successfully query object info
	ChainSuccessQueryObjectInfo = "query_object_info_success"
	// ChainFailureQueryObjectInfo defines the metrics label of unsuccessfully query object info
	ChainFailureQueryObjectInfo = "query_object_info_failure"
	// ChainSuccessQueryObjectInfoByID defines the metrics label of successfully query object info by id
	ChainSuccessQueryObjectInfoByID = "query_object_info_by_id_success"
	// ChainFailureQueryObjectInfoByID defines the metrics label of unsuccessfully query object info by id
	ChainFailureQueryObjectInfoByID = "query_object_info_by_id_failure"
	// ChainSuccessQueryBucketInfoAndObjectInfo defines the metrics label of successfully query bucket and object info
	ChainSuccessQueryBucketInfoAndObjectInfo = "query_bucket_and_object_info_success"
	// ChainFailureQueryBucketInfoAndObjectInfo defines the metrics label of unsuccessfully query bucket and object info
	ChainFailureQueryBucketInfoAndObjectInfo = "query_bucket_and_object_info_failure"
	// ChainSuccessListenObjectSeal defines the metrics label of successfully listen object seal
	ChainSuccessListenObjectSeal = "listen_object_seal_success"
	// ChainFailureListenObjectSeal defines the metrics label of unsuccessfully listen object seal
	ChainFailureListenObjectSeal = "listen_object_seal_failure"
	// ChainSuccessListenRejectUnSealObject defines the metrics label of successfully listen object reject unseal
	ChainSuccessListenRejectUnSealObject = "listen_reject_unseal_object_success"
	// ChainFailureListenRejectUnSealObject defines the metrics label of unsuccessfully listen object reject unseal
	ChainFailureListenRejectUnSealObject = "listen_reject_unseal_object_failure"
	// ChainSuccessQueryPaymentStreamRecord defines the metrics label of successfully query payment stream
	ChainSuccessQueryPaymentStreamRecord = "query_payment_stream_record_success"
	// ChainFailureQueryPaymentStreamRecord defines the metrics label of unsuccessfully query payment stream
	ChainFailureQueryPaymentStreamRecord = "query_payment_stream_record_failure"
	// ChainSuccessVerifyGetObjectPermission defines the metrics label of successfully verify get object permission
	ChainSuccessVerifyGetObjectPermission = "verify_get_object_permission_success"
	// ChainFailureVerifyGetObjectPermission defines the metrics label of unsuccessfully verify get object permission
	ChainFailureVerifyGetObjectPermission = "verify_get_object_permission_failure"
	// ChainSuccessVerifyPutObjectPermission defines the metrics label of successfully verify put object permission
	ChainSuccessVerifyPutObjectPermission = "verify_put_object_permission_success"
	// ChainFailureVerifyPutObjectPermission defines the metrics label of unsuccessfully verify put object permission
	ChainFailureVerifyPutObjectPermission = "verify_put_object_permission_failure"

	// ConfirmBlockNumber defines wait block number.
	ConfirmBlockNumber = 3
	// WaitForNextBlockTimeout define wait block timeout.
	WaitForNextBlockTimeout = 30 * time.Second
)

Variables

View Source
var (
	ErrNoSuchBucket        = gfsperrors.Register(GreenFieldChain, http.StatusBadRequest, 500001, "no such bucket")
	ErrSealTimeout         = gfsperrors.Register(GreenFieldChain, http.StatusBadRequest, 500002, "seal failed")
	ErrRejectUnSealTimeout = gfsperrors.Register(GreenFieldChain, http.StatusBadRequest, 500003, "reject unseal failed")
)

Functions

This section is empty.

Types

type Gnfd

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

func NewGnfd

func NewGnfd(cfg *GnfdChainConfig) (*Gnfd, error)

NewGnfd returns the Greenfield instance.

func (*Gnfd) AvailableGlobalVirtualGroupFamilies added in v0.2.4

func (g *Gnfd) AvailableGlobalVirtualGroupFamilies(ctx context.Context, globalVirtualGroupFamiliesIDs []uint32) ([]uint32, error)

AvailableGlobalVirtualGroupFamilies submits a list global virtual group families Id to chain and return the filtered list of families which are able to server create bucket request.

func (*Gnfd) Close

func (g *Gnfd) Close() error

Close the Greenfield instance.

func (*Gnfd) ConfirmTransaction added in v0.2.4

func (g *Gnfd) ConfirmTransaction(ctx context.Context, txHash string) (*sdk.TxResponse, error)

ConfirmTransaction is used to confirm whether the transaction is on the chain.

func (*Gnfd) CurrentHeight

func (g *Gnfd) CurrentHeight(ctx context.Context) (height uint64, err error)

CurrentHeight the block height sub one as the stable height.

func (*Gnfd) HasAccount

func (g *Gnfd) HasAccount(ctx context.Context, address string) (has bool, err error)

HasAccount returns an indication of the existence of address.

func (*Gnfd) ListBondedValidators

func (g *Gnfd) ListBondedValidators(ctx context.Context) (validators []stakingtypes.Validator, err error)

ListBondedValidators returns the list of bonded validators.

func (*Gnfd) ListGlobalVirtualGroupsByFamilyID added in v0.2.3

func (g *Gnfd) ListGlobalVirtualGroupsByFamilyID(ctx context.Context, vgfID uint32) ([]*virtualgrouptypes.GlobalVirtualGroup, error)

ListGlobalVirtualGroupsByFamilyID returns gvg list by family.

func (*Gnfd) ListSPs

func (g *Gnfd) ListSPs(ctx context.Context) (spInfos []*sptypes.StorageProvider, err error)

ListSPs returns the list of storage provider info.

func (*Gnfd) ListVirtualGroupFamilies added in v0.2.3

func (g *Gnfd) ListVirtualGroupFamilies(ctx context.Context, spID uint32) ([]*virtualgrouptypes.GlobalVirtualGroupFamily, error)

ListVirtualGroupFamilies return the list of virtual group family. TODO: improve it by metadata indexer.

func (*Gnfd) ListenObjectSeal

func (g *Gnfd) ListenObjectSeal(ctx context.Context, objectID uint64, timeoutHeight int) (seal bool, err error)

ListenObjectSeal returns an indication of the object is sealed. TODO:: retrieve service support seal event subscription

func (*Gnfd) ListenRejectUnSealObject

func (g *Gnfd) ListenRejectUnSealObject(ctx context.Context, objectID uint64, timeoutHeight int) (rejected bool, err error)

ListenRejectUnSealObject returns an indication of the object is rejected. TODO:: retrieve service support reject unseal event subscription

func (*Gnfd) QueryBucketInfo

func (g *Gnfd) QueryBucketInfo(ctx context.Context, bucket string) (bucketInfo *storagetypes.BucketInfo, err error)

QueryBucketInfo returns the bucket info by name.

func (*Gnfd) QueryBucketInfoAndObjectInfo

func (g *Gnfd) QueryBucketInfoAndObjectInfo(ctx context.Context, bucket, object string) (bucketInfo *storagetypes.BucketInfo,
	objectInfo *storagetypes.ObjectInfo, err error)

QueryBucketInfoAndObjectInfo returns bucket info and object info, if not found, return the corresponding error code

func (*Gnfd) QueryBucketInfoById added in v0.2.3

func (g *Gnfd) QueryBucketInfoById(ctx context.Context, bucketId uint64) (bucketInfo *storagetypes.BucketInfo, err error)

QueryBucketInfoById returns the bucket info by name.

func (*Gnfd) QueryGlobalVirtualGroup added in v0.2.3

func (g *Gnfd) QueryGlobalVirtualGroup(ctx context.Context, gvgID uint32) (*virtualgrouptypes.GlobalVirtualGroup, error)

QueryGlobalVirtualGroup returns the global virtual group info.

func (*Gnfd) QueryObjectInfo

func (g *Gnfd) QueryObjectInfo(ctx context.Context, bucket, object string) (objectInfo *storagetypes.ObjectInfo, err error)

QueryObjectInfo returns the object info by name.

func (*Gnfd) QueryObjectInfoByID

func (g *Gnfd) QueryObjectInfoByID(ctx context.Context, objectID string) (objectInfo *storagetypes.ObjectInfo, err error)

QueryObjectInfoByID returns the object info by name.

func (*Gnfd) QueryPaymentStreamRecord

func (g *Gnfd) QueryPaymentStreamRecord(ctx context.Context, account string) (stream *paymenttypes.StreamRecord, err error)

QueryPaymentStreamRecord returns the steam record info by account.

func (*Gnfd) QuerySP added in v0.2.3

func (g *Gnfd) QuerySP(ctx context.Context, operatorAddress string) (*sptypes.StorageProvider, error)

QuerySP returns the sp info.

func (*Gnfd) QuerySPByID added in v0.2.3

func (g *Gnfd) QuerySPByID(ctx context.Context, spID uint32) (*sptypes.StorageProvider, error)

QuerySPByID returns the sp info.

func (*Gnfd) QuerySPFreeQuota added in v0.2.3

func (g *Gnfd) QuerySPFreeQuota(ctx context.Context, operatorAddress string) (uint64, error)

QuerySPFreeQuota returns the sp free quota

func (*Gnfd) QuerySPPrice added in v0.2.3

func (g *Gnfd) QuerySPPrice(ctx context.Context, operatorAddress string) (sptypes.SpStoragePrice, error)

QuerySPPrice returns the sp price info

func (*Gnfd) QueryStorageParams

func (g *Gnfd) QueryStorageParams(ctx context.Context) (params *storagetypes.Params, err error)

QueryStorageParams returns storage params

func (*Gnfd) QueryStorageParamsByTimestamp

func (g *Gnfd) QueryStorageParamsByTimestamp(ctx context.Context, timestamp int64) (params *storagetypes.Params, err error)

QueryStorageParamsByTimestamp returns storage params by block create time.

func (*Gnfd) QueryVirtualGroupFamily added in v0.2.3

func (g *Gnfd) QueryVirtualGroupFamily(ctx context.Context, vgfID uint32) (*virtualgrouptypes.GlobalVirtualGroupFamily, error)

QueryVirtualGroupFamily returns the virtual group family.

func (*Gnfd) QueryVirtualGroupParams added in v0.2.3

func (g *Gnfd) QueryVirtualGroupParams(ctx context.Context) (*virtualgrouptypes.Params, error)

QueryVirtualGroupParams return virtual group params.

func (*Gnfd) VerifyGetObjectPermission

func (g *Gnfd) VerifyGetObjectPermission(ctx context.Context, account, bucket, object string) (allow bool, err error)

VerifyGetObjectPermission verifies get object permission.

func (*Gnfd) VerifyPutObjectPermission

func (g *Gnfd) VerifyPutObjectPermission(ctx context.Context, account, bucket, object string) (allow bool, err error)

VerifyPutObjectPermission verifies put object permission.

func (*Gnfd) WaitForNextBlock added in v0.2.4

func (g *Gnfd) WaitForNextBlock(ctx context.Context) error

WaitForNextBlock is used to chain generate a new block.

type GnfdChainConfig

type GnfdChainConfig struct {
	ChainID      string
	ChainAddress []string
}

type GreenfieldClient

type GreenfieldClient struct {
	Provider string
	// contains filtered or unexported fields
}

GreenfieldClient the greenfield chain client, only use to query.

func (*GreenfieldClient) GnfdClient

func (client *GreenfieldClient) GnfdClient() *chainClient.GreenfieldClient

GnfdClient returns the greenfield chain client.

Jump to

Keyboard shortcuts

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