registry

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: Apache-2.0, BSD-2-Clause Imports: 16 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

This section is empty.

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
	Peers   []string
	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 CommitteeRecord added in v0.2.0

type CommitteeRecord struct {
	Address ledgerstate.Address
	Nodes   []string // "host_addr:port"
}

CommitteeRecord represents committee information TODO optimize: no need to persists address in the structure

func CommitteeRecordFromBytes added in v0.2.0

func CommitteeRecordFromBytes(data []byte) (*CommitteeRecord, error)

CommitteeRecordFromBytes

func CommitteeRecordFromMarshalUtil added in v0.2.0

func CommitteeRecordFromMarshalUtil(mu *marshalutil.MarshalUtil) (*CommitteeRecord, error)

CommitteeRecordFromMarshalUtil

func NewCommitteeRecord added in v0.2.0

func NewCommitteeRecord(addr ledgerstate.Address, nodes ...string) *CommitteeRecord

NewCommitteeRecord

func (*CommitteeRecord) Bytes added in v0.2.0

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

func (*CommitteeRecord) String added in v0.2.0

func (rec *CommitteeRecord) String() string

type CommitteeRegistryProvider added in v0.2.0

type CommitteeRegistryProvider interface {
	GetCommitteeRecord(addr ledgerstate.Address) (*CommitteeRecord, error)
	SaveCommitteeRecord(rec *CommitteeRecord) error
}

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) GetCommitteeRecord added in v0.2.0

func (r *Impl) GetCommitteeRecord(addr ledgerstate.Address) (*CommitteeRecord, 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) SaveCommitteeRecord added in v0.2.0

func (r *Impl) SaveCommitteeRecord(rec *CommitteeRecord) 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 PeerNetworkConfigProvider added in v0.2.0

type PeerNetworkConfigProvider interface {
	OwnNetID() string
	PeeringPort() int
	Neighbors() []string
	String() string
}

PeerNetworkConfigProvider access to node and chain configuration: a list of netIDs of potential peers

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