storenodes

package
v0.184.52 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: MPL-2.0, MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

package storenodes provides functionality to work with community specific storenodes Current limitations: - we support only one storenode per community - we assume that the storenode is always active - we don't support a way to regularly check connection similar to the `messenger_mailserver_cycle.go`

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)

Functions

This section is empty.

Types

type CommunityStorenodes

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

CommunityStorenodes has methods to handle the storenodes for a community

func NewCommunityStorenodes

func NewCommunityStorenodes(storenodesDB *Database, logger *zap.Logger) *CommunityStorenodes

func (*CommunityStorenodes) GetStorenodeByCommunnityID

func (m *CommunityStorenodes) GetStorenodeByCommunnityID(communityID string) (mailservers.Mailserver, error)

GetStorenodeByCommunnityID returns the active storenode for a community

func (*CommunityStorenodes) GetStorenodesFromDB

func (m *CommunityStorenodes) GetStorenodesFromDB(communityID types.HexBytes) ([]Storenode, error)

func (*CommunityStorenodes) HasStorenodeSetup

func (m *CommunityStorenodes) HasStorenodeSetup(communityID string) bool

func (*CommunityStorenodes) IsCommunityStoreNode

func (m *CommunityStorenodes) IsCommunityStoreNode(id string) bool

func (*CommunityStorenodes) ReloadFromDB

func (m *CommunityStorenodes) ReloadFromDB() error

ReloadFromDB loads or reloads the mailservers from the database (on adding/deleting mailservers)

func (*CommunityStorenodes) UpdateStorenodesInDB

func (m *CommunityStorenodes) UpdateStorenodesInDB(communityID types.HexBytes, snodes []Storenode, clock uint64) error

type Database

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

func NewDB

func NewDB(db *sql.DB) *Database

type Storenode

type Storenode struct {
	CommunityID types.HexBytes      `json:"community_id"`
	StorenodeID string              `json:"storenode_id"`
	Name        string              `json:"name"`
	Address     multiaddr.Multiaddr `json:"address"`
	Fleet       string              `json:"fleet"`
	Version     uint                `json:"version"`
	Clock       uint64              `json:"-"` // used to sync
	Removed     bool                `json:"-"`
	DeletedAt   int64               `json:"-"`
}

Storenode is a struct that represents a storenode, it is very closely related to `mailservers.Mailserver`

type Storenodes

type Storenodes []Storenode

func FromProtobuf

func FromProtobuf(storenodes []*protobuf.Storenode, clock uint64) Storenodes

func (Storenodes) ToProtobuf

func (m Storenodes) ToProtobuf() []*protobuf.Storenode

Jump to

Keyboard shortcuts

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