keepers

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagAccount                 = "a"
	TagPushKey                 = "g"
	TagAddressPushKeyID        = "ag"
	TagRepo                    = "r"
	TagRepoPropVote            = "rpv"
	TagRepoPropEndIndex        = "rei"
	TagNS                      = "ns"
	TagClosedProp              = "cp"
	TagBlockInfo               = "b"
	TagHelmRepo                = "hr"
	TagValidators              = "v"
	TagTrackedRepo             = "tr"
	TagAnnouncementScheduleKey = "ak"
	TagRepoRefLastSyncHeight   = "rrh"
)

Variables

View Source
var ErrBlockInfoNotFound = fmt.Errorf("block info not found")

ErrBlockInfoNotFound means the block info was not found

Functions

func MakeAccountKey

func MakeAccountKey(address string) []byte

MakeAccountKey creates a key for accessing an account

func MakeAddrPushKeyIDIndexKey

func MakeAddrPushKeyIDIndexKey(address, pushKeyID string) []byte

MakeAddrPushKeyIDIndexKey creates a key for address to push key index

func MakeAnnounceListKey

func MakeAnnounceListKey(key []byte, announceTime int64) []byte

MakeAnnounceListKey creates a key for adding DHT key announcement entry

func MakeBlockValidatorsKey

func MakeBlockValidatorsKey(height int64) []byte

MakeBlockValidatorsKey creates a key for storing validators of blocks

func MakeClosedProposalKey

func MakeClosedProposalKey(name, propID string) []byte

MakeClosedProposalKey creates a key for marking a proposal as "closed"

func MakeKeyBlockInfo

func MakeKeyBlockInfo(height int64) []byte

MakeKeyBlockInfo creates a key for accessing/storing committed block data.

func MakeKeyHelmRepo

func MakeKeyHelmRepo() []byte

MakeKeyHelmRepo creates a key for getting/setting the helm repo

func MakeNamespaceKey

func MakeNamespaceKey(name string) []byte

MakeNamespaceKey creates a key for accessing a namespace

func MakePushKeyKey

func MakePushKeyKey(pushKeyID string) []byte

MakePushKeyKey creates a key for storing push key

func MakeQueryAnnounceListKey

func MakeQueryAnnounceListKey() []byte

MakeQueryAnnounceListKey creates a key for accessing all DHT key announcements entries.

func MakeQueryKeyBlockInfo

func MakeQueryKeyBlockInfo() []byte

MakeQueryKeyBlockInfo creates a key for querying committed block data

func MakeQueryKeyBlockValidators

func MakeQueryKeyBlockValidators() []byte

MakeQueryKeyBlockValidators creates a key for querying all block validators

func MakeQueryKeyRepoProposalAtEndHeight

func MakeQueryKeyRepoProposalAtEndHeight(endHeight uint64) []byte

MakeQueryKeyRepoProposalAtEndHeight creates a key for finding repo proposals ending at the given height

func MakeQueryPushKeyIDsOfAddress

func MakeQueryPushKeyIDsOfAddress(address string) []byte

MakeQueryPushKeyIDsOfAddress creates a key for querying push key ids belonging to an address

func MakeQueryTrackedRepoKey

func MakeQueryTrackedRepoKey() []byte

MakeQueryTrackedRepoKey creates a key for accessing all tracked repo.

func MakeRepoKey

func MakeRepoKey(name string) []byte

MakeRepoKey creates a key for accessing a repository object

func MakeRepoProposalEndIndexKey

func MakeRepoProposalEndIndexKey(repoName, proposalID string, endHeight uint64) []byte

MakeRepoProposalEndIndexKey creates a key that makes a repo proposal to its end height

func MakeRepoProposalVoteKey

func MakeRepoProposalVoteKey(repoName, proposalID, voterAddr string) []byte

MakeRepoProposalVoteKey creates a key as flag for a repo proposal vote

func MakeRepoRefLastSyncHeightKey

func MakeRepoRefLastSyncHeightKey(repo, reference string) []byte

MakeRepoRefLastSyncHeightKey creates a key for storing a repo's reference last successful synchronized height.

func MakeTrackedRepoKey

func MakeTrackedRepoKey(name string) []byte

MakeTrackedRepoKey creates a key for accessing a tracked repo.

Types

type AccountKeeper

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

AccountKeeper manages account state.

func NewAccountKeeper

func NewAccountKeeper(state *tree.SafeTree) *AccountKeeper

NewAccountKeeper creates an instance of AccountKeeper

func (*AccountKeeper) Get

func (a *AccountKeeper) Get(address identifier.Address, blockNum ...uint64) *state.Account

Get returns an account by address.

ARGS: address: The address of the account blockNum: The target block to query (Optional. Default: latest)

CONTRACT: It returns an empty Account if no account is found.

func (*AccountKeeper) Update

func (a *AccountKeeper) Update(address identifier.Address, upd *state.Account)

Update sets a new object at the given address.

ARGS: address: The address of the account to update udp: The updated account object to replace the existing object.

type DHTKeeper

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

DHTKeeper manages DHT operation information.

func NewDHTKeyKeeper

func NewDHTKeyKeeper(db storagetypes.Tx) *DHTKeeper

NewDHTKeyKeeper creates an instance of DHTKeeper

func (*DHTKeeper) AddToAnnounceList

func (d *DHTKeeper) AddToAnnounceList(key []byte, repo string, objType int, announceTime int64) error

AddToAnnounceList adds a key that will be announced at a later time. key is the unique object key. objType is the object type. announceTime is the unix time when the key should be announced.

func (*DHTKeeper) IterateAnnounceList

func (d *DHTKeeper) IterateAnnounceList(it func(key []byte, entry *core.AnnounceListEntry))

IterateAnnounceList iterates over all announcements entries, passing each of them to the provided callback function. Entries with the closest announcement time are returned first.

func (*DHTKeeper) RemoveFromAnnounceList

func (d *DHTKeeper) RemoveFromAnnounceList(key []byte) error

RemoveFromAnnounceList removes a scheduled key announcement

type NamespaceKeeper

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

NamespaceKeeper manages namespaces.

func NewNamespaceKeeper

func NewNamespaceKeeper(state *tree.SafeTree) *NamespaceKeeper

NewNamespaceKeeper creates an instance of NamespaceKeeper

func (*NamespaceKeeper) Get

func (a *NamespaceKeeper) Get(name string, blockNum ...uint64) *state.Namespace

Get finds a namespace by name.

ARGS:
- name: The name of the namespace to find.
- blockNum: The target block to query (Optional. Default: latest)
CONTRACT: It returns an empty Namespace if no matching namespace is found.

func (*NamespaceKeeper) GetTarget

func (a *NamespaceKeeper) GetTarget(path string, blockNum ...uint64) (string, error)

GetTarget looks up the target of a full namespace path

ARGS:
- path: The path to look up.
- blockNum: The target block to query (Optional. Default: latest)

func (*NamespaceKeeper) Update

func (a *NamespaceKeeper) Update(name string, upd *state.Namespace)

Update sets a new object at the given name.

ARGS:
- name: The name of the namespace to update
- udp: The updated namespace object to replace the existing object.

type PushKeyKeeper

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

PushKeyKeeper manages push public keys.

func NewPushKeyKeeper

func NewPushKeyKeeper(state *tree.SafeTree, db storagetypes.Tx) *PushKeyKeeper

NewPushKeyKeeper creates an instance of PushKeyKeeper

func (*PushKeyKeeper) Get

func (g *PushKeyKeeper) Get(pushKeyID string, blockNum ...uint64) *state.PushKey

Get finds and returns a push key

ARGS: pushKeyID: The unique ID of the public key blockNum: The target block to query (Optional. Default: latest)

CONTRACT: It returns an empty Account if the key is not found.

func (*PushKeyKeeper) GetByAddress

func (g *PushKeyKeeper) GetByAddress(address string) []string

GetByAddress returns all public keys associated with the given address

ARGS: address: The target address

func (*PushKeyKeeper) Remove

func (g *PushKeyKeeper) Remove(pushKeyID string) bool

Remove removes a push key by its id

ARGS: pushKeyID: The public key unique ID

func (*PushKeyKeeper) Update

func (g *PushKeyKeeper) Update(pushKeyID string, upd *state.PushKey) error

Update sets a new value for the given public key id. It also adds an address->pubID index search for public keys by address.

ARGS: pushKeyID: The public key unique ID udp: The updated object to replace the existing object.

type RepoKeeper

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

RepoKeeper manages repository state.

func NewRepoKeeper

func NewRepoKeeper(state *tree.SafeTree, db storagetypes.Tx) *RepoKeeper

NewRepoKeeper creates an instance of RepoKeeper

func (*RepoKeeper) Get

func (a *RepoKeeper) Get(name string, blockNum ...uint64) *state.Repository

Get finds a repository by name.

It will populate the proposals in the repo with their correct config source from the version the repo that they where first appeared in.

ARGS: name: The name of the repository to find. blockNum: The target block to query (Optional. Default: latest)

CONTRACT: It returns an empty Repository if no repo is found.

func (*RepoKeeper) GetNoPopulate

func (a *RepoKeeper) GetNoPopulate(name string, blockNum ...uint64) *state.Repository

GetNoPopulate fetches a repository by the given name without making additional queries to populate the repo with associated objects.

ARGS: name: The name of the repository to find. blockNum: The target block to query (Optional. Default: latest)

CONTRACT: It returns an empty Repository if no repo is found.

func (*RepoKeeper) GetProposalVote

func (a *RepoKeeper) GetProposalVote(
	name, propID,
	voterAddr string) (vote int, found bool, err error)

GetProposalVote returns the vote choice of the given voter for the given proposal

ARGS: name: The name of the repository propID: The target proposal voterAddr: The address of the voter

func (*RepoKeeper) GetProposalsEndingAt

func (a *RepoKeeper) GetProposalsEndingAt(height uint64) []*core.EndingProposals

GetProposalsEndingAt finds repo proposals ending at the given height

ARGS: height: The chain height when the proposal will stop accepting votes.

func (*RepoKeeper) IndexProposalEnd

func (a *RepoKeeper) IndexProposalEnd(name, propID string, endHeight uint64) error

IndexProposalEnd indexes a proposal by its end height so it can be tracked and finalized at the given height

ARGS: name: The name of the repository propID: The target proposal endHeight: The chain height when the proposal will stop accepting votes.

func (*RepoKeeper) IndexProposalVote

func (a *RepoKeeper) IndexProposalVote(name, propID, voterAddr string, vote int) error

IndexProposalVote indexes a proposal vote.

ARGS: name: The name of the repository propID: The target proposal voterAddr: The address of the voter vote: Indicates the vote choice

func (*RepoKeeper) IsProposalClosed

func (a *RepoKeeper) IsProposalClosed(name, propID string) (bool, error)

IsProposalClosed checks whether a proposal has been marked "closed"

ARGS: name: The name of the repository propID: The target proposal

func (*RepoKeeper) MarkProposalAsClosed

func (a *RepoKeeper) MarkProposalAsClosed(name, propID string) error

MarkProposalAsClosed makes a proposal as "closed"

ARGS: name: The name of the repository propID: The target proposal

func (*RepoKeeper) Update

func (a *RepoKeeper) Update(name string, upd *state.Repository)

Update sets a new object at the given name.

ARGS: name: The name of the repository to update udp: The updated repository object to replace the existing object.

type RepoSyncInfoKeeper

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

RepoSyncInfoKeeper manages information about repositories that are being tracked.

func NewRepoSyncInfoKeeper

func NewRepoSyncInfoKeeper(db storagetypes.Tx, state *tree.SafeTree) *RepoSyncInfoKeeper

NewRepoSyncInfoKeeper creates an instance of RepoSyncInfoKeeper

func (*RepoSyncInfoKeeper) GetRefLastSyncHeight

func (t *RepoSyncInfoKeeper) GetRefLastSyncHeight(repo, ref string) (uint64, error)

GetLastSyncedNonce returns the last synchronized height of the given repo's reference

func (*RepoSyncInfoKeeper) GetTracked

func (t *RepoSyncInfoKeeper) GetTracked(name string) *core.TrackedRepo

GetTracked returns a repo.

Returns nil if not found

func (*RepoSyncInfoKeeper) Track

func (t *RepoSyncInfoKeeper) Track(targets string, height ...uint64) error

Add adds repositories to the track list.

Target can be one or more comma-separated list of repositories or user namespaces.

If a user namespace is provided, all repository targets are added.

If height is provided, it will be used as the last update height.

If will not re-add an already repo

func (*RepoSyncInfoKeeper) Tracked

func (t *RepoSyncInfoKeeper) Tracked() (res map[string]*core.TrackedRepo)

Tracked returns a map of repositories.

func (*RepoSyncInfoKeeper) UnTrack

func (t *RepoSyncInfoKeeper) UnTrack(targets string) error

Remove removes repositories from the track list.

Target can be one or more comma-separated list of repositories or user namespaces.

If a user namespace is provided, all repository targets are removed.

func (*RepoSyncInfoKeeper) UpdateRefLastSyncHeight

func (t *RepoSyncInfoKeeper) UpdateRefLastSyncHeight(repo, ref string, height uint64) error

SetLastSyncedNonce sets the last synchronized height of repo's reference.

type SystemKeeper

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

SystemKeeper stores system information such as app states, commit history and more.

func NewSystemKeeper

func NewSystemKeeper(db storagetypes.Tx) *SystemKeeper

NewSystemKeeper creates an instance of SystemKeeper

func (*SystemKeeper) GetBlockInfo

func (s *SystemKeeper) GetBlockInfo(height int64) (*state.BlockInfo, error)

GetBlockInfo returns block information at a given height

func (*SystemKeeper) GetHelmRepo

func (s *SystemKeeper) GetHelmRepo() (string, error)

GetHelmRepo gets the governing repository of the network

func (*SystemKeeper) GetLastBlockInfo

func (s *SystemKeeper) GetLastBlockInfo() (*state.BlockInfo, error)

GetLastBlockInfo returns information about the last committed block.

func (*SystemKeeper) SaveBlockInfo

func (s *SystemKeeper) SaveBlockInfo(info *state.BlockInfo) error

SaveBlockInfo saves a committed block information. Indexes the saved block info for faster future retrieval so that GetLastBlockInfo will not refetch

func (*SystemKeeper) SetHelmRepo

func (s *SystemKeeper) SetHelmRepo(name string) error

SetHelmRepo sets the governing repository of the network

type ValidatorKeeper

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

ValidatorKeeper manages information about validators

func NewValidatorKeeper

func NewValidatorKeeper(db storagetypes.Tx) *ValidatorKeeper

NewValidatorKeeper creates an instance of ValidatorKeeper

func (*ValidatorKeeper) Get

func (v *ValidatorKeeper) Get(height int64) (core.BlockValidators, error)

GetByHeight gets validators at the given height. If height is <= 0, the validator set of the highest height is returned.

func (*ValidatorKeeper) Index

func (v *ValidatorKeeper) Index(height int64, validators []*core.Validator) error

Index adds a set of validators associated to the given height

Jump to

Keyboard shortcuts

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