registry

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2022 License: Apache-2.0, BSD-2-Clause Imports: 16 Imported by: 1

Documentation

Overview

Package registry provides a business specific API to the local database.

Index

Constants

View Source
const BlobCacheDefaultTTL = 1 * time.Hour
View Source
const (
	// CfgBindAddress defines the config flag of the web API binding address.
	CfgRewardAddress = "reward.address"
)

Variables

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

Functions

func GetFeeDestination added in v0.1.0

func GetFeeDestination(chainID *iscp.ChainID) ledgerstate.Address

func InitFlags

func InitFlags()

func MakeChainRecordDbKey added in v0.2.0

func MakeChainRecordDbKey(chainID *iscp.ChainID) []byte

Types

type BlobCache added in v0.2.0

type BlobCache interface {
	GetBlob(h hashing.HashValue) ([]byte, bool, error)
	HasBlob(h hashing.HashValue) (bool, error)
	// PutBlob ttl s TimeToLive, expiration time in Unix nanoseconds
	PutBlob(data []byte, ttl ...time.Duration) (hashing.HashValue, error)
}

BlobCache is an access to the cache of big binary objects

type ChainRecord added in v0.1.0

type ChainRecord struct {
	ChainID *iscp.ChainID
	Active  bool
}

ChainRecord represents chain the node is participating in TODO optimize, no need for a persistent structure, simple activity tag is enough

func ChainRecordFromBytes added in v0.2.0

func ChainRecordFromBytes(data []byte) (*ChainRecord, error)

CommitteeRecordFromBytes

func FromMarshalUtil added in v0.2.0

func FromMarshalUtil(mu *marshalutil.MarshalUtil) (*ChainRecord, error)

func (*ChainRecord) Bytes added in v0.2.0

func (rec *ChainRecord) Bytes() []byte

func (*ChainRecord) String added in v0.1.0

func (rec *ChainRecord) String() string

type ChainRecordRegistryProvider added in v0.2.0

type ChainRecordRegistryProvider interface {
	GetChainRecordByChainID(chainID *iscp.ChainID) (*ChainRecord, error)
	GetChainRecords() ([]*ChainRecord, error)
	UpdateChainRecord(chainID *iscp.ChainID, f func(*ChainRecord) bool) (*ChainRecord, error)
	ActivateChainRecord(chainID *iscp.ChainID) (*ChainRecord, error)
	DeactivateChainRecord(chainID *iscp.ChainID) (*ChainRecord, error)
}

ChainRecordRegistryProvider stands for a partial registry interface, needed for this package.

type DKShareRegistryProvider added in v0.2.0

type DKShareRegistryProvider interface {
	SaveDKShare(dkShare *tcrypto.DKShare) error
	LoadDKShare(sharedAddress ledgerstate.Address) (*tcrypto.DKShare, error)
}

DKShareRegistryProvider stands for a partial registry interface, needed for this package. It should be implemented by registry.impl

type Impl added in v0.1.0

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

Impl is just a placeholder to implement all interfaces needed by different components. Each of the interfaces are implemented in the corresponding file in this package.

func NewRegistry added in v0.1.0

func NewRegistry(log *logger.Logger, store kvstore.KVStore) *Impl

New creates new instance of the registry implementation.

func (*Impl) ActivateChainRecord added in v0.2.0

func (r *Impl) ActivateChainRecord(chainID *iscp.ChainID) (*ChainRecord, error)

func (*Impl) DeactivateChainRecord added in v0.2.0

func (r *Impl) DeactivateChainRecord(chainID *iscp.ChainID) (*ChainRecord, error)

func (*Impl) DistrustPeer added in v0.2.0

func (r *Impl) DistrustPeer(pubKey ed25519.PublicKey) (*peering.TrustedPeer, error)

DistrustPeer implements TrustedNetworkManager interface. Get is kind of optional, so we ignore errors related to it.

func (*Impl) GetBlob added in v0.1.0

func (r *Impl) GetBlob(h hashing.HashValue) ([]byte, bool, error)

Reads data from registry by hash. Returns existence flag

func (*Impl) GetChainRecordByChainID added in v0.2.0

func (r *Impl) GetChainRecordByChainID(chainID *iscp.ChainID) (*ChainRecord, error)

func (*Impl) GetChainRecords added in v0.2.0

func (r *Impl) GetChainRecords() ([]*ChainRecord, error)

func (*Impl) GetNodeIdentity added in v0.1.0

func (r *Impl) GetNodeIdentity() (*ed25519.KeyPair, error)

GetNodeIdentity implements NodeIdentityProvider.

func (*Impl) GetNodePublicKey added in v0.1.0

func (r *Impl) GetNodePublicKey() (*ed25519.PublicKey, error)

GetNodePublicKey implements NodeIdentityProvider.

func (*Impl) HasBlob added in v0.1.0

func (r *Impl) HasBlob(h hashing.HashValue) (bool, error)

func (*Impl) IsTrustedPeer added in v0.2.0

func (r *Impl) IsTrustedPeer(pubKey ed25519.PublicKey) error

IsTrustedPeer implements TrustedNetworkManager interface.

func (*Impl) LoadDKShare added in v0.1.0

func (r *Impl) LoadDKShare(sharedAddress ledgerstate.Address) (*tcrypto.DKShare, error)

LoadDKShare implements dkg.DKShareRegistryProvider.

func (*Impl) PutBlob added in v0.1.0

func (r *Impl) PutBlob(data []byte, ttl ...time.Duration) (hashing.HashValue, error)

PutBlob Writes data into the registry with the key of its hash Also stores TTL if provided

func (*Impl) SaveChainRecord added in v0.2.0

func (r *Impl) SaveChainRecord(rec *ChainRecord) error

func (*Impl) SaveDKShare added in v0.1.0

func (r *Impl) SaveDKShare(dkShare *tcrypto.DKShare) error

SaveDKShare implements dkg.DKShareRegistryProvider.

func (*Impl) TrustPeer added in v0.2.0

func (r *Impl) TrustPeer(pubKey ed25519.PublicKey, netID string) (*peering.TrustedPeer, error)

TrustPeer implements TrustedNetworkManager interface.

func (*Impl) TrustedPeers added in v0.2.0

func (r *Impl) TrustedPeers() ([]*peering.TrustedPeer, error)

TrustedPeers implements TrustedNetworkManager interface.

func (*Impl) UpdateChainRecord added in v0.2.0

func (r *Impl) UpdateChainRecord(chainID *iscp.ChainID, f func(*ChainRecord) bool) (*ChainRecord, error)

type NodeIdentityProvider added in v0.1.0

type NodeIdentityProvider interface {
	GetNodeIdentity() (*ed25519.KeyPair, error)
	GetNodePublicKey() (*ed25519.PublicKey, error)
}

type Provider added in v0.2.0

type Provider func() *Impl

Jump to

Keyboard shortcuts

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