bucket

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BucketCreatedEventId                = "004464634275636b65743a3a4275636b65744372656174656400000000000000"
	BucketAllocatedEventId              = "004464634275636b65743a3a4275636b6574416c6c6f63617465640000000000"
	BucketSettlePaymentEventId          = "004464634275636b65743a3a4275636b6574536574746c655061796d656e7400"
	BucketAvailabilityUpdatedId         = "8d8714b3df602b0ce92b8a3de12daedf222ff9198078f834d57176ca2a06359c"
	ClusterCreatedEventId               = "004464634275636b65743a3a436c757374657243726561746564000000000000"
	ClusterNodeReplacedEventId          = "004464634275636b65743a3a436c75737465724e6f64655265706c6163656400"
	ClusterReserveResourceEventId       = "84d6d26a3275dced8e359779bf21488762a1d88029f52522d8fc27607759399e"
	ClusterDistributeRevenuesEventId    = "65441936759a16fb28d0e059b878f2e48283ca2eac57c396a8035cce9e2acdd3"
	CdnClusterCreatedEventId            = "004464634275636b65743a3a43646e436c757374657243726561746564000000"
	CdnClusterDistributeRevenuesEventId = "4e19fc4683a9a741a09d89a1d62b22d592a8bf10e2b8b6eff7c6742a0ed88bb4"
	CdnNodeCreatedEventId               = "004464634275636b65743a3a43646e4e6f646543726561746564000000000000"
	NodeCreatedEventId                  = "004464634275636b65743a3a4e6f646543726561746564000000000000000000"
	DepositEventId                      = "004464634275636b65743a3a4465706f73697400000000000000000000000000"
	GrantPermissionEventId              = "004464634275636b65743a3a4772616e745065726d697373696f6e0000000000"
	RevokePermissionEventId             = "004464634275636b65743a3a5265766f6b655065726d697373696f6e00000000"
)

Variables

View Source
var (
	ErrBucketDoesNotExist   = errors.New("bucket doesn't exist")
	ErrProviderDoesNotExist = errors.New("provider doesn't exist")
	ErrUnauthorizedProvider = errors.New("unauthorized provider")
	ErrTransferFailed       = errors.New("transfer failed")
	ErrUndefined            = errors.New("undefined error")
)

ToDo update error regarding latest contract

View Source
var NodeTags = map[string]byte{
	"UNKNOWN":  UNKNOWN,
	"ACTIVE":   ACTIVE,
	"ADDING":   ADDING,
	"DELETING": DELETING,
	"OFFLINE":  OFFLINE,
}

Functions

This section is empty.

Types

type Account

type Account struct {
	Deposit           Cash
	Bonded            Cash
	Negative          Cash
	UnboundedAmount   Cash
	UnbondedTimestamp uint64
	PayableSchedule   Schedule
}

func (*Account) HasBalance

func (a *Account) HasBalance() bool

type AccountId

type AccountId = types.AccountID

type Balance

type Balance = types.U128

type Bucket

type Bucket struct {
	OwnerId            AccountId
	ClusterId          ClusterId
	ResourceReserved   Resource
	PublicAvailability bool
	GasConsumptionCap  Resource
}

type BucketAllocatedEvent added in v0.1.5

type BucketAllocatedEvent struct {
	BucketId  BucketId
	ClusterId ClusterId
	Resource  Resource
}

type BucketAvailabilityUpdatedEvent added in v0.1.5

type BucketAvailabilityUpdatedEvent struct {
	BucketId           BucketId
	PublicAvailability bool
}

type BucketCreatedEvent added in v0.1.5

type BucketCreatedEvent struct {
	BucketId  BucketId
	AccountId AccountId
}

type BucketId

type BucketId = uint32

type BucketParams

type BucketParams = Params

type BucketSettlePaymentEvent added in v0.1.5

type BucketSettlePaymentEvent struct {
	BucketId  BucketId
	ClusterId ClusterId
}

type BucketStatus

type BucketStatus struct {
	BucketId           BucketId
	Bucket             Bucket
	Params             BucketParams
	WriterIds          []AccountId
	ReaderIds          []AccountId
	RentCoveredUntilMs uint64
}

func (*BucketStatus) HasReadAccess

func (b *BucketStatus) HasReadAccess(publicKey []byte) bool

func (*BucketStatus) HasWriteAccess

func (b *BucketStatus) HasWriteAccess(publicKey []byte) bool

func (*BucketStatus) IsOwner

func (b *BucketStatus) IsOwner(publicKey []byte) bool

func (*BucketStatus) RentExpired

func (b *BucketStatus) RentExpired() bool

type CDNCluster

type CDNCluster struct {
	ManagerId    AccountId
	CDNNodes     []NodeId
	ResourceUsed Resource
	Revenues     Cash
	UsdPerGb     Balance
}

type CDNClusterStatus

type CDNClusterStatus struct {
	ClusterId  ClusterId
	CDNCluster CDNCluster
}

type CDNNode

type CDNNode struct {
	ProviderId           ProviderId
	UndistributedPayment Balance
}

type CDNNodeParams

type CDNNodeParams struct {
	Url       string  `json:"url"`
	Size      FlexInt `json:"size"`
	Location  string  `json:"location"`
	PublicKey string  `json:"publicKey"`
}

Structure-helper for json on the CDN Node Params string

func ReadCDNNodeParams

func ReadCDNNodeParams(s string) (p CDNNodeParams, err error)

type CDNNodeStatus

type CDNNodeStatus struct {
	NodeId NodeId
	Node   CDNNode
	Params string
}

type Cash

type Cash = Balance

type CdnClusterCreatedEvent added in v0.1.5

type CdnClusterCreatedEvent struct {
	ClusterId ClusterId
	AccountId AccountId
}

type CdnClusterDistributeRevenuesEvent added in v0.1.5

type CdnClusterDistributeRevenuesEvent struct {
	ClusterId  ClusterId
	ProviderId AccountId
}

type CdnNodeCreatedEvent added in v0.1.5

type CdnNodeCreatedEvent struct {
	NodeId    NodeId
	AccountId AccountId
	Payment   Balance
}

type Cluster

type Cluster struct {
	ManagerId        AccountId
	ResourcePerVNode Resource
	ResourceUsed     Resource
	Revenues         Cash
	Nodes            []NodeId
	VNodes           [][]Token
	TotalRent        Balance
}

type ClusterCreatedEvent added in v0.1.5

type ClusterCreatedEvent struct {
	ClusterId     ClusterId
	AccountId     AccountId
	ClusterParams Params
}

type ClusterDistributeRevenuesEvent added in v0.1.5

type ClusterDistributeRevenuesEvent struct {
	ClusterId ClusterId
	AccountId AccountId
}

type ClusterId

type ClusterId = uint32

type ClusterNodeReplacedEvent added in v0.1.5

type ClusterNodeReplacedEvent struct {
	ClusterId ClusterId
	NodeId    NodeId
}

type ClusterParams

type ClusterParams struct {
	ReplicationFactor FlexInt `json:"replicationFactor"`
}

type ClusterReserveResourceEvent added in v0.1.5

type ClusterReserveResourceEvent struct {
	ClusterId ClusterId
	NodeId    NodeId
}

type ClusterStatus

type ClusterStatus struct {
	ClusterId ClusterId
	Cluster   Cluster
	Params    Params
}

func (*ClusterStatus) ReplicationFactor

func (c *ClusterStatus) ReplicationFactor() uint

type DdcBucketContract

type DdcBucketContract interface {
	GetContractAddress() string
	GetLastAccessTime() time.Time

	BucketGet(bucketId uint32) (*BucketStatus, error)
	ClusterGet(clusterId uint32) (*ClusterStatus, error)
	NodeGet(nodeId uint32) (*NodeStatus, error)
	CDNClusterGet(clusterId uint32) (*CDNClusterStatus, error)
	CDNNodeGet(nodeId uint32) (*CDNNodeStatus, error)
	AccountGet(account types.AccountID) (*Account, error)
	AddContractEventHandler(event string, handler func(interface{})) error
	GetEventDispatcher() map[types.Hash]pkg.ContractEventDispatchEntry
}

func CreateDdcBucketContract

func CreateDdcBucketContract(client pkg.BlockchainClient, contractAddressSS58 string) DdcBucketContract

type DepositEvent added in v0.1.5

type DepositEvent struct {
	AccountId AccountId
	Value     Balance
}

type FlexInt added in v0.1.6

type FlexInt int

A FlexInt is an int that can be unmarshalled from a JSON field that has either a number or a string value. E.g. if the json field contains an string "42", the FlexInt value will be "42". Use it for example for int fields that can came from smart contract "params" field. JS will save them as strings, but Go will expect them to be ints.

func (*FlexInt) UnmarshalJSON added in v0.1.6

func (fi *FlexInt) UnmarshalJSON(b []byte) error

type GrantPermissionEvent added in v0.1.5

type GrantPermissionEvent struct {
	AccountId  AccountId
	Permission byte
}

type Node

type Node struct {
	ProviderId    ProviderId
	RentPerMonth  Balance
	FreeResources Resource
	NodeState     NodeState
}

type NodeCreatedEvent added in v0.1.5

type NodeCreatedEvent struct {
	NodeId       NodeId
	ProviderId   AccountId
	RentPerMonth Balance
	NodeParams   Params
}

type NodeId

type NodeId = uint32

type NodeState

type NodeState = byte
const (
	UNKNOWN NodeState = iota
	ACTIVE
	ADDING
	DELETING
	OFFLINE
)

type NodeStatus

type NodeStatus struct {
	NodeId NodeId
	Node   Node
	Params string
}

type Params

type Params = string

type ProviderId

type ProviderId = AccountId

type Resource

type Resource = uint32

type Result

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

type RevokePermissionEvent added in v0.1.5

type RevokePermissionEvent struct {
	AccountId  AccountId
	Permission byte
}

type Schedule

type Schedule struct {
	Rate   Balance
	Offset Balance
}

type Token

type Token = uint64

Jump to

Keyboard shortcuts

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