protocol

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParamsModuleName       = "params"
	SupplyModuleName       = "supply"
	StakingModuleName      = "staking"
	MintModuleName         = "mint"
	DistributionModuleName = "distribution"
	SlashingModuleName     = "slashing"
	GovModuleName          = "gov"
	AuthModuleName         = "auth"
	UpgradeModuleName      = "upgrade"
	GuardianModuleName     = "guardian"
	VMModuleName           = "vm"
)

all modules

View Source
const (
	MainStoreKey = "main"

	ParamsStoreKey       = ParamsModuleName
	SupplyStoreKey       = SupplyModuleName
	StakingStoreKey      = StakingModuleName
	MintStoreKey         = MintModuleName
	DistributionStoreKey = DistributionModuleName
	SlashingStoreKey     = SlashingModuleName
	GovStoreKey          = GovModuleName
	AuthStoreKey         = AuthModuleName
	UpgradeStoreKey      = UpgradeModuleName
	GuardianStoreKey     = GuardianModuleName
	VMStoreKey           = VMModuleName

	ParamsTStoreKey  = "transient_" + ParamsStoreKey
	StakingTStoreKey = "transient_" + StakingStoreKey
)

all store keys name

Variables

all store keys

Functions

func NewQueryRouter

func NewQueryRouter() sdk.QueryRouter

NewQueryRouter return QueryRouter

Types

type MockProtocol

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

MockProtocol is designed for engine test

func NewMockProtocol

func NewMockProtocol(version uint64) *MockProtocol

NewMockProtocol creates a new instance of MockProtocol

func (*MockProtocol) ExportAppStateAndValidators

func (m *MockProtocol) ExportAppStateAndValidators(ctx sdk.Context, forZeroHeight bool, jailWhiteList []string) (appState json.RawMessage, validators []types.GenesisValidator, err error)

ExportAppStateAndValidators exports the application state for a genesis file

func (MockProtocol) GetAnteHandler

func (m MockProtocol) GetAnteHandler() sdk.AnteHandler

GetAnteHandler gets ante handler

func (MockProtocol) GetBeginBlocker

func (m MockProtocol) GetBeginBlocker() sdk.BeginBlocker

GetBeginBlocker gets beginBlocker

func (*MockProtocol) GetCodec

func (m *MockProtocol) GetCodec() *codec.Codec

GetCodec gets codec

func (MockProtocol) GetEndBlocker

func (m MockProtocol) GetEndBlocker() sdk.EndBlocker

GetEndBlocker gets endBlocker

func (*MockProtocol) GetFeeRefundHandler

func (m *MockProtocol) GetFeeRefundHandler() sdk.FeeRefundHandler

GetFeeRefundHandler gets fee refund handler

func (*MockProtocol) GetInitChainer

func (m *MockProtocol) GetInitChainer() sdk.InitChainer

GetInitChainer get initChainer

func (*MockProtocol) GetQueryRouter

func (m *MockProtocol) GetQueryRouter() sdk.QueryRouter

GetQueryRouter gets query router

func (*MockProtocol) GetRouter

func (m *MockProtocol) GetRouter() sdk.Router

GetRouter gets router

func (*MockProtocol) GetSimulationManager

func (m *MockProtocol) GetSimulationManager() interface{}

GetSimulationManager - for simulation

func (*MockProtocol) GetVersion

func (m *MockProtocol) GetVersion() uint64

GetVersion gets version

func (*MockProtocol) Init

func (m *MockProtocol) Init()

Init - initialize

func (*MockProtocol) LoadContext

func (m *MockProtocol) LoadContext()

LoadContext - do nothing

func (*MockProtocol) SetAnteHandler

func (m *MockProtocol) SetAnteHandler(anteHandler sdk.AnteHandler)

SetAnteHandler set the anteHandler

func (*MockProtocol) SetInitChainer

func (m *MockProtocol) SetInitChainer(initChainer sdk.InitChainer)

SetInitChainer set the initChainer

func (*MockProtocol) SetQueryRouter

func (m *MockProtocol) SetQueryRouter(queryRouter sdk.QueryRouter)

SetQueryRouter allows us to customize the query router

func (*MockProtocol) SetRouter

func (m *MockProtocol) SetRouter(router sdk.Router)

SetRouter allows us to customize the router

type Protocol

type Protocol interface {
	GetVersion() uint64
	GetRouter() sdk.Router
	GetQueryRouter() sdk.QueryRouter
	GetAnteHandler() sdk.AnteHandler
	GetFeeRefundHandler() sdk.FeeRefundHandler
	GetInitChainer() sdk.InitChainer
	GetBeginBlocker() sdk.BeginBlocker
	GetEndBlocker() sdk.EndBlocker

	ExportAppStateAndValidators(ctx sdk.Context, forZeroHeight bool, jailWhiteList []string) (appState json.RawMessage, validators []tmtypes.GenesisValidator, err error)

	LoadContext()
	Init()
	GetCodec() *codec.Codec

	//for test
	SetRouter(sdk.Router)
	SetQueryRouter(sdk.QueryRouter)
	SetAnteHandler(anteHandler sdk.AnteHandler)
	SetInitChainer(sdk.InitChainer)

	//for simulation
	GetSimulationManager() interface{}
}

Protocol shows the expected behavior for any protocol version

type ProtocolEngine

type ProtocolEngine struct {
	ProtocolKeeper sdk.ProtocolKeeper
	// contains filtered or unexported fields
}

ProtocolEngine protocol engine nolint

func NewProtocolEngine

func NewProtocolEngine(protocolKeeper sdk.ProtocolKeeper) ProtocolEngine

func (*ProtocolEngine) Activate

func (pe *ProtocolEngine) Activate(version uint64) bool

func (*ProtocolEngine) Add

func (pe *ProtocolEngine) Add(p Protocol) Protocol

func (*ProtocolEngine) GetByVersion

func (pe *ProtocolEngine) GetByVersion(v uint64) (Protocol, bool)

func (*ProtocolEngine) GetCurrentProtocol

func (pe *ProtocolEngine) GetCurrentProtocol() Protocol

func (*ProtocolEngine) GetCurrentVersion

func (pe *ProtocolEngine) GetCurrentVersion() uint64

func (*ProtocolEngine) GetProtocolKeeper

func (pe *ProtocolEngine) GetProtocolKeeper() sdk.ProtocolKeeper

GetProtocolKeeper gets protocol keeper from engine

func (*ProtocolEngine) GetUpgradeConfigByStore

func (pe *ProtocolEngine) GetUpgradeConfigByStore(store sdk.KVStore) (upgradeConfig sdk.UpgradeConfig,
	found bool)

GetUpgradeConfigByStore gets upgrade config from store

func (*ProtocolEngine) LoadCurrentProtocol

func (pe *ProtocolEngine) LoadCurrentProtocol(kvStore sdk.KVStore) (bool, uint64)

func (*ProtocolEngine) LoadProtocol

func (pe *ProtocolEngine) LoadProtocol(version uint64)

type Router

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

Router provides handlers for each transaction type

func NewRouter

func NewRouter() *Router

NewQueryRouter returns a reference to a new QueryRouter

func (*Router) AddRoute

func (rtr *Router) AddRoute(path string, h sdk.Handler) sdk.Router

AddRoute adds a query path to the router with a given Querier

func (*Router) Route

func (rtr *Router) Route(_ sdk.Context, path string) sdk.Handler

Route returns the Querier for a given query route path

Jump to

Keyboard shortcuts

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