keeper

package
v0.0.0-...-c736a29 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2021 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ListRecordsPath        = "list"
	GetRecordPath          = "get"
	QueryRecordsByBondPath = "query-by-bond"
	QueryParametersPath    = "parameters"
	Balance                = "balance"

	WhoIsPath       = "whois"
	LookUpWRNPath   = "lookup"
	ListNamesPath   = "names"
	ResolveNamePath = "resolve"

	RecordExpiryQueue    = "record-expiry"
	AuthorityExpiryQueue = "authority-expiry"
)

query endpoints supported by the nameservice Querier

View Source
const NoExpiry = time.Hour * 24 * 365 * 100

NoExpiry => really long duration (used to indicate no-expiry).

Variables

View Source
var KeySyncStatus = []byte{0xff}

KeySyncStatus is the key for the sync status record. Only used by WNS lite but defined here to prevent conflicts with existing prefixes.

View Source
var PrefixAuctionToAuthorityNameIndex = []byte{0x05}

PrefixAuctionToAuthorityNameIndex is the prefix for the auction ID -> authority name index.

View Source
var PrefixBlockChangesetIndex = []byte{0x04}

PrefixBlockChangesetIndex is the prefix for the block changeset index.

View Source
var PrefixBondIDToAuthoritiesIndex = []byte{0x06}

PrefixBondIDToAuthoritiesIndex is the prefix for the Bond ID -> [Authority] index.

View Source
var PrefixBondIDToRecordsIndex = []byte{0x03}

PrefixBondIDToRecordsIndex is the prefix for the Bond ID -> [Record] index.

View Source
var PrefixCIDToNamesIndex = []byte{0xe0}

PrefixCIDToNamesIndex the the reverse index for naming, i.e. maps CID -> []Names. TODO(ashwin): Move out of WNS once we have an indexing service.

View Source
var PrefixCIDToRecordIndex = []byte{0x00}

PrefixCIDToRecordIndex is the prefix for CID -> Record index. Note: This is the primary index in the system. Note: Golang doesn't support const arrays.

View Source
var PrefixExpiryTimeToAuthoritiesIndex = []byte{0x11}

PrefixExpiryTimeToAuthoritiesIndex is the prefix for the Expiry Time -> [Authority] index.

View Source
var PrefixExpiryTimeToRecordsIndex = []byte{0x10}

PrefixExpiryTimeToRecordsIndex is the prefix for the Expiry Time -> [Record] index.

View Source
var PrefixNameAuthorityRecordIndex = []byte{0x01}

PrefixNameAuthorityRecordIndex is the prefix for the name -> NameAuthority index.

View Source
var PrefixWRNToNameRecordIndex = []byte{0x02}

PrefixWRNToNameRecordIndex is the prefix for the WRN -> NamingRecord index.

Functions

func AddRecordToNameMapping

func AddRecordToNameMapping(store sdk.KVStore, codec *amino.Codec, id types.ID, wrn string)

AddRecordToNameMapping adds a name to the record ID -> []names index.

func AllInvariants

func AllInvariants(k Keeper) sdk.Invariant

AllInvariants runs all invariants of the nameservice module.

func GetAuctionToAuthorityIndexKey

func GetAuctionToAuthorityIndexKey(auctionID auction.ID) []byte

func GetBlockChangesetIndexKey

func GetBlockChangesetIndexKey(height int64) []byte

func GetCIDToNamesIndexKey

func GetCIDToNamesIndexKey(id types.ID) []byte

func GetNameAuthority

func GetNameAuthority(store sdk.KVStore, codec *amino.Codec, name string) *types.NameAuthority

GetNameAuthority - gets a name authority from the store.

func GetNameAuthorityIndexKey

func GetNameAuthorityIndexKey(name string) []byte

Generates name -> NameAuthority index key.

func GetNameRecord

func GetNameRecord(store sdk.KVStore, codec *amino.Codec, wrn string) *types.NameRecord

GetNameRecord - gets a name record from the store.

func GetNameRecordIndexKey

func GetNameRecordIndexKey(wrn string) []byte

Generates WRN -> NameRecord index key.

func GetRecord

func GetRecord(store sdk.KVStore, codec *amino.Codec, id types.ID) types.Record

GetRecord - gets a record from the store.

func GetRecordIndexKey

func GetRecordIndexKey(id types.ID) []byte

Generates Bond ID -> Bond index key.

func HasNameAuthority

func HasNameAuthority(store sdk.KVStore, name string) bool

HasNameAuthority - checks if a name authority entry exists.

func HasRecord

func HasRecord(store sdk.KVStore, id types.ID) bool

HasRecord - checks if a record by the given ID exists.

func MatchRecords

func MatchRecords(store sdk.KVStore, codec *amino.Codec, matchFn func(*types.Record) bool) []*types.Record

MatchRecords - get all matching records.

func ModuleAccountInvariant

func ModuleAccountInvariant(k Keeper) sdk.Invariant

ModuleAccountInvariant checks that the 'bond' module account balance is non-negative.

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier is the module level router for state queries

func RecordInvariants

func RecordInvariants(k Keeper) sdk.Invariant

RecordInvariants checks that every record: (1) has a corresponding naming record & (2) associated bond exists, if bondID is not null.

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)

RegisterInvariants registers all nameservice module invariants.

func RemoveBondToAuthorityIndexEntry

func RemoveBondToAuthorityIndexEntry(store sdk.KVStore, bondID bond.ID, name string)

func RemoveRecordToNameMapping

func RemoveRecordToNameMapping(store sdk.KVStore, codec *amino.Codec, id types.ID, wrn string)

RemoveRecordToNameMapping removes a name from the record ID -> []names index.

func ResolveWRN

func ResolveWRN(store sdk.KVStore, codec *amino.Codec, wrn string) (*types.Record, *types.NameRecord)

ResolveWRN resolves a WRN to a record.

func SetNameAuthority

func SetNameAuthority(ctx sdk.Context, store sdk.KVStore, codec *amino.Codec, name string, authority types.NameAuthority)

func SetNameRecord

func SetNameRecord(store sdk.KVStore, codec *amino.Codec, wrn string, id types.ID, height int64)

SetNameRecord - sets a name record.

Types

type Keeper

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

Keeper maintains the link to storage and exposes getter/setter methods for the various parts of the state machine

func NewKeeper

func NewKeeper(accountKeeper auth.AccountKeeper, supplyKeeper supply.Keeper, recordKeeper RecordKeeper, bondKeeper bond.BondClientKeeper, auctionKeeper auction.Keeper, storeKey sdk.StoreKey, cdc *codec.Codec, paramstore params.Subspace) Keeper

NewKeeper creates new instances of the nameservice Keeper

func (Keeper) AddAuctionToAuthorityMapping

func (k Keeper) AddAuctionToAuthorityMapping(ctx sdk.Context, auctionID auction.ID, name string)

func (Keeper) AddBondToAuthorityIndexEntry

func (k Keeper) AddBondToAuthorityIndexEntry(ctx sdk.Context, bondID bond.ID, name string)

AddBondToAuthorityIndexEntry adds the Bond ID -> [Authority] index entry.

func (Keeper) AddBondToRecordIndexEntry

func (k Keeper) AddBondToRecordIndexEntry(ctx sdk.Context, bondID bond.ID, id types.ID)

AddBondToRecordIndexEntry adds the Bond ID -> [Record] index entry.

func (Keeper) AuthorityExpiryQueueIterator

func (k Keeper) AuthorityExpiryQueueIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator

AuthorityExpiryQueueIterator returns all the authority expiry queue timeslices from time 0 until endTime.

func (Keeper) DeleteAuthorityExpiryQueue

func (k Keeper) DeleteAuthorityExpiryQueue(ctx sdk.Context, name string, authority types.NameAuthority)

DeleteAuthorityExpiryQueue deletes an authority name from the authority expiry queue.

func (Keeper) DeleteAuthorityExpiryQueueTimeSlice

func (k Keeper) DeleteAuthorityExpiryQueueTimeSlice(ctx sdk.Context, timestamp time.Time)

DeleteAuthorityExpiryQueueTimeSlice deletes a specific authority expiry queue timeslice.

func (Keeper) DeleteRecordExpiryQueue

func (k Keeper) DeleteRecordExpiryQueue(ctx sdk.Context, record types.Record)

DeleteRecordExpiryQueue deletes a record CID from the record expiry queue.

func (Keeper) DeleteRecordExpiryQueueTimeSlice

func (k Keeper) DeleteRecordExpiryQueueTimeSlice(ctx sdk.Context, timestamp time.Time)

DeleteRecordExpiryQueueTimeSlice deletes a specific record expiry queue timeslice.

func (Keeper) GetAllExpiredAuthorities

func (k Keeper) GetAllExpiredAuthorities(ctx sdk.Context, currTime time.Time) (expiredAuthorityNames []string)

GetAllExpiredAuthorities returns a concatenated list of all the timeslices before currTime.

func (Keeper) GetAllExpiredRecords

func (k Keeper) GetAllExpiredRecords(ctx sdk.Context, currTime time.Time) (expiredRecordCIDs []types.ID)

GetAllExpiredRecords returns a concatenated list of all the timeslices before currTime.

func (Keeper) GetAuthorityExpiryQueue

func (k Keeper) GetAuthorityExpiryQueue(ctx sdk.Context) (expired map[string][]string)

func (Keeper) GetAuthorityExpiryQueueTimeSlice

func (k Keeper) GetAuthorityExpiryQueueTimeSlice(ctx sdk.Context, timestamp time.Time) (names []string)

func (Keeper) GetModuleBalances

func (k Keeper) GetModuleBalances(ctx sdk.Context) map[string]sdk.Coins

GetModuleBalances gets the nameservice module account(s) balances.

func (Keeper) GetNameAuthority

func (k Keeper) GetNameAuthority(ctx sdk.Context, name string) *types.NameAuthority

GetNameAuthority - gets a name authority from the store.

func (Keeper) GetNameRecord

func (k Keeper) GetNameRecord(ctx sdk.Context, wrn string) *types.NameRecord

GetNameRecord - gets a name record from the store.

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)

GetParams - Get all parameteras as types.Params.

func (Keeper) GetRecord

func (k Keeper) GetRecord(ctx sdk.Context, id types.ID) types.Record

GetRecord - gets a record from the store.

func (Keeper) GetRecordExpiryQueue

func (k Keeper) GetRecordExpiryQueue(ctx sdk.Context) (expired map[string][]types.ID)

func (Keeper) GetRecordExpiryQueueTimeSlice

func (k Keeper) GetRecordExpiryQueueTimeSlice(ctx sdk.Context, timestamp time.Time) (cids []types.ID)

GetRecordExpiryQueueTimeSlice gets a specific record queue timeslice. A timeslice is a slice of CIDs corresponding to records that expire at a certain time.

func (Keeper) HasNameAuthority

func (k Keeper) HasNameAuthority(ctx sdk.Context, name string) bool

HasNameAuthority - checks if a name/authority exists.

func (Keeper) HasNameRecord

func (k Keeper) HasNameRecord(ctx sdk.Context, wrn string) bool

HasNameRecord - checks if a name record exists.

func (Keeper) HasRecord

func (k Keeper) HasRecord(ctx sdk.Context, id types.ID) bool

HasRecord - checks if a record by the given ID exists.

func (Keeper) InsertAuthorityExpiryQueue

func (k Keeper) InsertAuthorityExpiryQueue(ctx sdk.Context, name string, expiryTime time.Time)

func (Keeper) InsertRecordExpiryQueue

func (k Keeper) InsertRecordExpiryQueue(ctx sdk.Context, val types.Record)

InsertRecordExpiryQueue inserts a record CID to the appropriate timeslice in the record expiry queue.

func (Keeper) ListNameAuthorityRecords

func (k Keeper) ListNameAuthorityRecords(ctx sdk.Context) map[string]types.NameAuthority

ListNameAuthorityRecords - get all name authority records.

func (Keeper) ListNameRecords

func (k Keeper) ListNameRecords(ctx sdk.Context) map[string]types.NameRecord

ListNameRecords - get all name records.

func (Keeper) ListRecords

func (k Keeper) ListRecords(ctx sdk.Context) []types.Record

ListRecords - get all records.

func (Keeper) MatchRecords

func (k Keeper) MatchRecords(ctx sdk.Context, matchFn func(*types.Record) bool) []*types.Record

MatchRecords - get all matching records.

func (Keeper) ProcessAssociateBond

func (k Keeper) ProcessAssociateBond(ctx sdk.Context, msg types.MsgAssociateBond) (*types.Record, error)

ProcessAssociateBond associates a record with a bond.

func (Keeper) ProcessAuthorityExpiryQueue

func (k Keeper) ProcessAuthorityExpiryQueue(ctx sdk.Context)

ProcessAuthorityExpiryQueue tries to renew expiring authorities (by collecting rent) else marks them as expired.

func (Keeper) ProcessDeleteName

func (k Keeper) ProcessDeleteName(ctx sdk.Context, msg types.MsgDeleteName) error

ProcessDeleteName removes a WRN -> Record ID mapping.

func (Keeper) ProcessDissociateBond

func (k Keeper) ProcessDissociateBond(ctx sdk.Context, msg types.MsgDissociateBond) (*types.Record, error)

ProcessDissociateBond dissociates a record from its bond.

func (Keeper) ProcessDissociateRecords

func (k Keeper) ProcessDissociateRecords(ctx sdk.Context, msg types.MsgDissociateRecords) (*bond.Bond, error)

ProcessDissociateRecords dissociates all records associated with a given bond.

func (Keeper) ProcessReassociateRecords

func (k Keeper) ProcessReassociateRecords(ctx sdk.Context, msg types.MsgReassociateRecords) (*bond.Bond, error)

ProcessReassociateRecords switches records from and old to new bond.

func (Keeper) ProcessRecordExpiryQueue

func (k Keeper) ProcessRecordExpiryQueue(ctx sdk.Context)

ProcessRecordExpiryQueue tries to renew expiring records (by collecting rent) else marks them as deleted.

func (Keeper) ProcessRenewRecord

func (k Keeper) ProcessRenewRecord(ctx sdk.Context, msg types.MsgRenewRecord) (*types.Record, error)

ProcessRenewRecord renews a record.

func (Keeper) ProcessReserveAuthority

func (k Keeper) ProcessReserveAuthority(ctx sdk.Context, msg types.MsgReserveAuthority) (string, error)

ProcessReserveAuthority reserves a name authority.

func (Keeper) ProcessReserveSubAuthority

func (k Keeper) ProcessReserveSubAuthority(ctx sdk.Context, name string, msg types.MsgReserveAuthority) (string, error)

ProcessReserveSubAuthority reserves a sub-authority.

func (Keeper) ProcessSetAuthorityBond

func (k Keeper) ProcessSetAuthorityBond(ctx sdk.Context, msg types.MsgSetAuthorityBond) (string, error)

ProcessSetAuthorityBond sets a bond on an authority.

func (Keeper) ProcessSetName

func (k Keeper) ProcessSetName(ctx sdk.Context, msg types.MsgSetName) error

ProcessSetName creates a WRN -> Record ID mapping.

func (Keeper) ProcessSetRecord

func (k Keeper) ProcessSetRecord(ctx sdk.Context, msg types.MsgSetRecord) (*types.Record, error)

ProcessSetRecord creates a record.

func (Keeper) PutRecord

func (k Keeper) PutRecord(ctx sdk.Context, record types.Record)

PutRecord - saves a record to the store and updates ID -> Record index.

func (Keeper) RecordExpiryQueueIterator

func (k Keeper) RecordExpiryQueueIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator

RecordExpiryQueueIterator returns all the record expiry queue timeslices from time 0 until endTime.

func (Keeper) RemoveAuctionToAuthorityMapping

func (k Keeper) RemoveAuctionToAuthorityMapping(ctx sdk.Context, auctionID auction.ID)

func (Keeper) RemoveBondToAuthorityIndexEntry

func (k Keeper) RemoveBondToAuthorityIndexEntry(ctx sdk.Context, bondID bond.ID, name string)

RemoveBondToAuthorityIndexEntry removes the Bond ID -> [Authority] index entry.

func (Keeper) RemoveBondToRecordIndexEntry

func (k Keeper) RemoveBondToRecordIndexEntry(ctx sdk.Context, bondID bond.ID, id types.ID)

RemoveBondToRecordIndexEntry removes the Bond ID -> [Record] index entry.

func (Keeper) ResolveWRN

func (k Keeper) ResolveWRN(ctx sdk.Context, wrn string) *types.Record

ResolveWRN resolves a WRN to a record.

func (Keeper) SetAuthorityExpiryQueueTimeSlice

func (k Keeper) SetAuthorityExpiryQueueTimeSlice(ctx sdk.Context, timestamp time.Time, names []string)

func (Keeper) SetNameAuthority

func (k Keeper) SetNameAuthority(ctx sdk.Context, name string, authority types.NameAuthority)

SetNameAuthority creates the NameAutority record.

func (Keeper) SetNameRecord

func (k Keeper) SetNameRecord(ctx sdk.Context, wrn string, id types.ID)

SetNameRecord - sets a name record.

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params types.Params)

SetParams - set the params.

func (Keeper) SetRecordExpiryQueueTimeSlice

func (k Keeper) SetRecordExpiryQueueTimeSlice(ctx sdk.Context, timestamp time.Time, cids []types.ID)

SetRecordExpiryQueueTimeSlice sets a specific record expiry queue timeslice.

func (Keeper) TryTakeAuthorityRent

func (k Keeper) TryTakeAuthorityRent(ctx sdk.Context, name string, authority types.NameAuthority)

TryTakeAuthorityRent tries to take rent from the authority bond.

func (Keeper) TryTakeRecordRent

func (k Keeper) TryTakeRecordRent(ctx sdk.Context, record types.Record)

TryTakeRecordRent tries to take rent from the record bond.

type RecordKeeper

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

RecordKeeper exposes the bare minimal read-only API for other modules.

func NewRecordKeeper

func NewRecordKeeper(auctionKeeper auction.Keeper, storeKey sdk.StoreKey, cdc *codec.Codec) RecordKeeper

NewRecordKeeper creates new instances of the nameservice RecordKeeper

func (RecordKeeper) GetAuctionToAuthorityMapping

func (k RecordKeeper) GetAuctionToAuthorityMapping(ctx sdk.Context, auctionID auction.ID) string

func (RecordKeeper) ModuleName

func (k RecordKeeper) ModuleName() string

ModuleName returns the module name.

func (RecordKeeper) OnAuction

func (k RecordKeeper) OnAuction(ctx sdk.Context, auctionID auction.ID)

func (RecordKeeper) OnAuctionBid

func (k RecordKeeper) OnAuctionBid(ctx sdk.Context, auctionID auction.ID, bidderAddress string)

func (RecordKeeper) OnAuctionWinnerSelected

func (k RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionID auction.ID)

OnAuctionWinnerSelected is called when an auction winner is selected.

func (RecordKeeper) QueryRecordsByBond

func (k RecordKeeper) QueryRecordsByBond(ctx sdk.Context, bondID bond.ID) []types.Record

QueryRecordsByBond - get all records for the given bond.

func (RecordKeeper) UsesAuction

func (k RecordKeeper) UsesAuction(ctx sdk.Context, auctionID auction.ID) bool

UsesAuction returns true if the auction is used for an name authority.

func (RecordKeeper) UsesBond

func (k RecordKeeper) UsesBond(ctx sdk.Context, bondID bond.ID) bool

UsesBond returns true if the bond has associated records.

Jump to

Keyboard shortcuts

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