From 3c9c797754376c2787d1e58c1f29ef62cca5a9d4 Mon Sep 17 00:00:00 2001 From: C H Date: Mon, 18 Sep 2023 11:40:04 +0800 Subject: [PATCH 1/7] format --- .golangci.yml | 0 Makefile | 13 +- app/ante.go | 26 ++-- app/app.go | 63 ++++---- app/encoding.go | 2 +- app/export.go | 6 +- app/prefix.go | 2 +- app/types.go | 1 - cmd/cyber/cmd/genaccounts.go | 25 ++- cmd/cyber/cmd/root.go | 20 +-- cmd/cyber/cmd/testnet.go | 16 +- cmd/iavltool/cmd/root.go | 31 ++-- cmd/iavltool/main.go | 2 +- merkle/proof.go | 1 - merkle/subtree.go | 1 - merkle/tree.go | 6 - merkle/tree_test.go | 8 +- merkle/util.go | 4 - plugins/liquidity_plugin/liquidity_plugin.go | 54 ++++--- plugins/msg_binding.go | 3 +- plugins/query_binding.go | 2 +- types/account.go | 1 - types/query/pagination.pb.go | 26 +++- utils/context.go | 4 +- utils/io.go | 7 +- x/bandwidth/abci.go | 4 +- x/bandwidth/client/cli/query.go | 14 +- x/bandwidth/client/rest/query.go | 5 - x/bandwidth/client/rest/rest.go | 1 - x/bandwidth/keeper/accounts.go | 2 +- x/bandwidth/keeper/blocks.go | 2 +- x/bandwidth/keeper/grpc_query.go | 4 +- x/bandwidth/keeper/keeper.go | 9 +- x/bandwidth/keeper/querier.go | 13 +- x/bandwidth/module.go | 14 +- x/bandwidth/types/account_bandwidth.go | 9 +- x/bandwidth/types/errors.go | 4 +- x/bandwidth/types/genesis.pb.go | 22 ++- x/bandwidth/types/keys.go | 8 +- x/bandwidth/types/params.go | 24 +-- x/bandwidth/types/querier.go | 12 +- x/bandwidth/types/query.pb.go | 103 ++++++++++--- x/bandwidth/types/query.pb.gw.go | 36 +---- x/bandwidth/types/types.pb.go | 37 ++++- x/bandwidth/wasm/interface.go | 19 ++- x/cyberbank/abci.go | 2 +- x/cyberbank/keeper/keeper.go | 23 ++- x/cyberbank/keeper/proxy.go | 9 +- x/cyberbank/module.go | 10 +- x/cyberbank/types/expected_keepers.go | 3 +- x/cyberbank/types/keys.go | 4 +- x/dmn/client/cli/query.go | 17 +- x/dmn/client/rest/query.go | 7 +- x/dmn/client/rest/rest.go | 6 +- x/dmn/keeper/genesis.go | 3 +- x/dmn/keeper/grpc_query.go | 2 +- x/dmn/keeper/keeper.go | 39 +++-- x/dmn/keeper/msg_server.go | 2 +- x/dmn/keeper/querier.go | 9 +- x/dmn/module.go | 11 +- x/dmn/types/errors.go | 2 +- x/dmn/types/events.go | 4 +- x/dmn/types/expected_keepers.go | 2 +- x/dmn/types/genesis.go | 2 +- x/dmn/types/genesis.pb.go | 22 ++- x/dmn/types/keys.go | 13 +- x/dmn/types/msgs.go | 44 +++--- x/dmn/types/params.go | 13 +- x/dmn/types/querier.go | 4 +- x/dmn/types/query.pb.go | 94 +++++++++-- x/dmn/types/query.pb.gw.go | 44 ++---- x/dmn/types/thought.go | 13 +- x/dmn/types/tx.pb.go | 154 +++++++++++++++---- x/dmn/types/types.pb.go | 49 +++++- x/dmn/wasm/interface.go | 39 +++-- x/graph/abci.go | 4 +- x/graph/client/cli/query.go | 4 +- x/graph/client/cli/tx.go | 6 +- x/graph/client/rest/query.go | 2 +- x/graph/client/rest/rest.go | 2 +- x/graph/keeper/genesis.go | 1 - x/graph/keeper/graph.go | 27 ++-- x/graph/keeper/grpc_query.go | 2 +- x/graph/keeper/index.go | 13 +- x/graph/keeper/msg_server.go | 22 ++- x/graph/keeper/neudeg.go | 9 +- x/graph/keeper/particles.go | 9 +- x/graph/keeper/querier.go | 3 +- x/graph/module.go | 34 ++-- x/graph/types/compact_link.go | 8 +- x/graph/types/cyberlinks.go | 15 +- x/graph/types/errors.go | 16 +- x/graph/types/events.go | 4 +- x/graph/types/keys.go | 26 ++-- x/graph/types/msgs.go | 15 +- x/graph/types/particles_filter.go | 2 - x/graph/types/querier.go | 4 +- x/graph/types/query.pb.go | 42 +++-- x/graph/types/query.pb.gw.go | 28 ++-- x/graph/types/tx.pb.go | 42 +++-- x/graph/types/types.pb.go | 22 ++- x/graph/wasm/interface.go | 13 +- x/grid/client/cli/query.go | 20 +-- x/grid/client/rest/query.go | 8 +- x/grid/keeper/genesis.go | 4 +- x/grid/keeper/grpc_query.go | 2 +- x/grid/keeper/keeper.go | 9 +- x/grid/keeper/querier.go | 15 +- x/grid/module.go | 7 +- x/grid/types/errors.go | 12 +- x/grid/types/events.go | 11 +- x/grid/types/expected_keepers.go | 3 +- x/grid/types/genesis.go | 4 +- x/grid/types/genesis.pb.go | 22 ++- x/grid/types/keys.go | 11 +- x/grid/types/msgs.go | 30 ++-- x/grid/types/params.go | 4 +- x/grid/types/querier.go | 21 ++- x/grid/types/query.pb.go | 90 +++++++++-- x/grid/types/query.pb.gw.go | 68 ++------ x/grid/types/route.go | 2 +- x/grid/types/tx.pb.go | 90 ++++++++--- x/grid/types/types.pb.go | 37 ++++- x/grid/wasm/interface.go | 35 +++-- x/rank/abci.go | 2 +- x/rank/client/cli/query.go | 24 +-- x/rank/client/rest/query.go | 3 - x/rank/client/rest/rest.go | 2 +- x/rank/keeper/calculate.go | 8 +- x/rank/keeper/calculate_cpu.go | 53 ++++--- x/rank/keeper/calculate_gpu.go | 23 +-- x/rank/keeper/calculate_gpu_nop.go | 1 + x/rank/keeper/genesis.go | 1 + x/rank/keeper/grpc_query.go | 30 ++-- x/rank/keeper/keeper.go | 61 ++++---- x/rank/keeper/querier.go | 69 +++++---- x/rank/module.go | 2 +- x/rank/types/context.go | 20 ++- x/rank/types/genesis.pb.go | 22 ++- x/rank/types/index.go | 27 ++-- x/rank/types/index_types.go | 6 +- x/rank/types/keys.go | 23 ++- x/rank/types/params.go | 8 +- x/rank/types/querier.go | 26 ++-- x/rank/types/query.pb.go | 144 +++++++++++++++-- x/rank/types/query.pb.gw.go | 79 ++-------- x/rank/types/rank.go | 77 +++++----- x/rank/types/types.pb.go | 31 +++- x/rank/wasm/interface.go | 11 +- x/resources/client/cli/query.go | 12 +- x/resources/client/cli/tx.go | 4 +- x/resources/client/rest/query.go | 6 +- x/resources/client/rest/rest.go | 2 +- x/resources/keeper/genesis.go | 1 + x/resources/keeper/grpc_query.go | 5 +- x/resources/keeper/keeper.go | 60 ++++---- x/resources/keeper/msg_server.go | 7 +- x/resources/keeper/querier.go | 8 +- x/resources/module.go | 11 +- x/resources/types/codec.go | 2 +- x/resources/types/errors.go | 18 +-- x/resources/types/events.go | 16 +- x/resources/types/expected_keepers.go | 2 +- x/resources/types/genesis.go | 2 +- x/resources/types/genesis.pb.go | 22 ++- x/resources/types/keys.go | 10 +- x/resources/types/msgs.go | 5 +- x/resources/types/params.go | 12 +- x/resources/types/querier.go | 6 +- x/resources/types/query.pb.go | 55 +++++-- x/resources/types/query.pb.gw.go | 28 ++-- x/resources/types/tx.pb.go | 42 +++-- x/resources/types/types.pb.go | 25 ++- x/resources/wasm/interface.go | 8 +- x/staking/module.go | 15 +- x/staking/msg_server.go | 42 +++-- 176 files changed, 2000 insertions(+), 1371 deletions(-) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..e69de29 diff --git a/Makefile b/Makefile index 960301b..180cc1f 100644 --- a/Makefile +++ b/Makefile @@ -101,6 +101,11 @@ run: ### Tools / Dependencies ### ############################################################################### +format-tools: + go install mvdan.cc/gofumpt@v0.4.0 + go install github.com/client9/misspell/cmd/misspell@v0.3.4 + go install golang.org/x/tools/cmd/goimports@latest + go-mod-cache: go.sum @echo "--> Download go modules to local cache" @go mod download @@ -123,10 +128,10 @@ statik: $(GO) generate ./api/... .PHONY: statik -format: - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*.pb.go" | xargs gofmt -w -s - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*.pb.go" | xargs misspell -w - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*.pb.go" | xargs goimports -w -local github.com/cybercongress/go-cyber +format: format-tools + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" | xargs gofumpt -w + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" | xargs misspell -w + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" | xargs goimports -w -local github.com/cybercongress/go-cyber .PHONY: format ############################################################################### diff --git a/app/ante.go b/app/ante.go index 3a7f561..7bff12b 100644 --- a/app/ante.go +++ b/app/ante.go @@ -2,6 +2,7 @@ package app import ( "fmt" + "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" @@ -15,13 +16,14 @@ import ( ctypes "github.com/cybercongress/go-cyber/types" + wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" ibcante "github.com/cosmos/ibc-go/v3/modules/core/ante" "github.com/cosmos/ibc-go/v3/modules/core/keeper" + bandwidthkeeper "github.com/cybercongress/go-cyber/x/bandwidth/keeper" bandwidthtypes "github.com/cybercongress/go-cyber/x/bandwidth/types" graphtypes "github.com/cybercongress/go-cyber/x/graph/types" - wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types" ) // HandlerOptions are the options required for constructing a default SDK AnteHandler. @@ -39,7 +41,7 @@ type HandlerBaseOptions struct { type HandlerOptions struct { HandlerBaseOptions - IBCKeeper *keeper.Keeper + IBCKeeper *keeper.Keeper WasmConfig *wasmTypes.WasmConfig TXCounterStoreKey sdk.StoreKey } @@ -64,7 +66,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "tx counter key is required for ante builder") } - var sigGasConsumer = options.SigGasConsumer + sigGasConsumer := options.SigGasConsumer if sigGasConsumer == nil { sigGasConsumer = ante.DefaultSigVerificationGasConsumer } @@ -94,11 +96,10 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { } type DeductFeeBandDecorator struct { - ak ante.AccountKeeper - bankKeeper bankkeeper.Keeper - bandMeter *bandwidthkeeper.BandwidthMeter - feegrantKeeper ante.FeegrantKeeper - + ak ante.AccountKeeper + bankKeeper bankkeeper.Keeper + bandMeter *bandwidthkeeper.BandwidthMeter + feegrantKeeper ante.FeegrantKeeper } func NewDeductFeeBandRouterDecorator( @@ -116,7 +117,6 @@ func NewDeductFeeBandRouterDecorator( } func (drd DeductFeeBandDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { - feeFlag := false feeSplitFlag := false bandwidthFlag := false @@ -168,7 +168,6 @@ func (drd DeductFeeBandDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "fee grants are not enabled") } else if !feeGranter.Equals(feePayer) { err := drd.feegrantKeeper.UseGrantedFees(ctx, feeGranter, feePayer, fee, tx.GetMsgs()) - if err != nil { return ctx, sdkerrors.Wrapf(err, "%s not allowed to pay fees from %s", feeGranter, feePayer) } @@ -223,11 +222,12 @@ func (drd DeductFeeBandDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat if !simulate { if !accountBandwidth.HasEnoughRemained(txCost) { return ctx, bandwidthtypes.ErrNotEnoughBandwidth - } else if (txCost + currentBlockSpentBandwidth) > maxBlockBandwidth { + } else if (txCost + currentBlockSpentBandwidth) > maxBlockBandwidth { return ctx, bandwidthtypes.ErrExceededMaxBlockBandwidth } else { if !ctx.IsCheckTx() && !ctx.IsReCheckTx() { - err = drd.bandMeter.ConsumeAccountBandwidth(ctx, accountBandwidth, txCost); if err != nil { + err = drd.bandMeter.ConsumeAccountBandwidth(ctx, accountBandwidth, txCost) + if err != nil { return ctx, err } // TODO think to add to transient store @@ -254,7 +254,7 @@ func DeductFees(bankKeeper bankkeeper.Keeper, ctx sdk.Context, acc authtypes.Acc } } else { feeInCYB := sdk.NewDec(fees.AmountOf(ctypes.CYB).Int64()) - toProgram := feeInCYB.Mul(sdk.NewDecWithPrec(80,2)) + toProgram := feeInCYB.Mul(sdk.NewDecWithPrec(80, 2)) toValidators := feeInCYB.Sub(toProgram) toValidatorsAmount := sdk.NewCoins(sdk.NewCoin(ctypes.CYB, toValidators.RoundInt())) diff --git a/app/app.go b/app/app.go index bbe12c0..6eea3d1 100644 --- a/app/app.go +++ b/app/app.go @@ -2,6 +2,13 @@ package app import ( "fmt" + "io" + "net/http" + "os" + "path/filepath" + "strings" + "time" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/cosmos/cosmos-sdk/x/authz" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" @@ -19,23 +26,19 @@ import ( porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types" ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host" ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper" + _ "github.com/cybercongress/go-cyber/client/docs/statik" "github.com/cybercongress/go-cyber/plugins/liquidity_plugin" - "io" - "net/http" - "os" - "path/filepath" - "strings" - "time" "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" - ctypes "github.com/cybercongress/go-cyber/types" "github.com/gorilla/mux" "github.com/rakyll/statik/fs" "github.com/tendermint/liquidity/x/liquidity" liquiditykeeper "github.com/tendermint/liquidity/x/liquidity/keeper" liquiditytypes "github.com/tendermint/liquidity/x/liquidity/types" + ctypes "github.com/cybercongress/go-cyber/types" + wasmplugins "github.com/cybercongress/go-cyber/plugins" "github.com/cybercongress/go-cyber/x/dmn" "github.com/cybercongress/go-cyber/x/resources" @@ -143,14 +146,15 @@ import ( resourcestypes "github.com/cybercongress/go-cyber/x/resources/types" stakingwrap "github.com/cybercongress/go-cyber/x/staking" - "github.com/cybercongress/go-cyber/app/params" tmjson "github.com/tendermint/tendermint/libs/json" + "github.com/cybercongress/go-cyber/app/params" + store "github.com/cosmos/cosmos-sdk/store/types" ) const ( - appName = "BostromHub" + appName = "BostromHub" upgradeName = "cyberfrey" ) @@ -168,7 +172,7 @@ var ( DefaultReDnmString = `[a-zA-Z][a-zA-Z0-9/\-\.]{2,127}` // If EnabledSpecificProposals is "", and this is "true", then enable all x/wasm proposals. - ProposalsEnabled = "true" + ProposalsEnabled = "true" EnableSpecificProposals = "" ) @@ -255,7 +259,7 @@ var ( resourcestypes.ResourcesName: {authtypes.Minter, authtypes.Burner}, } - // module accounts that are allowed to receive tokens + // module accounts that are allowed to receive tokens allowedReceivingModAcc = map[string]bool{ distrtypes.ModuleName: true, } @@ -307,14 +311,14 @@ type App struct { WasmKeeper wasm.Keeper LiquidityKeeper liquiditykeeper.Keeper - BandwidthMeter *bandwidthkeeper.BandwidthMeter - CyberbankKeeper *cyberbankkeeper.IndexedKeeper - GraphKeeper *graphkeeper.GraphKeeper - IndexKeeper *graphkeeper.IndexKeeper - RankKeeper *rankkeeper.StateKeeper - GridKeeper gridkeeper.Keeper - DmnKeeper *dmnkeeper.Keeper - ResourcesKeeper resourceskeeper.Keeper + BandwidthMeter *bandwidthkeeper.BandwidthMeter + CyberbankKeeper *cyberbankkeeper.IndexedKeeper + GraphKeeper *graphkeeper.GraphKeeper + IndexKeeper *graphkeeper.IndexKeeper + RankKeeper *rankkeeper.StateKeeper + GridKeeper gridkeeper.Keeper + DmnKeeper *dmnkeeper.Keeper + ResourcesKeeper resourceskeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -343,8 +347,8 @@ func NewApp( baseAppOptions ...func(*baseapp.BaseApp), ) *App { // TODO clean - //config := sdk.NewConfig() - //config.Seal() + // config := sdk.NewConfig() + // config.Seal() appCodec, legacyAmino := encodingConfig.Marshaler, encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry @@ -354,7 +358,7 @@ func NewApp( bApp.SetVersion(version.Version) bApp.SetInterfaceRegistry(interfaceRegistry) // TODO clean - //sdk.SetCoinDenomRegex(SdkCoinDenomRegex) + // sdk.SetCoinDenomRegex(SdkCoinDenomRegex) keys := sdk.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, @@ -699,7 +703,7 @@ func NewApp( // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment // we prefer to be more strict in what arguments the modules expect. - var skipGenesisInvariants = cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) + skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. @@ -880,9 +884,9 @@ func NewApp( SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), SigGasConsumer: ante.DefaultSigVerificationGasConsumer, }, - IBCKeeper: app.IBCKeeper, - WasmConfig: &wasmConfig, - TXCounterStoreKey: keys[wasm.StoreKey], + IBCKeeper: app.IBCKeeper, + WasmConfig: &wasmConfig, + TXCounterStoreKey: keys[wasm.StoreKey], }, ) if err != nil { @@ -898,9 +902,8 @@ func NewApp( app.UpgradeKeeper.SetUpgradeHandler( upgradeName, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - - //ctx.Logger().Info("start to init module...") - //ctx.Logger().Info("start to run module migrations...") + // ctx.Logger().Info("start to init module...") + // ctx.Logger().Info("start to run module migrations...") return app.mm.RunMigrations(ctx, app.configurator, fromVM) }, @@ -1165,4 +1168,4 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino func MakeCodecs() (codec.Codec, *codec.LegacyAmino) { config := MakeEncodingConfig() return config.Marshaler, config.Amino -} \ No newline at end of file +} diff --git a/app/encoding.go b/app/encoding.go index 8353c5e..999ef7f 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -3,6 +3,7 @@ package app import ( simappparams "github.com/cosmos/cosmos-sdk/simapp/params" "github.com/cosmos/cosmos-sdk/std" + "github.com/cybercongress/go-cyber/app/params" ) @@ -19,7 +20,6 @@ func MakeEncodingConfig() params.EncodingConfig { } func MakeTestEncodingConfig() simappparams.EncodingConfig { - encodingConfig := params.MakeEncodingConfig() std.RegisterLegacyAminoCodec(encodingConfig.Amino) std.RegisterInterfaces(encodingConfig.InterfaceRegistry) diff --git a/app/export.go b/app/export.go index 0e15b77..915fe48 100644 --- a/app/export.go +++ b/app/export.go @@ -10,6 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" "github.com/cosmos/cosmos-sdk/x/staking" + //"github.com/cosmos/cosmos-sdk/x/staking/exported" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -19,7 +20,6 @@ import ( func (app *App) ExportAppStateAndValidators( forZeroHeight bool, jailAllowedAddrs []string, ) (servertypes.ExportedApp, error) { - // as if they could withdraw from the start of the next block ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) @@ -48,7 +48,8 @@ func (app *App) ExportAppStateAndValidators( // prepare for fresh start at zero height // NOTE zero height genesis is a temporary feature which will be deprecated -// in favour of export at a block height +// +// in favour of export at a block height func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { applyAllowedAddrs := false @@ -193,4 +194,3 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str }, ) } - diff --git a/app/prefix.go b/app/prefix.go index cf3b9f8..c668a1b 100644 --- a/app/prefix.go +++ b/app/prefix.go @@ -25,4 +25,4 @@ func SetConfig() { config.SetBech32PrefixForValidator(ValidatorAddressPrefix, ValidatorPubKeyPrefix) config.SetBech32PrefixForConsensusNode(ConsNodeAddressPrefix, ConsNodePubKeyPrefix) config.Seal() -} \ No newline at end of file +} diff --git a/app/types.go b/app/types.go index cb04fe8..f782bf5 100644 --- a/app/types.go +++ b/app/types.go @@ -38,4 +38,3 @@ type CosmosApp interface { // All the registered module account addreses. ModuleAccountAddrs() map[string]bool } - diff --git a/cmd/cyber/cmd/genaccounts.go b/cmd/cyber/cmd/genaccounts.go index f7bc2f8..91d82aa 100644 --- a/cmd/cyber/cmd/genaccounts.go +++ b/cmd/cyber/cmd/genaccounts.go @@ -49,9 +49,9 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa if err != nil { inBuf := bufio.NewReader(cmd.InOrStdin()) keyringBackend, err := cmd.Flags().GetString(flags.FlagKeyringBackend) - if err != nil { - return err - } + if err != nil { + return err + } // attempt to lookup address from Keybase if no address was provided kb, err := keyring.New(sdk.KeyringServiceName(), keyringBackend, clientCtx.HomeDir, inBuf) @@ -73,17 +73,17 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa } vestingStart, err := cmd.Flags().GetInt64(flagVestingStart) - if err != nil { - return err - } + if err != nil { + return err + } vestingEnd, err := cmd.Flags().GetInt64(flagVestingEnd) - if err != nil { - return err - } + if err != nil { + return err + } vestingAmtStr, err := cmd.Flags().GetString(flagVestingAmt) - if err != nil { - return err - } + if err != nil { + return err + } vestingAmt, err := sdk.ParseCoinsNormalized(vestingAmtStr) if err != nil { @@ -162,7 +162,6 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa bankGenState.Balances = banktypes.SanitizeGenesisBalances(bankGenState.Balances) bankGenState.Supply = bankGenState.Supply.Add(balances.Coins...) - bankGenStateBz, err := clientCtx.Codec.MarshalJSON(bankGenState) if err != nil { return fmt.Errorf("failed to marshal bank genesis state: %w", err) diff --git a/cmd/cyber/cmd/root.go b/cmd/cyber/cmd/root.go index 40702e1..eb5de41 100644 --- a/cmd/cyber/cmd/root.go +++ b/cmd/cyber/cmd/root.go @@ -2,14 +2,16 @@ package cmd import ( "errors" - wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - "github.com/cosmos/cosmos-sdk/client/config" - "github.com/cybercongress/go-cyber/app" - "github.com/prometheus/client_golang/prometheus" "io" "os" "path/filepath" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + "github.com/cosmos/cosmos-sdk/client/config" + "github.com/prometheus/client_golang/prometheus" + + "github.com/cybercongress/go-cyber/app" + "github.com/CosmWasm/wasmd/x/wasm" "github.com/cosmos/cosmos-sdk/snapshots" "github.com/cosmos/cosmos-sdk/x/crisis" @@ -38,6 +40,7 @@ import ( genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" serverconfig "github.com/cosmos/cosmos-sdk/server/config" + "github.com/cybercongress/go-cyber/app/params" ) @@ -85,7 +88,6 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { } func initAppConfig() (string, interface{}) { - type CustomAppConfig struct { serverconfig.Config } @@ -106,7 +108,6 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { cfg := sdk.GetConfig() cfg.Seal() - rootCmd.AddCommand( genutilcli.InitCmd(app.ModuleBasics, app.DefaultNodeHome), genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome), @@ -248,9 +249,9 @@ func (ac appCreator) newApp( baseapp.SetInterBlockCache(cache), baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))), baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))), - baseapp.SetSnapshotStore(snapshotStore), - baseapp.SetSnapshotInterval(cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval))), - baseapp.SetSnapshotKeepRecent(cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent))), + baseapp.SetSnapshotStore(snapshotStore), + baseapp.SetSnapshotInterval(cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval))), + baseapp.SetSnapshotKeepRecent(cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent))), ) } @@ -263,7 +264,6 @@ func (ac appCreator) appExport( jailAllowedAddrs []string, appOpts servertypes.AppOptions, ) (servertypes.ExportedApp, error) { - homePath, ok := appOpts.Get(flags.FlagHome).(string) if !ok || homePath == "" { return servertypes.ExportedApp{}, errors.New("application home is not set") diff --git a/cmd/cyber/cmd/testnet.go b/cmd/cyber/cmd/testnet.go index f8e7b3a..75b737a 100644 --- a/cmd/cyber/cmd/testnet.go +++ b/cmd/cyber/cmd/testnet.go @@ -6,11 +6,12 @@ import ( "bufio" "encoding/json" "fmt" - "github.com/cosmos/cosmos-sdk/testutil" "net" "os" "path/filepath" + "github.com/cosmos/cosmos-sdk/testutil" + "github.com/spf13/cobra" tmconfig "github.com/tendermint/tendermint/config" tmos "github.com/tendermint/tendermint/libs/os" @@ -94,7 +95,7 @@ Example: return cmd } -const nodeDirPerm = 0755 +const nodeDirPerm = 0o755 // Initialize the testnet func InitTestnet( @@ -113,7 +114,6 @@ func InitTestnet( algoStr string, numValidators int, ) error { - if chainID == "" { chainID = "chain-" + tmrand.NewRand().Str(6) } @@ -178,7 +178,7 @@ func InitTestnet( return err } - addr, secret, err := testutil.GenerateSaveCoinKey(kb, nodeDirName, "",true, algo) + addr, secret, err := testutil.GenerateSaveCoinKey(kb, nodeDirName, "", true, algo) if err != nil { _ = os.RemoveAll(outputDir) return err @@ -270,7 +270,6 @@ func initGenFiles( genAccounts []authtypes.GenesisAccount, genBalances []banktypes.Balance, genFiles []string, numValidators int, ) error { - appGenState := mbm.DefaultGenesis(clientCtx.Codec) // set the accounts in the genesis state @@ -317,7 +316,6 @@ func collectGenFiles( nodeIDs []string, valPubKeys []cryptotypes.PubKey, numValidators int, outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator, ) error { - var appState json.RawMessage genTime := tmtime.Now() @@ -386,15 +384,15 @@ func writeFile(name string, dir string, contents []byte) error { writePath := filepath.Join(dir) file := filepath.Join(writePath, name) - err := tmos.EnsureDir(writePath, 0755) + err := tmos.EnsureDir(writePath, 0o755) if err != nil { return err } - err = tmos.WriteFile(file, contents, 0644) + err = tmos.WriteFile(file, contents, 0o644) if err != nil { return err } return nil -} \ No newline at end of file +} diff --git a/cmd/iavltool/cmd/root.go b/cmd/iavltool/cmd/root.go index 3965fc0..9f7320a 100644 --- a/cmd/iavltool/cmd/root.go +++ b/cmd/iavltool/cmd/root.go @@ -2,12 +2,11 @@ package cmd import ( "bytes" - "strconv" - "crypto/sha256" "encoding/hex" "fmt" "os" + "strconv" "strings" "github.com/spf13/cobra" @@ -24,8 +23,8 @@ const ( var ( DefaultHome = os.ExpandEnv("$HOME/") + ".cyber/data" - rootCmd = &cobra.Command{Use: "iavltool"} - home string + rootCmd = &cobra.Command{Use: "iavltool"} + home string ) // TODO autoconf stores @@ -70,7 +69,7 @@ func init() { var dataCmd = &cobra.Command{ Use: "data [store] [version] [kv] [hash]", Short: "Print data of given stores at given block", - Args: cobra.MinimumNArgs(0), + Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { db, err := OpenDb(home) if err != nil { @@ -92,7 +91,9 @@ var dataCmd = &cobra.Command{ fallthrough case 1: var a []string - if args[0] != "all" { stores = append(a, args[0]) } + if args[0] != "all" { + stores = append(a, args[0]) + } } for _, name := range stores { @@ -113,7 +114,7 @@ var dataCmd = &cobra.Command{ var shapeCmd = &cobra.Command{ Use: "shape [store] [version]", Short: "Print shape of given stores at given block", - Args: cobra.MinimumNArgs(0), + Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { db, err := OpenDb(home) if err != nil { @@ -142,7 +143,7 @@ var shapeCmd = &cobra.Command{ var versionsCmd = &cobra.Command{ Use: "versions [store]", Short: "Print shape of given stores at given block", - Args: cobra.MinimumNArgs(1), + Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { db, err := OpenDb(home) if err != nil { @@ -161,7 +162,7 @@ var versionsCmd = &cobra.Command{ var deleteCmd = &cobra.Command{ Use: "delete [store] [from] [to]", Short: "Delete versions range for given stores", - Args: cobra.MinimumNArgs(0), + Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { db, err := OpenDb(home) if err != nil { @@ -179,7 +180,9 @@ var deleteCmd = &cobra.Command{ fallthrough case 1: var a []string - if args[0] != "all" { stores = append(a, args[0]) } + if args[0] != "all" { + stores = append(a, args[0]) + } } for _, name := range stores { @@ -201,7 +204,7 @@ var deleteCmd = &cobra.Command{ var statsCmd = &cobra.Command{ Use: "stats [store] [version]", Short: "Print shape of given stores at given block", - Args: cobra.MinimumNArgs(0), + Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { db, err := OpenDb(home) if err != nil { @@ -215,11 +218,11 @@ var statsCmd = &cobra.Command{ var pruneCmd = &cobra.Command{ Use: "prune", Short: "Prune leveldb", - Args: cobra.NoArgs, + Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { db, _ := goleveldb.OpenFile(home+"/application.db", nil) defer db.Close() - _ = db.CompactRange(util.Range{nil,nil}) + _ = db.CompactRange(util.Range{nil, nil}) }, } @@ -331,4 +334,4 @@ func PrintVersions(tree *iavl.MutableTree) { for _, v := range versions { fmt.Printf(" %d\n", v) } -} \ No newline at end of file +} diff --git a/cmd/iavltool/main.go b/cmd/iavltool/main.go index e2fabfc..66e83f6 100644 --- a/cmd/iavltool/main.go +++ b/cmd/iavltool/main.go @@ -6,4 +6,4 @@ import ( func main() { cmd.Execute() -} \ No newline at end of file +} diff --git a/merkle/proof.go b/merkle/proof.go index 011a03b..200f568 100644 --- a/merkle/proof.go +++ b/merkle/proof.go @@ -11,7 +11,6 @@ type Proof struct { // calculate sum hash func (p *Proof) SumWith(hashF hash.Hash, hash []byte) []byte { - if p.LeftSide { return sum(hashF, p.Hash, hash) } else { diff --git a/merkle/subtree.go b/merkle/subtree.go index e8c7a7a..49b69c8 100644 --- a/merkle/subtree.go +++ b/merkle/subtree.go @@ -39,7 +39,6 @@ func (t *Subtree) getLeftSubtreesProof() []Proof { // right proof is only one cause we have to sum all right subtrees // we have to sum hashes from right to left func (t *Subtree) getRightSubtreesProof() []Proof { - if t.right == nil { return make([]Proof, 0) } diff --git a/merkle/tree.go b/merkle/tree.go index 1f4a3b2..1575357 100644 --- a/merkle/tree.go +++ b/merkle/tree.go @@ -32,7 +32,6 @@ func NewTree(hashF hash.Hash, full bool) *Tree { } func (t *Tree) joinAllSubtrees() { - for t.subTree.left != nil && t.subTree.height == t.subTree.left.height { newSubtreeRoot := &Node{ @@ -102,12 +101,10 @@ func (t *Tree) BuildNew(data [][]byte) { } t.lastIndex = int(endIndex) - } // n*log(n) func (t *Tree) Push(data []byte) { - newSubtreeRoot := &Node{ hash: sum(t.hashF, data), parent: nil, @@ -137,7 +134,6 @@ func (t *Tree) Push(data []byte) { // going from right trees to left func (t *Tree) GetIndexProofs(i int) []Proof { - // we cannot build proofs with not full tree if !t.full { return nil @@ -167,7 +163,6 @@ func (t *Tree) ValidateIndex(i int, data []byte) bool { } func (t *Tree) ValidateIndexByProofs(i int, data []byte, proofs []Proof) bool { - rootHash := sum(t.hashF, data) for _, proof := range proofs { rootHash = proof.SumWith(t.hashF, rootHash) @@ -178,7 +173,6 @@ func (t *Tree) ValidateIndexByProofs(i int, data []byte, proofs []Proof) bool { // root hash calculates from right to left by summing subtrees root hashes. func (t *Tree) RootHash() []byte { - if t.subTree == nil { return sum(t.hashF) // zero hash } diff --git a/merkle/tree_test.go b/merkle/tree_test.go index fab084a..5524ad0 100644 --- a/merkle/tree_test.go +++ b/merkle/tree_test.go @@ -3,12 +3,12 @@ package merkle import ( "crypto/sha256" "encoding/binary" - "github.com/stretchr/testify/require" "testing" + + "github.com/stretchr/testify/require" ) func TestPushAndProofs(t *testing.T) { - tree := NewTree(sha256.New(), true) data := make([]byte, 8) @@ -24,11 +24,9 @@ func TestPushAndProofs(t *testing.T) { binary.LittleEndian.PutUint64(data, uint64(i)) require.Equal(t, true, tree.ValidateIndexByProofs(i, data, proofs)) } - } func TestBuildNewAndProofs(t *testing.T) { - tree := NewTree(sha256.New(), true) allData := make([][]byte, 0, 31) @@ -48,11 +46,9 @@ func TestBuildNewAndProofs(t *testing.T) { binary.LittleEndian.PutUint64(data, uint64(i)) require.Equal(t, true, tree.ValidateIndexByProofs(i, data, proofs)) } - } func TestEqualityOfBuildNewAndPush(t *testing.T) { - tree1 := NewTree(sha256.New(), true) data := make([]byte, 8) diff --git a/merkle/util.go b/merkle/util.go index 6186f6d..03fe1e4 100644 --- a/merkle/util.go +++ b/merkle/util.go @@ -17,16 +17,13 @@ func sum(h hash.Hash, data ...[]byte) []byte { // number of data elements should be power of 2 // not suitable for parallel calculations cause using same hash.Hash func buildSubTree(h hash.Hash, full bool, startIndex int, data [][]byte) *Subtree { - nodes := make([]*Node, len(data)) for i := 0; i < len(data); i++ { - nodes[i] = &Node{ hash: sum(h, data[i]), firstIndex: startIndex + i, lastIndex: startIndex + i, } - } root := sumNodes(h, full, nodes)[0] @@ -41,7 +38,6 @@ func buildSubTree(h hash.Hash, full bool, startIndex int, data [][]byte) *Subtre } func sumNodes(h hash.Hash, full bool, nodes []*Node) []*Node { - if len(nodes) == 1 { return nodes } diff --git a/plugins/liquidity_plugin/liquidity_plugin.go b/plugins/liquidity_plugin/liquidity_plugin.go index 27362e6..096564a 100644 --- a/plugins/liquidity_plugin/liquidity_plugin.go +++ b/plugins/liquidity_plugin/liquidity_plugin.go @@ -2,9 +2,11 @@ package liquidity_plugin import ( "encoding/json" - "github.com/cybercongress/go-cyber/plugins" + liquiditytypes "github.com/tendermint/liquidity/x/liquidity/types" + "github.com/cybercongress/go-cyber/plugins" + "github.com/CosmWasm/wasmd/x/wasm" wasmTypes "github.com/CosmWasm/wasmvm/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -13,8 +15,10 @@ import ( "github.com/tendermint/liquidity/x/liquidity/keeper" ) -var _ plugins.WasmQuerierInterface = WasmQuerier{} -var _ plugins.WasmMsgParserInterface = WasmMsgParser{} +var ( + _ plugins.WasmQuerierInterface = WasmQuerier{} + _ plugins.WasmMsgParserInterface = WasmMsgParser{} +) //-------------------------------------------------- @@ -24,13 +28,15 @@ func NewWasmMsgParser() WasmMsgParser { return WasmMsgParser{} } -func (WasmMsgParser) Parse(_ sdk.AccAddress, _ wasmTypes.CosmosMsg) ([]sdk.Msg, error) { return nil, nil } +func (WasmMsgParser) Parse(_ sdk.AccAddress, _ wasmTypes.CosmosMsg) ([]sdk.Msg, error) { + return nil, nil +} type CosmosMsg struct { - CreatePool *liquiditytypes.MsgCreatePool `json:"create_pool,omitempty"` - DepositWithinBatch *liquiditytypes.MsgDepositWithinBatch `json:"deposit_within_batch,omitempty"` - WithdrawWithinBatch *liquiditytypes.MsgWithdrawWithinBatch `json:"withdraw_within_batch,omitempty"` - SwapWithinBatch *liquiditytypes.MsgSwapWithinBatch `json:"swap_within_batch,omitempty"` + CreatePool *liquiditytypes.MsgCreatePool `json:"create_pool,omitempty"` + DepositWithinBatch *liquiditytypes.MsgDepositWithinBatch `json:"deposit_within_batch,omitempty"` + WithdrawWithinBatch *liquiditytypes.MsgWithdrawWithinBatch `json:"withdraw_within_batch,omitempty"` + SwapWithinBatch *liquiditytypes.MsgSwapWithinBatch `json:"swap_within_batch,omitempty"` } func (WasmMsgParser) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessage) ([]sdk.Msg, error) { @@ -55,7 +61,6 @@ func (WasmMsgParser) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessa //-------------------------------------------------- - type WasmQuerier struct { keeper.Keeper } @@ -79,10 +84,10 @@ type QueryPoolParams struct { } type PoolParamsResponse struct { - TypeId uint32 `json:"type_id"` - ReserveCoinDenoms []string `json:"reserve_coin_denoms"` - ReserveAccountAddress string `json:"reserve_account_address"` - PoolCoinDenom string `json:"pool_coin_denom"` + TypeId uint32 `json:"type_id"` + ReserveCoinDenoms []string `json:"reserve_coin_denoms"` + ReserveAccountAddress string `json:"reserve_account_address"` + PoolCoinDenom string `json:"pool_coin_denom"` } type PoolLiquidityResponse struct { @@ -97,7 +102,6 @@ type PoolPriceResponse struct { Price string `json:"price"` } - type PoolAddressResponse struct { Address string `json:"address"` } @@ -105,7 +109,6 @@ type PoolAddressResponse struct { func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) { var query CosmosQuery err := json.Unmarshal(data, &query) - if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } @@ -113,20 +116,22 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ var bz []byte if query.PoolParams != nil { - pool, found := querier.Keeper.GetPool(ctx, query.PoolParams.PoolId); if found != true { + pool, found := querier.Keeper.GetPool(ctx, query.PoolParams.PoolId) + if found != true { return nil, sdkerrors.ErrInvalidRequest } bz, err = json.Marshal( PoolParamsResponse{ - TypeId: pool.TypeId, - ReserveCoinDenoms: pool.ReserveCoinDenoms, + TypeId: pool.TypeId, + ReserveCoinDenoms: pool.ReserveCoinDenoms, ReserveAccountAddress: pool.ReserveAccountAddress, - PoolCoinDenom: pool.PoolCoinDenom, + PoolCoinDenom: pool.PoolCoinDenom, }, ) } else if query.PoolLiquidity != nil { - pool, found := querier.Keeper.GetPool(ctx, query.PoolLiquidity.PoolId); if found != true { + pool, found := querier.Keeper.GetPool(ctx, query.PoolLiquidity.PoolId) + if found != true { return nil, sdkerrors.ErrInvalidRequest } @@ -138,7 +143,8 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ }, ) } else if query.PoolSupply != nil { - pool, found := querier.Keeper.GetPool(ctx, query.PoolSupply.PoolId); if found != true { + pool, found := querier.Keeper.GetPool(ctx, query.PoolSupply.PoolId) + if found != true { return nil, sdkerrors.ErrInvalidRequest } @@ -150,7 +156,8 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ }, ) } else if query.PoolPrice != nil { - pool, found := querier.Keeper.GetPool(ctx, query.PoolPrice.PoolId); if found != true { + pool, found := querier.Keeper.GetPool(ctx, query.PoolPrice.PoolId) + if found != true { return nil, sdkerrors.ErrInvalidRequest } @@ -164,7 +171,8 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ }, ) } else if query.PoolAddress != nil { - pool, found := querier.Keeper.GetPool(ctx, query.PoolAddress.PoolId); if found != true { + pool, found := querier.Keeper.GetPool(ctx, query.PoolAddress.PoolId) + if found != true { return nil, sdkerrors.ErrInvalidRequest } diff --git a/plugins/msg_binding.go b/plugins/msg_binding.go index 05ea7b0..2ab2d37 100644 --- a/plugins/msg_binding.go +++ b/plugins/msg_binding.go @@ -2,6 +2,7 @@ package plugins import ( "encoding/json" + liquiditytypes "github.com/tendermint/liquidity/x/liquidity/types" "github.com/CosmWasm/wasmd/x/wasm" @@ -22,7 +23,7 @@ type WasmMsgParserInterface interface { } type MsgParser struct { - Parsers map[string]WasmMsgParserInterface + Parsers map[string]WasmMsgParserInterface } func NewMsgParser() MsgParser { diff --git a/plugins/query_binding.go b/plugins/query_binding.go index f1db75f..1f79c13 100644 --- a/plugins/query_binding.go +++ b/plugins/query_binding.go @@ -2,6 +2,7 @@ package plugins import ( "encoding/json" + liquiditytypes "github.com/tendermint/liquidity/x/liquidity/types" wasm "github.com/CosmWasm/wasmd/x/wasm" @@ -48,7 +49,6 @@ const ( func (q Querier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) { var customQuery WasmCustomQuery err := json.Unmarshal(data, &customQuery) - if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } diff --git a/types/account.go b/types/account.go index cbf4f8d..16cac18 100644 --- a/types/account.go +++ b/types/account.go @@ -1,4 +1,3 @@ package types type AccNumber uint64 - diff --git a/types/query/pagination.pb.go b/types/query/pagination.pb.go index 7a8cb4d..6807243 100644 --- a/types/query/pagination.pb.go +++ b/types/query/pagination.pb.go @@ -5,16 +5,19 @@ package query import ( fmt "fmt" - proto "github.com/gogo/protobuf/proto" io "io" math "math" math_bits "math/bits" + + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -33,9 +36,11 @@ func (*PageRequest) ProtoMessage() {} func (*PageRequest) Descriptor() ([]byte, []int) { return fileDescriptor_83d57be4c5c081da, []int{0} } + func (m *PageRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *PageRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_PageRequest.Marshal(b, m, deterministic) @@ -48,12 +53,15 @@ func (m *PageRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } + func (m *PageRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_PageRequest.Merge(m, src) } + func (m *PageRequest) XXX_Size() int { return m.Size() } + func (m *PageRequest) XXX_DiscardUnknown() { xxx_messageInfo_PageRequest.DiscardUnknown(m) } @@ -84,9 +92,11 @@ func (*PageResponse) ProtoMessage() {} func (*PageResponse) Descriptor() ([]byte, []int) { return fileDescriptor_83d57be4c5c081da, []int{1} } + func (m *PageResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *PageResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_PageResponse.Marshal(b, m, deterministic) @@ -99,12 +109,15 @@ func (m *PageResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } + func (m *PageResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_PageResponse.Merge(m, src) } + func (m *PageResponse) XXX_Size() int { return m.Size() } + func (m *PageResponse) XXX_DiscardUnknown() { xxx_messageInfo_PageResponse.DiscardUnknown(m) } @@ -217,6 +230,7 @@ func encodeVarintPagination(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *PageRequest) Size() (n int) { if m == nil { return 0 @@ -247,9 +261,11 @@ func (m *PageResponse) Size() (n int) { func sovPagination(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozPagination(x uint64) (n int) { return sovPagination(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *PageRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -338,6 +354,7 @@ func (m *PageRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *PageResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -407,6 +424,7 @@ func (m *PageResponse) Unmarshal(dAtA []byte) error { } return nil } + func skipPagination(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/utils/context.go b/utils/context.go index 7f9b972..0ef30a3 100644 --- a/utils/context.go +++ b/utils/context.go @@ -4,11 +4,10 @@ import ( "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/tendermint/tm-db" + db "github.com/tendermint/tm-db" ) func NewContextWithMSVersion(db db.DB, version int64, keys map[string]*sdk.KVStoreKey) (sdk.Context, error) { - ms := store.NewCommitMultiStore(db) for _, key := range keys { @@ -16,7 +15,6 @@ func NewContextWithMSVersion(db db.DB, version int64, keys map[string]*sdk.KVSto } err := ms.LoadVersion(version) - if err != nil { return sdk.Context{}, err } diff --git a/utils/io.go b/utils/io.go index 5f739e8..9b29f78 100644 --- a/utils/io.go +++ b/utils/io.go @@ -2,10 +2,11 @@ package utils import ( "errors" - "github.com/spf13/viper" - "github.com/tendermint/tendermint/libs/cli" "io" "path/filepath" + + "github.com/spf13/viper" + "github.com/tendermint/tendermint/libs/cli" ) func RootifyPath(path string) string { @@ -31,4 +32,4 @@ func ReadExactlyNBytes(reader io.Reader, n uint64) ([]byte, error) { } return data, nil -} \ No newline at end of file +} diff --git a/x/bandwidth/abci.go b/x/bandwidth/abci.go index a29c955..2b3095d 100644 --- a/x/bandwidth/abci.go +++ b/x/bandwidth/abci.go @@ -1,11 +1,11 @@ package bandwidth import ( + "time" + "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" - "time" - "github.com/cybercongress/go-cyber/x/bandwidth/keeper" "github.com/cybercongress/go-cyber/x/bandwidth/types" ) diff --git a/x/bandwidth/client/cli/query.go b/x/bandwidth/client/cli/query.go index 040f2dd..c685b22 100644 --- a/x/bandwidth/client/cli/query.go +++ b/x/bandwidth/client/cli/query.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" sdk "github.com/cosmos/cosmos-sdk/types" - //sdk "github.com/cosmos/cosmos-sdk/types" + // sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/cobra" "github.com/cybercongress/go-cyber/x/bandwidth/types" @@ -23,11 +23,11 @@ func GetQueryCmd() *cobra.Command { } bandwidthQueryCmd.AddCommand( - GetCmdQueryParams(), - GetCmdQueryPrice(), - GetCmdQueryLoad(), - GetCmdQueryTotalBandwidth(), - GetCmdQueryNeuron(), + GetCmdQueryParams(), + GetCmdQueryPrice(), + GetCmdQueryLoad(), + GetCmdQueryTotalBandwidth(), + GetCmdQueryNeuron(), ) return bandwidthQueryCmd @@ -181,4 +181,4 @@ func GetCmdQueryNeuron() *cobra.Command { flags.AddQueryFlagsToCmd(cmd) return cmd -} \ No newline at end of file +} diff --git a/x/bandwidth/client/rest/query.go b/x/bandwidth/client/rest/query.go index 28df649..26efa60 100644 --- a/x/bandwidth/client/rest/query.go +++ b/x/bandwidth/client/rest/query.go @@ -33,7 +33,6 @@ func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { func queryParamsHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryParameters) res, height, err := cliCtx.QueryWithData(route, nil) @@ -54,7 +53,6 @@ func queryParamsHandlerFn(cliCtx client.Context) http.HandlerFunc { func networkLoadHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryLoad) res, height, err := cliCtx.QueryWithData(route, nil) @@ -75,7 +73,6 @@ func networkLoadHandlerFn(cliCtx client.Context) http.HandlerFunc { func priceHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryPrice) res, height, err := cliCtx.QueryWithData(route, nil) @@ -96,7 +93,6 @@ func priceHandlerFn(cliCtx client.Context) http.HandlerFunc { func totalBandwidthHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryDesirableBandwidth) res, height, err := cliCtx.QueryWithData(route, nil) @@ -148,4 +144,3 @@ func neuronBandwidthHandlerFn(cliCtx client.Context) http.HandlerFunc { rest.PostProcessResponse(w, cliCtx, res) } } - diff --git a/x/bandwidth/client/rest/rest.go b/x/bandwidth/client/rest/rest.go index 3d965d1..eee7f72 100644 --- a/x/bandwidth/client/rest/rest.go +++ b/x/bandwidth/client/rest/rest.go @@ -3,7 +3,6 @@ package rest import ( "github.com/cosmos/cosmos-sdk/client" "github.com/gorilla/mux" - ) func RegisterRoutes(cliCtx client.Context, r *mux.Router) { diff --git a/x/bandwidth/keeper/accounts.go b/x/bandwidth/keeper/accounts.go index 43900e4..a3f6870 100644 --- a/x/bandwidth/keeper/accounts.go +++ b/x/bandwidth/keeper/accounts.go @@ -14,7 +14,7 @@ func (bm BandwidthMeter) GetAccountBandwidth(ctx sdk.Context, address sdk.AccAdd bwBytes := ctx.KVStore(bm.storeKey).Get(types.AccountStoreKey(address.String())) if bwBytes == nil { return types.NeuronBandwidth{ - Neuron : address.String(), + Neuron: address.String(), RemainedValue: 0, LastUpdatedBlock: uint64(ctx.BlockHeight()), MaxValue: 0, diff --git a/x/bandwidth/keeper/blocks.go b/x/bandwidth/keeper/blocks.go index 6ef177e..d225fe3 100644 --- a/x/bandwidth/keeper/blocks.go +++ b/x/bandwidth/keeper/blocks.go @@ -24,4 +24,4 @@ func (bm BandwidthMeter) GetValuesForPeriod(ctx sdk.Context, period uint64) map[ result[blockNumber] = sdk.BigEndianToUint64(store.Get(types.BlockStoreKey(blockNumber))) } return result -} \ No newline at end of file +} diff --git a/x/bandwidth/keeper/grpc_query.go b/x/bandwidth/keeper/grpc_query.go index 8a07b47..47c9445 100644 --- a/x/bandwidth/keeper/grpc_query.go +++ b/x/bandwidth/keeper/grpc_query.go @@ -1,12 +1,12 @@ package keeper import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "context" - "github.com/cybercongress/go-cyber/x/bandwidth/types" ) diff --git a/x/bandwidth/keeper/keeper.go b/x/bandwidth/keeper/keeper.go index b011b47..937f4a7 100644 --- a/x/bandwidth/keeper/keeper.go +++ b/x/bandwidth/keeper/keeper.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" @@ -30,7 +31,6 @@ func NewBandwidthMeter( asp types.AccountStakeProvider, paramSpace paramstypes.Subspace, ) *BandwidthMeter { - if !paramSpace.HasKeyTable() { paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) } @@ -197,11 +197,11 @@ func (bm *BandwidthMeter) AdjustPrice(ctx sdk.Context) { } } -func (bm *BandwidthMeter) GetTotalCyberlinksCost(ctx sdk.Context, tx sdk.Tx) (uint64) { +func (bm *BandwidthMeter) GetTotalCyberlinksCost(ctx sdk.Context, tx sdk.Tx) uint64 { bandwidthForTx := uint64(0) for _, msg := range tx.GetMsgs() { linkMsg := msg.(*gtypes.MsgCyberlink) - bandwidthForTx = bandwidthForTx + uint64(len(linkMsg.Links)) * 1000 + bandwidthForTx = bandwidthForTx + uint64(len(linkMsg.Links))*1000 } return bandwidthForTx } @@ -211,7 +211,8 @@ func (bm *BandwidthMeter) GetPricedTotalCyberlinksCost(ctx sdk.Context, tx sdk.T } func (bm *BandwidthMeter) ConsumeAccountBandwidth(ctx sdk.Context, bw types.NeuronBandwidth, amt uint64) error { - err := bw.Consume(amt); if err != nil { + err := bw.Consume(amt) + if err != nil { return err } bm.SetAccountBandwidth(ctx, bw) diff --git a/x/bandwidth/keeper/querier.go b/x/bandwidth/keeper/querier.go index 44966d6..01ba077 100644 --- a/x/bandwidth/keeper/querier.go +++ b/x/bandwidth/keeper/querier.go @@ -39,7 +39,7 @@ func queryParams(ctx sdk.Context, _ abci.RequestQuery, bm BandwidthMeter, legacy return res, nil } -func queryLoad(ctx sdk.Context, _ abci.RequestQuery, bm *BandwidthMeter, legacyQuerierCdc *codec.LegacyAmino,) ([]byte, error) { +func queryLoad(ctx sdk.Context, _ abci.RequestQuery, bm *BandwidthMeter, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { load := bm.GetCurrentNetworkLoad(ctx) res, err := codec.MarshalJSONIndent(legacyQuerierCdc, types.QueryLoadResponse{Load: sdk.DecProto{Dec: load}}) if err != nil { @@ -49,7 +49,7 @@ func queryLoad(ctx sdk.Context, _ abci.RequestQuery, bm *BandwidthMeter, legacyQ return res, nil } -func queryPrice(_ sdk.Context, _ abci.RequestQuery, bm *BandwidthMeter, legacyQuerierCdc *codec.LegacyAmino,) ([]byte, error) { +func queryPrice(_ sdk.Context, _ abci.RequestQuery, bm *BandwidthMeter, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { price := bm.GetCurrentCreditPrice() res, err := codec.MarshalJSONIndent(legacyQuerierCdc, types.QueryPriceResponse{Price: sdk.DecProto{Dec: price}}) if err != nil { @@ -59,7 +59,7 @@ func queryPrice(_ sdk.Context, _ abci.RequestQuery, bm *BandwidthMeter, legacyQu return res, nil } -func queryTotalBandwidth(ctx sdk.Context, _ abci.RequestQuery, bm *BandwidthMeter, legacyQuerierCdc *codec.LegacyAmino,) ([]byte, error) { +func queryTotalBandwidth(ctx sdk.Context, _ abci.RequestQuery, bm *BandwidthMeter, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { totalBandwidth := bm.GetDesirableBandwidth(ctx) res, err := codec.MarshalJSONIndent(legacyQuerierCdc, types.QueryTotalBandwidthResponse{TotalBandwidth: totalBandwidth}) if err != nil { @@ -69,10 +69,11 @@ func queryTotalBandwidth(ctx sdk.Context, _ abci.RequestQuery, bm *BandwidthMete return res, nil } -func queryNeuronBandwidth(ctx sdk.Context, req abci.RequestQuery, bm BandwidthMeter, legacyQuerierCdc *codec.LegacyAmino,) ([]byte, error) { +func queryNeuronBandwidth(ctx sdk.Context, req abci.RequestQuery, bm BandwidthMeter, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QueryAccountBandwidthParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); if err != nil { + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } @@ -85,5 +86,3 @@ func queryNeuronBandwidth(ctx sdk.Context, req abci.RequestQuery, bm BandwidthMe return res, nil } - - diff --git a/x/bandwidth/module.go b/x/bandwidth/module.go index 79c76af..d6da2fb 100644 --- a/x/bandwidth/module.go +++ b/x/bandwidth/module.go @@ -1,6 +1,7 @@ package bandwidth import ( + "context" "encoding/json" "fmt" @@ -18,8 +19,6 @@ import ( "github.com/cybercongress/go-cyber/x/bandwidth/keeper" "github.com/cybercongress/go-cyber/x/bandwidth/types" - "context" - sdk "github.com/cosmos/cosmos-sdk/types" abci "github.com/tendermint/tendermint/abci/types" ) @@ -29,8 +28,7 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) - -type AppModuleBasic struct{ +type AppModuleBasic struct { cdc codec.Codec } @@ -71,8 +69,8 @@ func (AppModuleBasic) RegisterInterfaces(_ codectypes.InterfaceRegistry) {} type AppModule struct { AppModuleBasic - ak authkeeper.AccountKeeper - bm *keeper.BandwidthMeter + ak authkeeper.AccountKeeper + bm *keeper.BandwidthMeter } func NewAppModule( @@ -82,8 +80,8 @@ func NewAppModule( ) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, - ak: ak, - bm: bm, + ak: ak, + bm: bm, } } diff --git a/x/bandwidth/types/account_bandwidth.go b/x/bandwidth/types/account_bandwidth.go index 00652ed..b7aeb1e 100644 --- a/x/bandwidth/types/account_bandwidth.go +++ b/x/bandwidth/types/account_bandwidth.go @@ -6,10 +6,10 @@ import ( func NewGenesisNeuronBandwidth(address sdk.AccAddress, bandwidth uint64) NeuronBandwidth { return NeuronBandwidth{ - Neuron: address.String(), - RemainedValue: bandwidth, - MaxValue: bandwidth, - LastUpdatedBlock: 0, + Neuron: address.String(), + RemainedValue: bandwidth, + MaxValue: bandwidth, + LastUpdatedBlock: 0, } } @@ -51,4 +51,3 @@ func (ab *NeuronBandwidth) ApplyCharge(bandwidthToAdd uint64) { func (ab NeuronBandwidth) HasEnoughRemained(bandwidthToConsume uint64) bool { return ab.RemainedValue >= bandwidthToConsume } - diff --git a/x/bandwidth/types/errors.go b/x/bandwidth/types/errors.go index ffb78be..2ac8663 100644 --- a/x/bandwidth/types/errors.go +++ b/x/bandwidth/types/errors.go @@ -5,6 +5,6 @@ import ( ) var ( - ErrNotEnoughBandwidth = sdkerrors.Register(ModuleName, 2, "not enough personal bandwidth") + ErrNotEnoughBandwidth = sdkerrors.Register(ModuleName, 2, "not enough personal bandwidth") ErrExceededMaxBlockBandwidth = sdkerrors.Register(ModuleName, 3, "exceeded max block bandwidth") -) \ No newline at end of file +) diff --git a/x/bandwidth/types/genesis.pb.go b/x/bandwidth/types/genesis.pb.go index 2b1ffea..0dea9e1 100644 --- a/x/bandwidth/types/genesis.pb.go +++ b/x/bandwidth/types/genesis.pb.go @@ -5,17 +5,20 @@ package types import ( fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -33,9 +36,11 @@ func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { return fileDescriptor_3fe039025849c89e, []int{0} } + func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) @@ -48,12 +53,15 @@ func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } + func (m *GenesisState) XXX_Merge(src proto.Message) { xxx_messageInfo_GenesisState.Merge(m, src) } + func (m *GenesisState) XXX_Size() int { return m.Size() } + func (m *GenesisState) XXX_DiscardUnknown() { xxx_messageInfo_GenesisState.DiscardUnknown(m) } @@ -137,6 +145,7 @@ func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *GenesisState) Size() (n int) { if m == nil { return 0 @@ -151,9 +160,11 @@ func (m *GenesisState) Size() (n int) { func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozGenesis(x uint64) (n int) { return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *GenesisState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -237,6 +248,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } return nil } + func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/bandwidth/types/keys.go b/x/bandwidth/types/keys.go index bebee57..a3161f9 100644 --- a/x/bandwidth/types/keys.go +++ b/x/bandwidth/types/keys.go @@ -5,9 +5,9 @@ import ( ) const ( - ModuleName = "bandwidth" - StoreKey = ModuleName - QuerierRoute = ModuleName + ModuleName = "bandwidth" + StoreKey = ModuleName + QuerierRoute = ModuleName ) var ( @@ -25,4 +25,4 @@ func AccountStoreKey(addr string) []byte { func BlockStoreKey(blockNumber uint64) []byte { return append(BlockStoreKeyPrefix, sdk.Uint64ToBigEndian(blockNumber)...) -} \ No newline at end of file +} diff --git a/x/bandwidth/types/params.go b/x/bandwidth/types/params.go index ddb80ad..c2ab56f 100644 --- a/x/bandwidth/types/params.go +++ b/x/bandwidth/types/params.go @@ -12,11 +12,11 @@ const ( ) var ( - KeyRecoveryPeriod = []byte("RecoveryPeriod") - KeyAdjustPricePeriod = []byte("AdjustPricePeriod") - KeyBasePrice = []byte("BasePrice") - KeyBaseLoad = []byte("BaseLoad") - KeyMaxBlockBandwidth = []byte("MaxBlockBandwidth") + KeyRecoveryPeriod = []byte("RecoveryPeriod") + KeyAdjustPricePeriod = []byte("AdjustPricePeriod") + KeyBasePrice = []byte("BasePrice") + KeyBaseLoad = []byte("BaseLoad") + KeyMaxBlockBandwidth = []byte("MaxBlockBandwidth") ) func ParamKeyTable() paramstypes.KeyTable { @@ -25,11 +25,11 @@ func ParamKeyTable() paramstypes.KeyTable { func DefaultParams() Params { return Params{ - RecoveryPeriod: uint64(100), - AdjustPricePeriod: uint64(5), - BasePrice: sdk.NewDecWithPrec(25,2), - BaseLoad: sdk.NewDecWithPrec(10,2), - MaxBlockBandwidth: uint64(10000), + RecoveryPeriod: uint64(100), + AdjustPricePeriod: uint64(5), + BasePrice: sdk.NewDecWithPrec(25, 2), + BaseLoad: sdk.NewDecWithPrec(10, 2), + MaxBlockBandwidth: uint64(10000), } } @@ -124,7 +124,7 @@ func validateBaseLoad(i interface{}) error { return fmt.Errorf("base load is more than one: %s", v) } - if v.LT(sdk.NewDecWithPrec(1,1)) { + if v.LT(sdk.NewDecWithPrec(1, 1)) { return fmt.Errorf("base price is less than one tenth: %s", v) } @@ -143,4 +143,4 @@ func validateMaxBlockBandwidth(i interface{}) error { } return nil -} \ No newline at end of file +} diff --git a/x/bandwidth/types/querier.go b/x/bandwidth/types/querier.go index 0f9d5d4..7499bb6 100644 --- a/x/bandwidth/types/querier.go +++ b/x/bandwidth/types/querier.go @@ -3,17 +3,17 @@ package types import sdk "github.com/cosmos/cosmos-sdk/types" const ( - QueryParameters = "params" - QueryLoad = "load" - QueryPrice = "price" - QueryAccount = "account" + QueryParameters = "params" + QueryLoad = "load" + QueryPrice = "price" + QueryAccount = "account" QueryDesirableBandwidth = "desirable_bandwidth" ) type QueryAccountBandwidthParams struct { - Address sdk.AccAddress + Address sdk.AccAddress } func NewQueryAccountBandwidthParams(addr sdk.AccAddress) QueryAccountBandwidthParams { return QueryAccountBandwidthParams{addr} -} \ No newline at end of file +} diff --git a/x/bandwidth/types/query.pb.go b/x/bandwidth/types/query.pb.go index b69f65f..edfd6d1 100644 --- a/x/bandwidth/types/query.pb.go +++ b/x/bandwidth/types/query.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-sdk/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" @@ -15,15 +19,14 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -31,8 +34,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type QueryLoadRequest struct { -} +type QueryLoadRequest struct{} func (m *QueryLoadRequest) Reset() { *m = QueryLoadRequest{} } func (m *QueryLoadRequest) String() string { return proto.CompactTextString(m) } @@ -40,9 +42,11 @@ func (*QueryLoadRequest) ProtoMessage() {} func (*QueryLoadRequest) Descriptor() ([]byte, []int) { return fileDescriptor_bccaa873af5af46c, []int{0} } + func (m *QueryLoadRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryLoadRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryLoadRequest.Marshal(b, m, deterministic) @@ -55,12 +59,15 @@ func (m *QueryLoadRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } + func (m *QueryLoadRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryLoadRequest.Merge(m, src) } + func (m *QueryLoadRequest) XXX_Size() int { return m.Size() } + func (m *QueryLoadRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryLoadRequest.DiscardUnknown(m) } @@ -77,9 +84,11 @@ func (*QueryLoadResponse) ProtoMessage() {} func (*QueryLoadResponse) Descriptor() ([]byte, []int) { return fileDescriptor_bccaa873af5af46c, []int{1} } + func (m *QueryLoadResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryLoadResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryLoadResponse.Marshal(b, m, deterministic) @@ -92,20 +101,22 @@ func (m *QueryLoadResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } + func (m *QueryLoadResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryLoadResponse.Merge(m, src) } + func (m *QueryLoadResponse) XXX_Size() int { return m.Size() } + func (m *QueryLoadResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryLoadResponse.DiscardUnknown(m) } var xxx_messageInfo_QueryLoadResponse proto.InternalMessageInfo -type QueryPriceRequest struct { -} +type QueryPriceRequest struct{} func (m *QueryPriceRequest) Reset() { *m = QueryPriceRequest{} } func (m *QueryPriceRequest) String() string { return proto.CompactTextString(m) } @@ -113,9 +124,11 @@ func (*QueryPriceRequest) ProtoMessage() {} func (*QueryPriceRequest) Descriptor() ([]byte, []int) { return fileDescriptor_bccaa873af5af46c, []int{2} } + func (m *QueryPriceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryPriceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryPriceRequest.Marshal(b, m, deterministic) @@ -128,12 +141,15 @@ func (m *QueryPriceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } + func (m *QueryPriceRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryPriceRequest.Merge(m, src) } + func (m *QueryPriceRequest) XXX_Size() int { return m.Size() } + func (m *QueryPriceRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryPriceRequest.DiscardUnknown(m) } @@ -150,9 +166,11 @@ func (*QueryPriceResponse) ProtoMessage() {} func (*QueryPriceResponse) Descriptor() ([]byte, []int) { return fileDescriptor_bccaa873af5af46c, []int{3} } + func (m *QueryPriceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryPriceResponse.Marshal(b, m, deterministic) @@ -165,20 +183,22 @@ func (m *QueryPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QueryPriceResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryPriceResponse.Merge(m, src) } + func (m *QueryPriceResponse) XXX_Size() int { return m.Size() } + func (m *QueryPriceResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryPriceResponse.DiscardUnknown(m) } var xxx_messageInfo_QueryPriceResponse proto.InternalMessageInfo -type QueryTotalBandwidthRequest struct { -} +type QueryTotalBandwidthRequest struct{} func (m *QueryTotalBandwidthRequest) Reset() { *m = QueryTotalBandwidthRequest{} } func (m *QueryTotalBandwidthRequest) String() string { return proto.CompactTextString(m) } @@ -186,9 +206,11 @@ func (*QueryTotalBandwidthRequest) ProtoMessage() {} func (*QueryTotalBandwidthRequest) Descriptor() ([]byte, []int) { return fileDescriptor_bccaa873af5af46c, []int{4} } + func (m *QueryTotalBandwidthRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryTotalBandwidthRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryTotalBandwidthRequest.Marshal(b, m, deterministic) @@ -201,12 +223,15 @@ func (m *QueryTotalBandwidthRequest) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } + func (m *QueryTotalBandwidthRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryTotalBandwidthRequest.Merge(m, src) } + func (m *QueryTotalBandwidthRequest) XXX_Size() int { return m.Size() } + func (m *QueryTotalBandwidthRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryTotalBandwidthRequest.DiscardUnknown(m) } @@ -223,9 +248,11 @@ func (*QueryTotalBandwidthResponse) ProtoMessage() {} func (*QueryTotalBandwidthResponse) Descriptor() ([]byte, []int) { return fileDescriptor_bccaa873af5af46c, []int{5} } + func (m *QueryTotalBandwidthResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryTotalBandwidthResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryTotalBandwidthResponse.Marshal(b, m, deterministic) @@ -238,12 +265,15 @@ func (m *QueryTotalBandwidthResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } + func (m *QueryTotalBandwidthResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryTotalBandwidthResponse.Merge(m, src) } + func (m *QueryTotalBandwidthResponse) XXX_Size() int { return m.Size() } + func (m *QueryTotalBandwidthResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryTotalBandwidthResponse.DiscardUnknown(m) } @@ -260,9 +290,11 @@ func (*QueryNeuronBandwidthRequest) ProtoMessage() {} func (*QueryNeuronBandwidthRequest) Descriptor() ([]byte, []int) { return fileDescriptor_bccaa873af5af46c, []int{6} } + func (m *QueryNeuronBandwidthRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryNeuronBandwidthRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryNeuronBandwidthRequest.Marshal(b, m, deterministic) @@ -275,12 +307,15 @@ func (m *QueryNeuronBandwidthRequest) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } + func (m *QueryNeuronBandwidthRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryNeuronBandwidthRequest.Merge(m, src) } + func (m *QueryNeuronBandwidthRequest) XXX_Size() int { return m.Size() } + func (m *QueryNeuronBandwidthRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryNeuronBandwidthRequest.DiscardUnknown(m) } @@ -297,9 +332,11 @@ func (*QueryNeuronBandwidthResponse) ProtoMessage() {} func (*QueryNeuronBandwidthResponse) Descriptor() ([]byte, []int) { return fileDescriptor_bccaa873af5af46c, []int{7} } + func (m *QueryNeuronBandwidthResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryNeuronBandwidthResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryNeuronBandwidthResponse.Marshal(b, m, deterministic) @@ -312,20 +349,22 @@ func (m *QueryNeuronBandwidthResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } + func (m *QueryNeuronBandwidthResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryNeuronBandwidthResponse.Merge(m, src) } + func (m *QueryNeuronBandwidthResponse) XXX_Size() int { return m.Size() } + func (m *QueryNeuronBandwidthResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryNeuronBandwidthResponse.DiscardUnknown(m) } var xxx_messageInfo_QueryNeuronBandwidthResponse proto.InternalMessageInfo -type QueryParamsRequest struct { -} +type QueryParamsRequest struct{} func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } @@ -333,9 +372,11 @@ func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_bccaa873af5af46c, []int{8} } + func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) @@ -348,12 +389,15 @@ func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryParamsRequest.Merge(m, src) } + func (m *QueryParamsRequest) XXX_Size() int { return m.Size() } + func (m *QueryParamsRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) } @@ -370,9 +414,11 @@ func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_bccaa873af5af46c, []int{9} } + func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) @@ -385,12 +431,15 @@ func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryParamsResponse.Merge(m, src) } + func (m *QueryParamsResponse) XXX_Size() int { return m.Size() } + func (m *QueryParamsResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) } @@ -458,8 +507,10 @@ var fileDescriptor_bccaa873af5af46c = []byte{ } // Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn +var ( + _ context.Context + _ grpc.ClientConn +) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. @@ -539,21 +590,24 @@ type QueryServer interface { } // UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} +type UnimplementedQueryServer struct{} func (*UnimplementedQueryServer) Load(ctx context.Context, req *QueryLoadRequest) (*QueryLoadResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Load not implemented") } + func (*UnimplementedQueryServer) Price(ctx context.Context, req *QueryPriceRequest) (*QueryPriceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Price not implemented") } + func (*UnimplementedQueryServer) TotalBandwidth(ctx context.Context, req *QueryTotalBandwidthRequest) (*QueryTotalBandwidthResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TotalBandwidth not implemented") } + func (*UnimplementedQueryServer) NeuronBandwidth(ctx context.Context, req *QueryNeuronBandwidthRequest) (*QueryNeuronBandwidthResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method NeuronBandwidth not implemented") } + func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } @@ -974,6 +1028,7 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *QueryLoadRequest) Size() (n int) { if m == nil { return 0 @@ -1082,9 +1137,11 @@ func (m *QueryParamsResponse) Size() (n int) { func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *QueryLoadRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1135,6 +1192,7 @@ func (m *QueryLoadRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryLoadResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1218,6 +1276,7 @@ func (m *QueryLoadResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryPriceRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1268,6 +1327,7 @@ func (m *QueryPriceRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryPriceResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1351,6 +1411,7 @@ func (m *QueryPriceResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryTotalBandwidthRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1401,6 +1462,7 @@ func (m *QueryTotalBandwidthRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryTotalBandwidthResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1470,6 +1532,7 @@ func (m *QueryTotalBandwidthResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryNeuronBandwidthRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1552,6 +1615,7 @@ func (m *QueryNeuronBandwidthRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryNeuronBandwidthResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1635,6 +1699,7 @@ func (m *QueryNeuronBandwidthResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1685,6 +1750,7 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1768,6 +1834,7 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } + func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/bandwidth/types/query.pb.gw.go b/x/bandwidth/types/query.pb.gw.go index b78613c..4da5bcd 100644 --- a/x/bandwidth/types/query.pb.gw.go +++ b/x/bandwidth/types/query.pb.gw.go @@ -24,12 +24,14 @@ import ( ) // Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = runtime.String + _ = utilities.NewDoubleArray + _ = descriptor.ForMessage +) func request_Query_Load_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryLoadRequest @@ -37,7 +39,6 @@ func request_Query_Load_0(ctx context.Context, marshaler runtime.Marshaler, clie msg, err := client.Load(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Load_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -46,7 +47,6 @@ func local_request_Query_Load_0(ctx context.Context, marshaler runtime.Marshaler msg, err := server.Load(ctx, &protoReq) return msg, metadata, err - } func request_Query_Price_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -55,7 +55,6 @@ func request_Query_Price_0(ctx context.Context, marshaler runtime.Marshaler, cli msg, err := client.Price(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Price_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -64,7 +63,6 @@ func local_request_Query_Price_0(ctx context.Context, marshaler runtime.Marshale msg, err := server.Price(ctx, &protoReq) return msg, metadata, err - } func request_Query_TotalBandwidth_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -73,7 +71,6 @@ func request_Query_TotalBandwidth_0(ctx context.Context, marshaler runtime.Marsh msg, err := client.TotalBandwidth(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_TotalBandwidth_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -82,7 +79,6 @@ func local_request_Query_TotalBandwidth_0(ctx context.Context, marshaler runtime msg, err := server.TotalBandwidth(ctx, &protoReq) return msg, metadata, err - } func request_Query_NeuronBandwidth_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -109,7 +105,6 @@ func request_Query_NeuronBandwidth_0(ctx context.Context, marshaler runtime.Mars msg, err := client.NeuronBandwidth(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_NeuronBandwidth_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -136,7 +131,6 @@ func local_request_Query_NeuronBandwidth_0(ctx context.Context, marshaler runtim msg, err := server.NeuronBandwidth(ctx, &protoReq) return msg, metadata, err - } func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -145,7 +139,6 @@ func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, cl msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -154,7 +147,6 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal msg, err := server.Params(ctx, &protoReq) return msg, metadata, err - } // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". @@ -162,7 +154,6 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_Load_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -180,7 +171,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Load_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Price_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -200,7 +190,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Price_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_TotalBandwidth_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -220,7 +209,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_TotalBandwidth_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_NeuronBandwidth_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -240,7 +228,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_NeuronBandwidth_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -260,7 +247,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) return nil @@ -303,7 +289,6 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_Load_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -321,7 +306,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Load_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Price_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -341,7 +325,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Price_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_TotalBandwidth_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -361,7 +344,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_TotalBandwidth_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_NeuronBandwidth_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -381,7 +363,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_NeuronBandwidth_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -401,7 +382,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) return nil diff --git a/x/bandwidth/types/types.pb.go b/x/bandwidth/types/types.pb.go index ceab8ca..f2a14a8 100644 --- a/x/bandwidth/types/types.pb.go +++ b/x/bandwidth/types/types.pb.go @@ -5,18 +5,21 @@ package types import ( fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" io "io" math "math" math_bits "math/bits" + + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -38,9 +41,11 @@ func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { return fileDescriptor_b76904de4f1717b1, []int{0} } + func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_Params.Marshal(b, m, deterministic) @@ -53,12 +58,15 @@ func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } + func (m *Params) XXX_Merge(src proto.Message) { xxx_messageInfo_Params.Merge(m, src) } + func (m *Params) XXX_Size() int { return m.Size() } + func (m *Params) XXX_DiscardUnknown() { xxx_messageInfo_Params.DiscardUnknown(m) } @@ -99,9 +107,11 @@ func (*NeuronBandwidth) ProtoMessage() {} func (*NeuronBandwidth) Descriptor() ([]byte, []int) { return fileDescriptor_b76904de4f1717b1, []int{1} } + func (m *NeuronBandwidth) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *NeuronBandwidth) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_NeuronBandwidth.Marshal(b, m, deterministic) @@ -114,12 +124,15 @@ func (m *NeuronBandwidth) XXX_Marshal(b []byte, deterministic bool) ([]byte, err return b[:n], nil } } + func (m *NeuronBandwidth) XXX_Merge(src proto.Message) { xxx_messageInfo_NeuronBandwidth.Merge(m, src) } + func (m *NeuronBandwidth) XXX_Size() int { return m.Size() } + func (m *NeuronBandwidth) XXX_DiscardUnknown() { xxx_messageInfo_NeuronBandwidth.DiscardUnknown(m) } @@ -136,9 +149,11 @@ func (*Price) ProtoMessage() {} func (*Price) Descriptor() ([]byte, []int) { return fileDescriptor_b76904de4f1717b1, []int{2} } + func (m *Price) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *Price) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_Price.Marshal(b, m, deterministic) @@ -151,12 +166,15 @@ func (m *Price) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } + func (m *Price) XXX_Merge(src proto.Message) { xxx_messageInfo_Price.Merge(m, src) } + func (m *Price) XXX_Size() int { return m.Size() } + func (m *Price) XXX_DiscardUnknown() { xxx_messageInfo_Price.DiscardUnknown(m) } @@ -241,6 +259,7 @@ func (this *Params) Equal(that interface{}) bool { } return true } + func (m *Params) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -388,6 +407,7 @@ func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *Params) Size() (n int) { if m == nil { return 0 @@ -446,9 +466,11 @@ func (m *Price) Size() (n int) { func sovTypes(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozTypes(x uint64) (n int) { return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *Params) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -624,6 +646,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } + func (m *NeuronBandwidth) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -763,6 +786,7 @@ func (m *NeuronBandwidth) Unmarshal(dAtA []byte) error { } return nil } + func (m *Price) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -847,6 +871,7 @@ func (m *Price) Unmarshal(dAtA []byte) error { } return nil } + func skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/bandwidth/wasm/interface.go b/x/bandwidth/wasm/interface.go index 9785c71..d442f75 100644 --- a/x/bandwidth/wasm/interface.go +++ b/x/bandwidth/wasm/interface.go @@ -29,8 +29,8 @@ func NewWasmQuerier(keeper *keeper.BandwidthMeter) WasmQuerier { func (WasmQuerier) Query(_ sdk.Context, _ wasmvmtypes.QueryRequest) ([]byte, error) { return nil, nil } type CosmosQuery struct { - BandwidthPrice *struct{} `json:"bandwidth_price,omitempty"` - BandwidthLoad *struct{} `json:"bandwidth_load,omitempty"` + BandwidthPrice *struct{} `json:"bandwidth_price,omitempty"` + BandwidthLoad *struct{} `json:"bandwidth_load,omitempty"` BandwidthTotal *struct{} `json:"bandwidth_total,omitempty"` NeuronBandwidth *QueryNeuronBandwidthParams `json:"neuron_bandwidth,omitempty"` } @@ -52,16 +52,15 @@ type BandwidthTotalResponse struct { } type NeuronBandwidthResponse struct { - Neuron string `json:"neuron"` - RemainedValue uint64 `json:"remained_value"` + Neuron string `json:"neuron"` + RemainedValue uint64 `json:"remained_value"` LastUpdatedBlock uint64 `json:"last_updated_block"` - MaxValue uint64 `json:"max_value"` + MaxValue uint64 `json:"max_value"` } func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) { var query CosmosQuery err := json.Unmarshal(data, &query) - if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } @@ -91,10 +90,10 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ accountBandwidth := querier.BandwidthMeter.GetCurrentAccountBandwidth(ctx, address) bz, err = json.Marshal(NeuronBandwidthResponse{ - Neuron: accountBandwidth.Neuron, - RemainedValue: accountBandwidth.RemainedValue, + Neuron: accountBandwidth.Neuron, + RemainedValue: accountBandwidth.RemainedValue, LastUpdatedBlock: accountBandwidth.LastUpdatedBlock, - MaxValue: accountBandwidth.MaxValue, + MaxValue: accountBandwidth.MaxValue, }) } else { return nil, wasmvmtypes.UnsupportedRequest{Kind: "unknown Bandwidth variant"} @@ -105,4 +104,4 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ } return bz, nil -} \ No newline at end of file +} diff --git a/x/cyberbank/abci.go b/x/cyberbank/abci.go index cb27777..91bb013 100644 --- a/x/cyberbank/abci.go +++ b/x/cyberbank/abci.go @@ -14,4 +14,4 @@ func EndBlocker(ctx sdk.Context, k *keeper.IndexedKeeper) { defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker) k.UpdateAccountsStakeAmpere(ctx) -} \ No newline at end of file +} diff --git a/x/cyberbank/keeper/keeper.go b/x/cyberbank/keeper/keeper.go index 7eeca3a..dca16cc 100644 --- a/x/cyberbank/keeper/keeper.go +++ b/x/cyberbank/keeper/keeper.go @@ -14,12 +14,11 @@ import ( "github.com/cybercongress/go-cyber/x/cyberbank/types" ) - type IndexedKeeper struct { *Proxy - accountKeeper types.AccountKeeper - cdc codec.BinaryCodec - authKey sdk.StoreKey + accountKeeper types.AccountKeeper + cdc codec.BinaryCodec + authKey sdk.StoreKey userTotalStakeAmpere map[uint64]uint64 userNewTotalStakeAmpere map[uint64]uint64 @@ -33,10 +32,10 @@ func NewIndexedKeeper( ak types.AccountKeeper, ) *IndexedKeeper { indexedKeeper := &IndexedKeeper{ - Proxy: pbk, - cdc: cdc, - authKey: authKey, - accountKeeper: ak, + Proxy: pbk, + cdc: cdc, + authKey: authKey, + accountKeeper: ak, accountToUpdate: make([]sdk.AccAddress, 0), } hook := func(ctx sdk.Context, from sdk.AccAddress, to sdk.AccAddress) { @@ -72,7 +71,7 @@ func (k *IndexedKeeper) getCollectFunc(ctx sdk.Context, userStake map[uint64]uin } } -func (k *IndexedKeeper) InitializeStakeAmpere(account uint64, stake uint64) { +func (k *IndexedKeeper) InitializeStakeAmpere(account uint64, stake uint64) { k.userTotalStakeAmpere[account] = stake k.userNewTotalStakeAmpere[account] = stake } @@ -116,11 +115,11 @@ func (k *IndexedKeeper) UpdateAccountsStakeAmpere(ctx sdk.Context) { nextAccountNumber := k.GetNextAccountNumber(ctx) if uint64(len(k.userNewTotalStakeAmpere)) != nextAccountNumber { startTime := time.Now() - for i := nextAccountNumber-1; i > 0; i-- { + for i := nextAccountNumber - 1; i > 0; i-- { if _, ok := k.userNewTotalStakeAmpere[i]; !ok { k.Logger(ctx).Info("added to stake index:", "account", i) // TODO update in next release - //stake := k.GetAccountTotalStakeAmper(ctx, addr) + // stake := k.GetAccountTotalStakeAmper(ctx, addr) k.userNewTotalStakeAmpere[i] = 0 } } @@ -149,4 +148,4 @@ func (k IndexedKeeper) GetNextAccountNumber(ctx sdk.Context) uint64 { } return accNumber -} \ No newline at end of file +} diff --git a/x/cyberbank/keeper/proxy.go b/x/cyberbank/keeper/proxy.go index 02e8ac5..ee0e1bb 100644 --- a/x/cyberbank/keeper/proxy.go +++ b/x/cyberbank/keeper/proxy.go @@ -26,7 +26,7 @@ type Proxy struct { func Wrap(bk bank.Keeper) *Proxy { return &Proxy{ - bk: bk, + bk: bk, coinsTransferHooks: make([]types.CoinsTransferHook, 0), } } @@ -66,7 +66,9 @@ func (p Proxy) GetAccountStakePercentageVolt(ctx sdk.Context, addr sdk.AccAddres c := aFloat / bFloat - if math.IsNaN(c) { return 0 } + if math.IsNaN(c) { + return 0 + } return c } @@ -274,11 +276,10 @@ func (p *Proxy) Params(ctx context.Context, request *banktypes.QueryParamsReques return p.bk.Params(ctx, request) } - func (p *Proxy) SpendableBalances(ctx context.Context, request *banktypes.QuerySpendableBalancesRequest) (*banktypes.QuerySpendableBalancesResponse, error) { return p.bk.SpendableBalances(ctx, request) } func (p *Proxy) HasSupply(ctx sdk.Context, denom string) bool { return p.bk.HasSupply(ctx, denom) -} \ No newline at end of file +} diff --git a/x/cyberbank/module.go b/x/cyberbank/module.go index bb893f9..b5ff5a3 100644 --- a/x/cyberbank/module.go +++ b/x/cyberbank/module.go @@ -21,11 +21,11 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} ) -type AppModuleBasic struct{ +type AppModuleBasic struct { cdc codec.Codec } @@ -54,7 +54,7 @@ func (AppModuleBasic) RegisterInterfaces(_ codectypes.InterfaceRegistry) {} type AppModule struct { AppModuleBasic - keeper *keeper.IndexedKeeper + keeper *keeper.IndexedKeeper } func NewAppModule( @@ -97,4 +97,4 @@ func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { EndBlocker(ctx, am.keeper) return []abci.ValidatorUpdate{} -} \ No newline at end of file +} diff --git a/x/cyberbank/types/expected_keepers.go b/x/cyberbank/types/expected_keepers.go index 566560d..56e0a5d 100644 --- a/x/cyberbank/types/expected_keepers.go +++ b/x/cyberbank/types/expected_keepers.go @@ -5,7 +5,6 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) - type AccountKeeper interface { IterateAccounts(ctx sdk.Context, process func(i authtypes.AccountI) (stop bool)) GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI @@ -14,4 +13,4 @@ type AccountKeeper interface { type EnergyKeeper interface { GetRoutedToEnergy(ctx sdk.Context, delegate sdk.AccAddress) sdk.Coins -} \ No newline at end of file +} diff --git a/x/cyberbank/types/keys.go b/x/cyberbank/types/keys.go index 0a44eef..890b257 100644 --- a/x/cyberbank/types/keys.go +++ b/x/cyberbank/types/keys.go @@ -1,5 +1,5 @@ package types const ( - ModuleName = "cyberbank" -) \ No newline at end of file + ModuleName = "cyberbank" +) diff --git a/x/dmn/client/cli/query.go b/x/dmn/client/cli/query.go index 3a50470..c46d5d7 100644 --- a/x/dmn/client/cli/query.go +++ b/x/dmn/client/cli/query.go @@ -66,7 +66,7 @@ func GetCmdQueryThought() *cobra.Command { cmd := &cobra.Command{ Use: "thought [program] [name]", Short: "Query thought", - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -85,7 +85,6 @@ func GetCmdQueryThought() *cobra.Command { program.String(), args[1], }, ) - if err != nil { return err } @@ -103,7 +102,7 @@ func GetCmdQueryThoughtStats() *cobra.Command { cmd := &cobra.Command{ Use: "thought-stats [program] [name]", Short: "Query thought stats", - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -122,7 +121,6 @@ func GetCmdQueryThoughtStats() *cobra.Command { program.String(), args[1], }, ) - if err != nil { return err } @@ -137,10 +135,10 @@ func GetCmdQueryThoughtStats() *cobra.Command { } func GetCmdQueryThoughts() *cobra.Command { - cmd := &cobra.Command{ + cmd := &cobra.Command{ Use: "thoughts", Short: "Query all thoughts", - Args: cobra.ExactArgs(0), + Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -152,7 +150,6 @@ func GetCmdQueryThoughts() *cobra.Command { context.Background(), &types.QueryThoughtsRequest{}, ) - if err != nil { return err } @@ -167,10 +164,10 @@ func GetCmdQueryThoughts() *cobra.Command { } func GetCmdQueryThoughtsStats() *cobra.Command { - cmd := &cobra.Command{ + cmd := &cobra.Command{ Use: "thoughts-stats", Short: "Query all thoughts stats", - Args: cobra.ExactArgs(0), + Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -182,7 +179,6 @@ func GetCmdQueryThoughtsStats() *cobra.Command { context.Background(), &types.QueryThoughtsStatsRequest{}, ) - if err != nil { return err } @@ -195,4 +191,3 @@ func GetCmdQueryThoughtsStats() *cobra.Command { return cmd } - diff --git a/x/dmn/client/rest/query.go b/x/dmn/client/rest/query.go index 4fc1a27..43a9bda 100644 --- a/x/dmn/client/rest/query.go +++ b/x/dmn/client/rest/query.go @@ -38,7 +38,6 @@ func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { func queryParamsHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryParams) res, _, err := cliCtx.QueryWithData(route, nil) @@ -53,7 +52,6 @@ func queryParamsHandlerFn(cliCtx client.Context) http.HandlerFunc { func queryThoughtHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) name := vars[Name] @@ -97,7 +95,6 @@ func queryThoughtHandlerFn(cliCtx client.Context) http.HandlerFunc { func queryThoughtStatsHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) name := vars[Name] @@ -140,7 +137,6 @@ func queryThoughtStatsHandlerFn(cliCtx client.Context) http.HandlerFunc { func queryThoughtsHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryThoughts) res, height, err := cliCtx.QueryWithData(route, nil) @@ -161,7 +157,6 @@ func queryThoughtsHandlerFn(cliCtx client.Context) http.HandlerFunc { func queryThoughtsStatsHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryThoughtsStats) res, height, err := cliCtx.QueryWithData(route, nil) @@ -178,4 +173,4 @@ func queryThoughtsStatsHandlerFn(cliCtx client.Context) http.HandlerFunc { cliCtx = cliCtx.WithHeight(height) rest.PostProcessResponse(w, cliCtx, res) } -} \ No newline at end of file +} diff --git a/x/dmn/client/rest/rest.go b/x/dmn/client/rest/rest.go index 1cbef67..108f24d 100644 --- a/x/dmn/client/rest/rest.go +++ b/x/dmn/client/rest/rest.go @@ -6,11 +6,11 @@ import ( ) const ( - Program = "program" - Name = "name" + Program = "program" + Name = "name" ) // RegisterRoutes registers power-related REST handlers to a router func RegisterRoutes(cliCtx client.Context, r *mux.Router) { registerQueryRoutes(cliCtx, r) -} \ No newline at end of file +} diff --git a/x/dmn/keeper/genesis.go b/x/dmn/keeper/genesis.go index 5d7ea18..86e0ed2 100644 --- a/x/dmn/keeper/genesis.go +++ b/x/dmn/keeper/genesis.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cybercongress/go-cyber/x/dmn/types" ) @@ -9,7 +10,7 @@ func InitGenesis(ctx sdk.Context, k Keeper, data types.GenesisState) { k.SetParams(ctx, data.Params) } -func ExportGenesis(ctx sdk.Context, k Keeper) *types.GenesisState { +func ExportGenesis(ctx sdk.Context, k Keeper) *types.GenesisState { params := k.GetParams(ctx) return types.NewGenesisState(params) diff --git a/x/dmn/keeper/grpc_query.go b/x/dmn/keeper/grpc_query.go index 1014cdb..1c5d0ac 100644 --- a/x/dmn/keeper/grpc_query.go +++ b/x/dmn/keeper/grpc_query.go @@ -89,4 +89,4 @@ func (k Keeper) ThoughtsStats(goCtx context.Context, _ *types.QueryThoughtsStats thoughtsStats := k.GetAllThoughtsStats(ctx) return &types.QueryThoughtsStatsResponse{ThoughtsStats: thoughtsStats}, nil -} \ No newline at end of file +} diff --git a/x/dmn/keeper/keeper.go b/x/dmn/keeper/keeper.go index b4a3c1f..801eb75 100644 --- a/x/dmn/keeper/keeper.go +++ b/x/dmn/keeper/keeper.go @@ -1,10 +1,9 @@ package keeper import ( - "fmt" - - "encoding/hex" "encoding/base64" + "encoding/hex" + "fmt" "github.com/CosmWasm/wasmd/x/wasm" "github.com/cosmos/cosmos-sdk/telemetry" @@ -26,7 +25,7 @@ import ( type Keeper struct { storeKey sdk.StoreKey cdc codec.BinaryCodec - wasmKeeper wasm.Keeper + wasmKeeper wasm.Keeper accountKeeper types.AccountKeeper proxyKeeper types.BankKeeper paramspace paramstypes.Subspace @@ -35,21 +34,20 @@ type Keeper struct { func NewKeeper( cdc codec.BinaryCodec, key sdk.StoreKey, - bk types.BankKeeper, - ak types.AccountKeeper, + bk types.BankKeeper, + ak types.AccountKeeper, paramSpace paramstypes.Subspace, ) *Keeper { - if !paramSpace.HasKeyTable() { paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) } return &Keeper{ - storeKey: key, - cdc: cdc, + storeKey: key, + cdc: cdc, proxyKeeper: bk, accountKeeper: ak, - paramspace: paramSpace, + paramspace: paramSpace, } } @@ -75,7 +73,6 @@ func (k Keeper) SaveThought( trigger types.Trigger, load types.Load, name string, particle graphtypes.Cid, ) error { - if trigger.Block != 0 && ctx.BlockHeight() > int64(trigger.Block) { return types.ErrBadTrigger } @@ -103,7 +100,7 @@ func (k Keeper) SaveThought( k.SetThoughtStats(ctx, program, name, types.NewStats( program.String(), name, - 0,0, 0, uint64(ctx.BlockHeight()), + 0, 0, 0, uint64(ctx.BlockHeight()), ), ) @@ -169,7 +166,7 @@ func (k Keeper) UpdateThoughtName( types.NewStats( program.String(), nameNew, thoughtStats.Calls, thoughtStats.Fees, thoughtStats.Fees, thoughtStats.LastBlock, - )) + )) return nil } @@ -258,10 +255,8 @@ func (k Keeper) UpdateThoughtBlock( return nil } - //______________________________________________________________________ - func (k Keeper) MaxThougths(ctx sdk.Context) (res uint32) { k.paramspace.Get(ctx, types.KeyMaxSlots, &res) return @@ -441,7 +436,7 @@ func (k Keeper) ExecuteThoughtsQueue(ctx sdk.Context) { price := thought.Load.GasPrice k.Logger(ctx).Info("Started thought", "number", i, "gas price", price) - thoughtsTriggered = thoughtsTriggered +1 + thoughtsTriggered = thoughtsTriggered + 1 cacheContext, writeFn := ctx.CacheContext() cacheContext = cacheContext.WithGasMeter(sdk.NewGasMeter(sdk.Gas(maxGasPerThought))) @@ -463,7 +458,7 @@ func (k Keeper) ExecuteThoughtsQueue(ctx sdk.Context) { gasUsedByThought := cacheContext.GasMeter().GasConsumed() ctx.GasMeter().ConsumeGas(gasUsedByThought, "thought execution") - if gasUsedTotal +gasUsedByThought > uint64(maxGas) { + if gasUsedTotal+gasUsedByThought > uint64(maxGas) { break } else { gasUsedTotal += gasUsedByThought @@ -472,7 +467,7 @@ func (k Keeper) ExecuteThoughtsQueue(ctx sdk.Context) { js, _ := k.GetThoughtStats(ctx, program, thought.Name) // TODO move to more advanced fee system, 10X fee reducer applied (min 0.1 per gas) amtGasFee := price.Amount.Int64() * int64(gasUsedByThought) / 10 - amtTTLFee := (ctx.BlockHeight() - int64(js.LastBlock))*int64(feeTTL) + amtTTLFee := (ctx.BlockHeight() - int64(js.LastBlock)) * int64(feeTTL) amtTotalFee := amtGasFee + amtTTLFee k.Logger(ctx).Info("Gas thought execution stats", @@ -542,11 +537,13 @@ func (k Keeper) executeThoughtWithSudo(ctx sdk.Context, program sdk.AccAddress, telemetry.IncrCounter(1.0, types.ModuleName, "thought") }() - callData, berr := base64.StdEncoding.DecodeString(msg); if berr != nil { + callData, berr := base64.StdEncoding.DecodeString(msg) + if berr != nil { // TODO remove hex later as deprecated - _, herr := hex.DecodeString(msg); if herr != nil { + _, herr := hex.DecodeString(msg) + if herr != nil { return nil, types.ErrBadCallData } } return k.wasmKeeper.Sudo(ctx, program, callData) -} \ No newline at end of file +} diff --git a/x/dmn/keeper/msg_server.go b/x/dmn/keeper/msg_server.go index f207fb4..90234d4 100644 --- a/x/dmn/keeper/msg_server.go +++ b/x/dmn/keeper/msg_server.go @@ -233,4 +233,4 @@ func (k msgServer) ChangeThoughtBlock(goCtx context.Context, msg *types.MsgChang }) return &types.MsgChangeThoughtBlockResponse{}, nil -} \ No newline at end of file +} diff --git a/x/dmn/keeper/querier.go b/x/dmn/keeper/querier.go index fe2bd61..f08c7f7 100644 --- a/x/dmn/keeper/querier.go +++ b/x/dmn/keeper/querier.go @@ -4,8 +4,9 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cybercongress/go-cyber/x/dmn/types" abci "github.com/tendermint/tendermint/abci/types" + + "github.com/cybercongress/go-cyber/x/dmn/types" ) func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { @@ -41,7 +42,8 @@ func queryParams(ctx sdk.Context, k Keeper, legacyQuerierCdc *codec.LegacyAmino) func queryThought(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QueryThoughtParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); if err != nil { + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } @@ -61,7 +63,8 @@ func queryThought(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerie func queryThoughtStats(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QueryThoughtParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); if err != nil { + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } diff --git a/x/dmn/module.go b/x/dmn/module.go index ce06a7d..f4b3cae 100644 --- a/x/dmn/module.go +++ b/x/dmn/module.go @@ -29,7 +29,7 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -type AppModuleBasic struct{ +type AppModuleBasic struct { cdc codec.Codec } @@ -43,7 +43,8 @@ func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { var data types.GenesisState - err := cdc.UnmarshalJSON(bz, &data); if err != nil { + err := cdc.UnmarshalJSON(bz, &data) + if err != nil { return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) } return types.ValidateGenesis(data) @@ -72,15 +73,15 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) type AppModule struct { AppModuleBasic - keeper keeper.Keeper + keeper keeper.Keeper } func NewAppModule( cdc codec.Codec, k keeper.Keeper, ) AppModule { return AppModule{ - AppModuleBasic: AppModuleBasic{cdc: cdc}, - keeper: k, + AppModuleBasic: AppModuleBasic{cdc: cdc}, + keeper: k, } } diff --git a/x/dmn/types/errors.go b/x/dmn/types/errors.go index 551af66..5ce363b 100644 --- a/x/dmn/types/errors.go +++ b/x/dmn/types/errors.go @@ -8,7 +8,7 @@ var ( ErrBadCallData = sdkerrors.Register(ModuleName, 4, "bad call data") ErrBadGasPrice = sdkerrors.Register(ModuleName, 5, "bad gas price") ErrBadTrigger = sdkerrors.Register(ModuleName, 6, "bad trigger") - ErrBadName = sdkerrors.Register(ModuleName, 7, "bad name") + ErrBadName = sdkerrors.Register(ModuleName, 7, "bad name") ErrThoughtNotExist = sdkerrors.Register(ModuleName, 8, "thought does not exist") ErrConvertTrigger = sdkerrors.Register(ModuleName, 9, "cannot convert trigger") ) diff --git a/x/dmn/types/events.go b/x/dmn/types/events.go index 5421963..ffa8a70 100644 --- a/x/dmn/types/events.go +++ b/x/dmn/types/events.go @@ -12,7 +12,7 @@ const ( AttributeKeyThoughtProgram = "program" AttributeKeyThoughtTrigger = "trigger" - AttributeKeyThoughtLoad = "load" + AttributeKeyThoughtLoad = "load" AttributeKeyThoughtName = "name" AttributeKeyThoughtParticle = "particle" AttributeKeyThoughtInput = "input" @@ -20,5 +20,5 @@ const ( AttributeKeyThoughtPeriod = "period" AttributeKeyThoughtBlock = "block" - AttributeValueCategory = ModuleName + AttributeValueCategory = ModuleName ) diff --git a/x/dmn/types/expected_keepers.go b/x/dmn/types/expected_keepers.go index b7d4818..4b21558 100644 --- a/x/dmn/types/expected_keepers.go +++ b/x/dmn/types/expected_keepers.go @@ -12,4 +12,4 @@ type BankKeeper interface { type AccountKeeper interface { GetModuleAddress(name string) sdk.AccAddress -} \ No newline at end of file +} diff --git a/x/dmn/types/genesis.go b/x/dmn/types/genesis.go index 7d78804..5d2dc70 100644 --- a/x/dmn/types/genesis.go +++ b/x/dmn/types/genesis.go @@ -2,7 +2,7 @@ package types func NewGenesisState(params Params) *GenesisState { return &GenesisState{ - Params: params, + Params: params, } } diff --git a/x/dmn/types/genesis.pb.go b/x/dmn/types/genesis.pb.go index 9a92f01..d99c547 100644 --- a/x/dmn/types/genesis.pb.go +++ b/x/dmn/types/genesis.pb.go @@ -5,17 +5,20 @@ package types import ( fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -33,9 +36,11 @@ func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { return fileDescriptor_3d0e09d4ad24cea5, []int{0} } + func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) @@ -48,12 +53,15 @@ func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } + func (m *GenesisState) XXX_Merge(src proto.Message) { xxx_messageInfo_GenesisState.Merge(m, src) } + func (m *GenesisState) XXX_Size() int { return m.Size() } + func (m *GenesisState) XXX_DiscardUnknown() { xxx_messageInfo_GenesisState.DiscardUnknown(m) } @@ -134,6 +142,7 @@ func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *GenesisState) Size() (n int) { if m == nil { return 0 @@ -148,9 +157,11 @@ func (m *GenesisState) Size() (n int) { func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozGenesis(x uint64) (n int) { return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *GenesisState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -234,6 +245,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } return nil } + func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/dmn/types/keys.go b/x/dmn/types/keys.go index ba31235..f155f9a 100644 --- a/x/dmn/types/keys.go +++ b/x/dmn/types/keys.go @@ -3,15 +3,15 @@ package types import sdk "github.com/cosmos/cosmos-sdk/types" const ( - ModuleName = "dmn" - StoreKey = ModuleName - RouterKey = ModuleName - QuerierRoute = ModuleName + ModuleName = "dmn" + StoreKey = ModuleName + RouterKey = ModuleName + QuerierRoute = ModuleName ) var ( - ThoughtKey = []byte{0x00} - ThoughtStatsKey = []byte{0x01} + ThoughtKey = []byte{0x00} + ThoughtStatsKey = []byte{0x01} ) func GetThoughtKey(program sdk.AccAddress, name string) []byte { @@ -23,4 +23,3 @@ func GetThoughtStatsKey(program sdk.AccAddress, name string) []byte { key := append(program.Bytes(), []byte(name)...) return append(ThoughtStatsKey, key...) } - diff --git a/x/dmn/types/msgs.go b/x/dmn/types/msgs.go index a7e3b08..236de9b 100644 --- a/x/dmn/types/msgs.go +++ b/x/dmn/types/msgs.go @@ -5,16 +5,16 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ipfs/go-cid" - //sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + // sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cybercongress/go-cyber/types" graph "github.com/cybercongress/go-cyber/x/graph/types" ) const ( - TypeMsgCreateThought = "create_thought" - TypeMsgForgetThought = "forget_thought" - TypeMsgChangeThoughtName = "change_thought_name" + TypeMsgCreateThought = "create_thought" + TypeMsgForgetThought = "forget_thought" + TypeMsgChangeThoughtName = "change_thought_name" TypeMsgChangeThoughtParticle = "change_thought_particle" TypeMsgChangeThoughtInput = "change_thought_input" TypeMsgChangeThoughtGasPrice = "change_thought_gas_price" @@ -40,7 +40,7 @@ func NewMsgCreateThought( func (msg MsgCreateThought) Route() string { return RouterKey } -func (msg MsgCreateThought) Type() string { return TypeMsgCreateThought } +func (msg MsgCreateThought) Type() string { return TypeMsgCreateThought } func (msg MsgCreateThought) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Program) @@ -56,10 +56,10 @@ func (msg MsgCreateThought) ValidateBasic() error { if !msg.Load.GasPrice.Amount.IsPositive() { return ErrBadGasPrice } - if (msg.Trigger.Period == 0 && msg.Trigger.Block == 0) { + if msg.Trigger.Period == 0 && msg.Trigger.Block == 0 { return ErrBadTrigger } - if (msg.Trigger.Period > 0 && msg.Trigger.Block > 0) { + if msg.Trigger.Period > 0 && msg.Trigger.Block > 0 { return ErrBadTrigger } if msg.Name == "" || len(msg.Name) > 32 { @@ -93,14 +93,14 @@ func (msg MsgCreateThought) GetSigners() []sdk.AccAddress { func NewMsgForgetThought(program sdk.AccAddress, label string) *MsgForgetThought { return &MsgForgetThought{ - Program: program.String(), - Name: label, + Program: program.String(), + Name: label, } } func (msg MsgForgetThought) Route() string { return RouterKey } -func (msg MsgForgetThought) Type() string { return TypeMsgForgetThought } +func (msg MsgForgetThought) Type() string { return TypeMsgForgetThought } func (msg MsgForgetThought) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Program) @@ -132,9 +132,9 @@ func NewMsgChangeThoughtName( name, newName string, ) *MsgChangeThoughtName { return &MsgChangeThoughtName{ - Program: program.String(), - Name: name, - NewName: newName, + Program: program.String(), + Name: name, + NewName: newName, } } @@ -176,8 +176,8 @@ func NewMsgChangeThoughtParticle( cid string, ) *MsgChangeThoughtParticle { return &MsgChangeThoughtParticle{ - Program: program.String(), - Name: label, + Program: program.String(), + Name: label, Particle: cid, } } @@ -269,7 +269,7 @@ func NewMsgChangeThoughtGasPrice( ) *MsgChangeThoughtGasPrice { return &MsgChangeThoughtGasPrice{ Program: program.String(), - Name : name, + Name: name, GasPrice: gasprice, } } @@ -315,9 +315,9 @@ func NewMsgChangeThoughtPeriod( period uint64, ) *MsgChangeThoughtPeriod { return &MsgChangeThoughtPeriod{ - Program: program.String(), - Name: name, - Period: period, + Program: program.String(), + Name: name, + Period: period, } } @@ -359,9 +359,9 @@ func NewMsgChangeThoughtBlock( block uint64, ) *MsgChangeThoughtBlock { return &MsgChangeThoughtBlock{ - Program: program.String(), - Name : name, - Block: block, + Program: program.String(), + Name: name, + Block: block, } } diff --git a/x/dmn/types/params.go b/x/dmn/types/params.go index 4a31df6..8db02e4 100644 --- a/x/dmn/types/params.go +++ b/x/dmn/types/params.go @@ -9,15 +9,15 @@ import ( const ( DefaultParamspace = ModuleName - DefaultMaxSlots uint32 = 4 - DefaultMaxGas uint32 = 2000000 - DefaultFeeTTL uint32 = 50 + DefaultMaxSlots uint32 = 4 + DefaultMaxGas uint32 = 2000000 + DefaultFeeTTL uint32 = 50 ) var ( - KeyMaxSlots = []byte("MaxSlots") - KeyMaxGas = []byte("MaxGas") - KeyFeeTTL = []byte("FeeTTL") + KeyMaxSlots = []byte("MaxSlots") + KeyMaxGas = []byte("MaxGas") + KeyFeeTTL = []byte("FeeTTL") ) func ParamKeyTable() paramstypes.KeyTable { @@ -40,7 +40,6 @@ func (p *Params) ParamSetPairs() paramstypes.ParamSetPairs { } } - func validateMaxSlots(i interface{}) error { v, ok := i.(uint32) if !ok { diff --git a/x/dmn/types/querier.go b/x/dmn/types/querier.go index f609e33..85bcabc 100644 --- a/x/dmn/types/querier.go +++ b/x/dmn/types/querier.go @@ -3,7 +3,7 @@ package types import sdk "github.com/cosmos/cosmos-sdk/types" const ( - QueryParams = "params" + QueryParams = "params" QueryThought = "thought" QueryThoughtStats = "thought_stats" QueryThoughts = "thoughts" @@ -17,4 +17,4 @@ type QueryThoughtParams struct { func NewQueryThoughtParams(program sdk.AccAddress, name string) QueryThoughtParams { return QueryThoughtParams{program, name} -} \ No newline at end of file +} diff --git a/x/dmn/types/query.pb.go b/x/dmn/types/query.pb.go index b8bb166..4d051e7 100644 --- a/x/dmn/types/query.pb.go +++ b/x/dmn/types/query.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -13,15 +17,14 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -29,8 +32,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type QueryParamsRequest struct { -} +type QueryParamsRequest struct{} func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } @@ -38,9 +40,11 @@ func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_55109069a1b1f260, []int{0} } + func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) @@ -53,12 +57,15 @@ func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryParamsRequest.Merge(m, src) } + func (m *QueryParamsRequest) XXX_Size() int { return m.Size() } + func (m *QueryParamsRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) } @@ -75,9 +82,11 @@ func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_55109069a1b1f260, []int{1} } + func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) @@ -90,12 +99,15 @@ func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryParamsResponse.Merge(m, src) } + func (m *QueryParamsResponse) XXX_Size() int { return m.Size() } + func (m *QueryParamsResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) } @@ -113,9 +125,11 @@ func (*QueryThoughtParamsRequest) ProtoMessage() {} func (*QueryThoughtParamsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_55109069a1b1f260, []int{2} } + func (m *QueryThoughtParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryThoughtParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryThoughtParamsRequest.Marshal(b, m, deterministic) @@ -128,12 +142,15 @@ func (m *QueryThoughtParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } + func (m *QueryThoughtParamsRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryThoughtParamsRequest.Merge(m, src) } + func (m *QueryThoughtParamsRequest) XXX_Size() int { return m.Size() } + func (m *QueryThoughtParamsRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryThoughtParamsRequest.DiscardUnknown(m) } @@ -150,9 +167,11 @@ func (*QueryThoughtResponse) ProtoMessage() {} func (*QueryThoughtResponse) Descriptor() ([]byte, []int) { return fileDescriptor_55109069a1b1f260, []int{3} } + func (m *QueryThoughtResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryThoughtResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryThoughtResponse.Marshal(b, m, deterministic) @@ -165,12 +184,15 @@ func (m *QueryThoughtResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte return b[:n], nil } } + func (m *QueryThoughtResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryThoughtResponse.Merge(m, src) } + func (m *QueryThoughtResponse) XXX_Size() int { return m.Size() } + func (m *QueryThoughtResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryThoughtResponse.DiscardUnknown(m) } @@ -187,9 +209,11 @@ func (*QueryThoughtStatsResponse) ProtoMessage() {} func (*QueryThoughtStatsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_55109069a1b1f260, []int{4} } + func (m *QueryThoughtStatsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryThoughtStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryThoughtStatsResponse.Marshal(b, m, deterministic) @@ -202,20 +226,22 @@ func (m *QueryThoughtStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } + func (m *QueryThoughtStatsResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryThoughtStatsResponse.Merge(m, src) } + func (m *QueryThoughtStatsResponse) XXX_Size() int { return m.Size() } + func (m *QueryThoughtStatsResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryThoughtStatsResponse.DiscardUnknown(m) } var xxx_messageInfo_QueryThoughtStatsResponse proto.InternalMessageInfo -type QueryThoughtsRequest struct { -} +type QueryThoughtsRequest struct{} func (m *QueryThoughtsRequest) Reset() { *m = QueryThoughtsRequest{} } func (m *QueryThoughtsRequest) String() string { return proto.CompactTextString(m) } @@ -223,9 +249,11 @@ func (*QueryThoughtsRequest) ProtoMessage() {} func (*QueryThoughtsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_55109069a1b1f260, []int{5} } + func (m *QueryThoughtsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryThoughtsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryThoughtsRequest.Marshal(b, m, deterministic) @@ -238,12 +266,15 @@ func (m *QueryThoughtsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte return b[:n], nil } } + func (m *QueryThoughtsRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryThoughtsRequest.Merge(m, src) } + func (m *QueryThoughtsRequest) XXX_Size() int { return m.Size() } + func (m *QueryThoughtsRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryThoughtsRequest.DiscardUnknown(m) } @@ -260,9 +291,11 @@ func (*QueryThoughtsResponse) ProtoMessage() {} func (*QueryThoughtsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_55109069a1b1f260, []int{6} } + func (m *QueryThoughtsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryThoughtsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryThoughtsResponse.Marshal(b, m, deterministic) @@ -275,20 +308,22 @@ func (m *QueryThoughtsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } + func (m *QueryThoughtsResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryThoughtsResponse.Merge(m, src) } + func (m *QueryThoughtsResponse) XXX_Size() int { return m.Size() } + func (m *QueryThoughtsResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryThoughtsResponse.DiscardUnknown(m) } var xxx_messageInfo_QueryThoughtsResponse proto.InternalMessageInfo -type QueryThoughtsStatsRequest struct { -} +type QueryThoughtsStatsRequest struct{} func (m *QueryThoughtsStatsRequest) Reset() { *m = QueryThoughtsStatsRequest{} } func (m *QueryThoughtsStatsRequest) String() string { return proto.CompactTextString(m) } @@ -296,9 +331,11 @@ func (*QueryThoughtsStatsRequest) ProtoMessage() {} func (*QueryThoughtsStatsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_55109069a1b1f260, []int{7} } + func (m *QueryThoughtsStatsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryThoughtsStatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryThoughtsStatsRequest.Marshal(b, m, deterministic) @@ -311,12 +348,15 @@ func (m *QueryThoughtsStatsRequest) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } + func (m *QueryThoughtsStatsRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryThoughtsStatsRequest.Merge(m, src) } + func (m *QueryThoughtsStatsRequest) XXX_Size() int { return m.Size() } + func (m *QueryThoughtsStatsRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryThoughtsStatsRequest.DiscardUnknown(m) } @@ -333,9 +373,11 @@ func (*QueryThoughtsStatsResponse) ProtoMessage() {} func (*QueryThoughtsStatsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_55109069a1b1f260, []int{8} } + func (m *QueryThoughtsStatsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryThoughtsStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryThoughtsStatsResponse.Marshal(b, m, deterministic) @@ -348,12 +390,15 @@ func (m *QueryThoughtsStatsResponse) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } + func (m *QueryThoughtsStatsResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryThoughtsStatsResponse.Merge(m, src) } + func (m *QueryThoughtsStatsResponse) XXX_Size() int { return m.Size() } + func (m *QueryThoughtsStatsResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryThoughtsStatsResponse.DiscardUnknown(m) } @@ -415,8 +460,10 @@ var fileDescriptor_55109069a1b1f260 = []byte{ } // Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn +var ( + _ context.Context + _ grpc.ClientConn +) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. @@ -496,21 +543,24 @@ type QueryServer interface { } // UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} +type UnimplementedQueryServer struct{} func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } + func (*UnimplementedQueryServer) Thought(ctx context.Context, req *QueryThoughtParamsRequest) (*QueryThoughtResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Thought not implemented") } + func (*UnimplementedQueryServer) ThoughtStats(ctx context.Context, req *QueryThoughtParamsRequest) (*QueryThoughtStatsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ThoughtStats not implemented") } + func (*UnimplementedQueryServer) Thoughts(ctx context.Context, req *QueryThoughtsRequest) (*QueryThoughtsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Thoughts not implemented") } + func (*UnimplementedQueryServer) ThoughtsStats(ctx context.Context, req *QueryThoughtsStatsRequest) (*QueryThoughtsStatsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ThoughtsStats not implemented") } @@ -928,6 +978,7 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *QueryParamsRequest) Size() (n int) { if m == nil { return 0 @@ -1038,9 +1089,11 @@ func (m *QueryThoughtsStatsResponse) Size() (n int) { func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1091,6 +1144,7 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1174,6 +1228,7 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryThoughtParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1288,6 +1343,7 @@ func (m *QueryThoughtParamsRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryThoughtResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1371,6 +1427,7 @@ func (m *QueryThoughtResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryThoughtStatsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1454,6 +1511,7 @@ func (m *QueryThoughtStatsResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryThoughtsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1504,6 +1562,7 @@ func (m *QueryThoughtsRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryThoughtsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1588,6 +1647,7 @@ func (m *QueryThoughtsResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryThoughtsStatsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1638,6 +1698,7 @@ func (m *QueryThoughtsStatsRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryThoughtsStatsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1722,6 +1783,7 @@ func (m *QueryThoughtsStatsResponse) Unmarshal(dAtA []byte) error { } return nil } + func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/dmn/types/query.pb.gw.go b/x/dmn/types/query.pb.gw.go index 1ac8951..0ead8ae 100644 --- a/x/dmn/types/query.pb.gw.go +++ b/x/dmn/types/query.pb.gw.go @@ -24,12 +24,14 @@ import ( ) // Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = runtime.String + _ = utilities.NewDoubleArray + _ = descriptor.ForMessage +) func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -37,7 +39,6 @@ func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, cl msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -46,12 +47,9 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal msg, err := server.Params(ctx, &protoReq) return msg, metadata, err - } -var ( - filter_Query_Thought_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) +var filter_Query_Thought_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_Query_Thought_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryThoughtParamsRequest @@ -66,7 +64,6 @@ func request_Query_Thought_0(ctx context.Context, marshaler runtime.Marshaler, c msg, err := client.Thought(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Thought_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -82,12 +79,9 @@ func local_request_Query_Thought_0(ctx context.Context, marshaler runtime.Marsha msg, err := server.Thought(ctx, &protoReq) return msg, metadata, err - } -var ( - filter_Query_ThoughtStats_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) +var filter_Query_ThoughtStats_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_Query_ThoughtStats_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryThoughtParamsRequest @@ -102,7 +96,6 @@ func request_Query_ThoughtStats_0(ctx context.Context, marshaler runtime.Marshal msg, err := client.ThoughtStats(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_ThoughtStats_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -118,7 +111,6 @@ func local_request_Query_ThoughtStats_0(ctx context.Context, marshaler runtime.M msg, err := server.ThoughtStats(ctx, &protoReq) return msg, metadata, err - } func request_Query_Thoughts_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -127,7 +119,6 @@ func request_Query_Thoughts_0(ctx context.Context, marshaler runtime.Marshaler, msg, err := client.Thoughts(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Thoughts_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -136,7 +127,6 @@ func local_request_Query_Thoughts_0(ctx context.Context, marshaler runtime.Marsh msg, err := server.Thoughts(ctx, &protoReq) return msg, metadata, err - } func request_Query_ThoughtsStats_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -145,7 +135,6 @@ func request_Query_ThoughtsStats_0(ctx context.Context, marshaler runtime.Marsha msg, err := client.ThoughtsStats(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_ThoughtsStats_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -154,7 +143,6 @@ func local_request_Query_ThoughtsStats_0(ctx context.Context, marshaler runtime. msg, err := server.ThoughtsStats(ctx, &protoReq) return msg, metadata, err - } // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". @@ -162,7 +150,6 @@ func local_request_Query_ThoughtsStats_0(ctx context.Context, marshaler runtime. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -180,7 +167,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Thought_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -200,7 +186,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Thought_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_ThoughtStats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -220,7 +205,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_ThoughtStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Thoughts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -240,7 +224,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Thoughts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_ThoughtsStats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -260,7 +243,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_ThoughtsStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) return nil @@ -303,7 +285,6 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -321,7 +302,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Thought_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -341,7 +321,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Thought_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_ThoughtStats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -361,7 +340,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_ThoughtStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Thoughts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -381,7 +359,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Thoughts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_ThoughtsStats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -401,7 +378,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_ThoughtsStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) return nil diff --git a/x/dmn/types/thought.go b/x/dmn/types/thought.go index edb695c..9548167 100644 --- a/x/dmn/types/thought.go +++ b/x/dmn/types/thought.go @@ -17,7 +17,7 @@ func NewThought( Program: program, Trigger: trigger, Load: load, - Name : name, + Name: name, Particle: particle, } } @@ -34,22 +34,21 @@ func (js Thoughts) Len() int { return len(js) } func (js Thoughts) Less(i, j int) bool { return js[j].Load.GasPrice.IsLT(js[i].Load.GasPrice) - //return js[i].Load.GasPrice.Amount.GT(js[j].Load.GasPrice.Amount) + // return js[i].Load.GasPrice.Amount.GT(js[j].Load.GasPrice.Amount) } func (js Thoughts) Swap(i, j int) { js[i], js[j] = js[j], js[i] } //______________________________________________________________________ - -func NewTrigger (period, block uint64) Trigger { +func NewTrigger(period, block uint64) Trigger { return Trigger{ Period: period, - Block: block, + Block: block, } } -func NewStats ( +func NewStats( program, name string, calls, fees, gas, block uint64, ) ThoughtStats { @@ -63,7 +62,7 @@ func NewStats ( } } -func NewLoad (calldata string, gasprice sdk.Coin) Load { +func NewLoad(calldata string, gasprice sdk.Coin) Load { return Load{ Input: calldata, GasPrice: gasprice, diff --git a/x/dmn/types/tx.pb.go b/x/dmn/types/tx.pb.go index 40c5092..270c6c6 100644 --- a/x/dmn/types/tx.pb.go +++ b/x/dmn/types/tx.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-sdk/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" @@ -14,15 +18,14 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -44,9 +47,11 @@ func (*MsgCreateThought) ProtoMessage() {} func (*MsgCreateThought) Descriptor() ([]byte, []int) { return fileDescriptor_4770788ccd571dd4, []int{0} } + func (m *MsgCreateThought) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgCreateThought) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgCreateThought.Marshal(b, m, deterministic) @@ -59,12 +64,15 @@ func (m *MsgCreateThought) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } + func (m *MsgCreateThought) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgCreateThought.Merge(m, src) } + func (m *MsgCreateThought) XXX_Size() int { return m.Size() } + func (m *MsgCreateThought) XXX_DiscardUnknown() { xxx_messageInfo_MsgCreateThought.DiscardUnknown(m) } @@ -82,9 +90,11 @@ func (*MsgForgetThought) ProtoMessage() {} func (*MsgForgetThought) Descriptor() ([]byte, []int) { return fileDescriptor_4770788ccd571dd4, []int{1} } + func (m *MsgForgetThought) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgForgetThought) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgForgetThought.Marshal(b, m, deterministic) @@ -97,12 +107,15 @@ func (m *MsgForgetThought) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } + func (m *MsgForgetThought) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgForgetThought.Merge(m, src) } + func (m *MsgForgetThought) XXX_Size() int { return m.Size() } + func (m *MsgForgetThought) XXX_DiscardUnknown() { xxx_messageInfo_MsgForgetThought.DiscardUnknown(m) } @@ -121,9 +134,11 @@ func (*MsgChangeThoughtParticle) ProtoMessage() {} func (*MsgChangeThoughtParticle) Descriptor() ([]byte, []int) { return fileDescriptor_4770788ccd571dd4, []int{2} } + func (m *MsgChangeThoughtParticle) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgChangeThoughtParticle) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgChangeThoughtParticle.Marshal(b, m, deterministic) @@ -136,12 +151,15 @@ func (m *MsgChangeThoughtParticle) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } + func (m *MsgChangeThoughtParticle) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgChangeThoughtParticle.Merge(m, src) } + func (m *MsgChangeThoughtParticle) XXX_Size() int { return m.Size() } + func (m *MsgChangeThoughtParticle) XXX_DiscardUnknown() { xxx_messageInfo_MsgChangeThoughtParticle.DiscardUnknown(m) } @@ -160,9 +178,11 @@ func (*MsgChangeThoughtName) ProtoMessage() {} func (*MsgChangeThoughtName) Descriptor() ([]byte, []int) { return fileDescriptor_4770788ccd571dd4, []int{3} } + func (m *MsgChangeThoughtName) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgChangeThoughtName) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgChangeThoughtName.Marshal(b, m, deterministic) @@ -175,12 +195,15 @@ func (m *MsgChangeThoughtName) XXX_Marshal(b []byte, deterministic bool) ([]byte return b[:n], nil } } + func (m *MsgChangeThoughtName) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgChangeThoughtName.Merge(m, src) } + func (m *MsgChangeThoughtName) XXX_Size() int { return m.Size() } + func (m *MsgChangeThoughtName) XXX_DiscardUnknown() { xxx_messageInfo_MsgChangeThoughtName.DiscardUnknown(m) } @@ -199,9 +222,11 @@ func (*MsgChangeThoughtInput) ProtoMessage() {} func (*MsgChangeThoughtInput) Descriptor() ([]byte, []int) { return fileDescriptor_4770788ccd571dd4, []int{4} } + func (m *MsgChangeThoughtInput) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgChangeThoughtInput) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgChangeThoughtInput.Marshal(b, m, deterministic) @@ -214,12 +239,15 @@ func (m *MsgChangeThoughtInput) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } + func (m *MsgChangeThoughtInput) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgChangeThoughtInput.Merge(m, src) } + func (m *MsgChangeThoughtInput) XXX_Size() int { return m.Size() } + func (m *MsgChangeThoughtInput) XXX_DiscardUnknown() { xxx_messageInfo_MsgChangeThoughtInput.DiscardUnknown(m) } @@ -238,9 +266,11 @@ func (*MsgChangeThoughtGasPrice) ProtoMessage() {} func (*MsgChangeThoughtGasPrice) Descriptor() ([]byte, []int) { return fileDescriptor_4770788ccd571dd4, []int{5} } + func (m *MsgChangeThoughtGasPrice) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgChangeThoughtGasPrice) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgChangeThoughtGasPrice.Marshal(b, m, deterministic) @@ -253,12 +283,15 @@ func (m *MsgChangeThoughtGasPrice) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } + func (m *MsgChangeThoughtGasPrice) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgChangeThoughtGasPrice.Merge(m, src) } + func (m *MsgChangeThoughtGasPrice) XXX_Size() int { return m.Size() } + func (m *MsgChangeThoughtGasPrice) XXX_DiscardUnknown() { xxx_messageInfo_MsgChangeThoughtGasPrice.DiscardUnknown(m) } @@ -277,9 +310,11 @@ func (*MsgChangeThoughtPeriod) ProtoMessage() {} func (*MsgChangeThoughtPeriod) Descriptor() ([]byte, []int) { return fileDescriptor_4770788ccd571dd4, []int{6} } + func (m *MsgChangeThoughtPeriod) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgChangeThoughtPeriod) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgChangeThoughtPeriod.Marshal(b, m, deterministic) @@ -292,12 +327,15 @@ func (m *MsgChangeThoughtPeriod) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } + func (m *MsgChangeThoughtPeriod) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgChangeThoughtPeriod.Merge(m, src) } + func (m *MsgChangeThoughtPeriod) XXX_Size() int { return m.Size() } + func (m *MsgChangeThoughtPeriod) XXX_DiscardUnknown() { xxx_messageInfo_MsgChangeThoughtPeriod.DiscardUnknown(m) } @@ -316,9 +354,11 @@ func (*MsgChangeThoughtBlock) ProtoMessage() {} func (*MsgChangeThoughtBlock) Descriptor() ([]byte, []int) { return fileDescriptor_4770788ccd571dd4, []int{7} } + func (m *MsgChangeThoughtBlock) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgChangeThoughtBlock) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgChangeThoughtBlock.Marshal(b, m, deterministic) @@ -331,20 +371,22 @@ func (m *MsgChangeThoughtBlock) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } + func (m *MsgChangeThoughtBlock) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgChangeThoughtBlock.Merge(m, src) } + func (m *MsgChangeThoughtBlock) XXX_Size() int { return m.Size() } + func (m *MsgChangeThoughtBlock) XXX_DiscardUnknown() { xxx_messageInfo_MsgChangeThoughtBlock.DiscardUnknown(m) } var xxx_messageInfo_MsgChangeThoughtBlock proto.InternalMessageInfo -type MsgCreateThoughtResponse struct { -} +type MsgCreateThoughtResponse struct{} func (m *MsgCreateThoughtResponse) Reset() { *m = MsgCreateThoughtResponse{} } func (m *MsgCreateThoughtResponse) String() string { return proto.CompactTextString(m) } @@ -352,9 +394,11 @@ func (*MsgCreateThoughtResponse) ProtoMessage() {} func (*MsgCreateThoughtResponse) Descriptor() ([]byte, []int) { return fileDescriptor_4770788ccd571dd4, []int{8} } + func (m *MsgCreateThoughtResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgCreateThoughtResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgCreateThoughtResponse.Marshal(b, m, deterministic) @@ -367,20 +411,22 @@ func (m *MsgCreateThoughtResponse) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } + func (m *MsgCreateThoughtResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgCreateThoughtResponse.Merge(m, src) } + func (m *MsgCreateThoughtResponse) XXX_Size() int { return m.Size() } + func (m *MsgCreateThoughtResponse) XXX_DiscardUnknown() { xxx_messageInfo_MsgCreateThoughtResponse.DiscardUnknown(m) } var xxx_messageInfo_MsgCreateThoughtResponse proto.InternalMessageInfo -type MsgForgetThoughtResponse struct { -} +type MsgForgetThoughtResponse struct{} func (m *MsgForgetThoughtResponse) Reset() { *m = MsgForgetThoughtResponse{} } func (m *MsgForgetThoughtResponse) String() string { return proto.CompactTextString(m) } @@ -388,9 +434,11 @@ func (*MsgForgetThoughtResponse) ProtoMessage() {} func (*MsgForgetThoughtResponse) Descriptor() ([]byte, []int) { return fileDescriptor_4770788ccd571dd4, []int{9} } + func (m *MsgForgetThoughtResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgForgetThoughtResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgForgetThoughtResponse.Marshal(b, m, deterministic) @@ -403,20 +451,22 @@ func (m *MsgForgetThoughtResponse) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } + func (m *MsgForgetThoughtResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgForgetThoughtResponse.Merge(m, src) } + func (m *MsgForgetThoughtResponse) XXX_Size() int { return m.Size() } + func (m *MsgForgetThoughtResponse) XXX_DiscardUnknown() { xxx_messageInfo_MsgForgetThoughtResponse.DiscardUnknown(m) } var xxx_messageInfo_MsgForgetThoughtResponse proto.InternalMessageInfo -type MsgChangeThoughtParticleResponse struct { -} +type MsgChangeThoughtParticleResponse struct{} func (m *MsgChangeThoughtParticleResponse) Reset() { *m = MsgChangeThoughtParticleResponse{} } func (m *MsgChangeThoughtParticleResponse) String() string { return proto.CompactTextString(m) } @@ -424,9 +474,11 @@ func (*MsgChangeThoughtParticleResponse) ProtoMessage() {} func (*MsgChangeThoughtParticleResponse) Descriptor() ([]byte, []int) { return fileDescriptor_4770788ccd571dd4, []int{10} } + func (m *MsgChangeThoughtParticleResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgChangeThoughtParticleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgChangeThoughtParticleResponse.Marshal(b, m, deterministic) @@ -439,20 +491,22 @@ func (m *MsgChangeThoughtParticleResponse) XXX_Marshal(b []byte, deterministic b return b[:n], nil } } + func (m *MsgChangeThoughtParticleResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgChangeThoughtParticleResponse.Merge(m, src) } + func (m *MsgChangeThoughtParticleResponse) XXX_Size() int { return m.Size() } + func (m *MsgChangeThoughtParticleResponse) XXX_DiscardUnknown() { xxx_messageInfo_MsgChangeThoughtParticleResponse.DiscardUnknown(m) } var xxx_messageInfo_MsgChangeThoughtParticleResponse proto.InternalMessageInfo -type MsgChangeThoughtNameResponse struct { -} +type MsgChangeThoughtNameResponse struct{} func (m *MsgChangeThoughtNameResponse) Reset() { *m = MsgChangeThoughtNameResponse{} } func (m *MsgChangeThoughtNameResponse) String() string { return proto.CompactTextString(m) } @@ -460,9 +514,11 @@ func (*MsgChangeThoughtNameResponse) ProtoMessage() {} func (*MsgChangeThoughtNameResponse) Descriptor() ([]byte, []int) { return fileDescriptor_4770788ccd571dd4, []int{11} } + func (m *MsgChangeThoughtNameResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgChangeThoughtNameResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgChangeThoughtNameResponse.Marshal(b, m, deterministic) @@ -475,20 +531,22 @@ func (m *MsgChangeThoughtNameResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } + func (m *MsgChangeThoughtNameResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgChangeThoughtNameResponse.Merge(m, src) } + func (m *MsgChangeThoughtNameResponse) XXX_Size() int { return m.Size() } + func (m *MsgChangeThoughtNameResponse) XXX_DiscardUnknown() { xxx_messageInfo_MsgChangeThoughtNameResponse.DiscardUnknown(m) } var xxx_messageInfo_MsgChangeThoughtNameResponse proto.InternalMessageInfo -type MsgChangeThoughtInputResponse struct { -} +type MsgChangeThoughtInputResponse struct{} func (m *MsgChangeThoughtInputResponse) Reset() { *m = MsgChangeThoughtInputResponse{} } func (m *MsgChangeThoughtInputResponse) String() string { return proto.CompactTextString(m) } @@ -496,9 +554,11 @@ func (*MsgChangeThoughtInputResponse) ProtoMessage() {} func (*MsgChangeThoughtInputResponse) Descriptor() ([]byte, []int) { return fileDescriptor_4770788ccd571dd4, []int{12} } + func (m *MsgChangeThoughtInputResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgChangeThoughtInputResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgChangeThoughtInputResponse.Marshal(b, m, deterministic) @@ -511,20 +571,22 @@ func (m *MsgChangeThoughtInputResponse) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } + func (m *MsgChangeThoughtInputResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgChangeThoughtInputResponse.Merge(m, src) } + func (m *MsgChangeThoughtInputResponse) XXX_Size() int { return m.Size() } + func (m *MsgChangeThoughtInputResponse) XXX_DiscardUnknown() { xxx_messageInfo_MsgChangeThoughtInputResponse.DiscardUnknown(m) } var xxx_messageInfo_MsgChangeThoughtInputResponse proto.InternalMessageInfo -type MsgChangeThoughtGasPriceResponse struct { -} +type MsgChangeThoughtGasPriceResponse struct{} func (m *MsgChangeThoughtGasPriceResponse) Reset() { *m = MsgChangeThoughtGasPriceResponse{} } func (m *MsgChangeThoughtGasPriceResponse) String() string { return proto.CompactTextString(m) } @@ -532,9 +594,11 @@ func (*MsgChangeThoughtGasPriceResponse) ProtoMessage() {} func (*MsgChangeThoughtGasPriceResponse) Descriptor() ([]byte, []int) { return fileDescriptor_4770788ccd571dd4, []int{13} } + func (m *MsgChangeThoughtGasPriceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgChangeThoughtGasPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgChangeThoughtGasPriceResponse.Marshal(b, m, deterministic) @@ -547,20 +611,22 @@ func (m *MsgChangeThoughtGasPriceResponse) XXX_Marshal(b []byte, deterministic b return b[:n], nil } } + func (m *MsgChangeThoughtGasPriceResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgChangeThoughtGasPriceResponse.Merge(m, src) } + func (m *MsgChangeThoughtGasPriceResponse) XXX_Size() int { return m.Size() } + func (m *MsgChangeThoughtGasPriceResponse) XXX_DiscardUnknown() { xxx_messageInfo_MsgChangeThoughtGasPriceResponse.DiscardUnknown(m) } var xxx_messageInfo_MsgChangeThoughtGasPriceResponse proto.InternalMessageInfo -type MsgChangeThoughtPeriodResponse struct { -} +type MsgChangeThoughtPeriodResponse struct{} func (m *MsgChangeThoughtPeriodResponse) Reset() { *m = MsgChangeThoughtPeriodResponse{} } func (m *MsgChangeThoughtPeriodResponse) String() string { return proto.CompactTextString(m) } @@ -568,9 +634,11 @@ func (*MsgChangeThoughtPeriodResponse) ProtoMessage() {} func (*MsgChangeThoughtPeriodResponse) Descriptor() ([]byte, []int) { return fileDescriptor_4770788ccd571dd4, []int{14} } + func (m *MsgChangeThoughtPeriodResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgChangeThoughtPeriodResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgChangeThoughtPeriodResponse.Marshal(b, m, deterministic) @@ -583,20 +651,22 @@ func (m *MsgChangeThoughtPeriodResponse) XXX_Marshal(b []byte, deterministic boo return b[:n], nil } } + func (m *MsgChangeThoughtPeriodResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgChangeThoughtPeriodResponse.Merge(m, src) } + func (m *MsgChangeThoughtPeriodResponse) XXX_Size() int { return m.Size() } + func (m *MsgChangeThoughtPeriodResponse) XXX_DiscardUnknown() { xxx_messageInfo_MsgChangeThoughtPeriodResponse.DiscardUnknown(m) } var xxx_messageInfo_MsgChangeThoughtPeriodResponse proto.InternalMessageInfo -type MsgChangeThoughtBlockResponse struct { -} +type MsgChangeThoughtBlockResponse struct{} func (m *MsgChangeThoughtBlockResponse) Reset() { *m = MsgChangeThoughtBlockResponse{} } func (m *MsgChangeThoughtBlockResponse) String() string { return proto.CompactTextString(m) } @@ -604,9 +674,11 @@ func (*MsgChangeThoughtBlockResponse) ProtoMessage() {} func (*MsgChangeThoughtBlockResponse) Descriptor() ([]byte, []int) { return fileDescriptor_4770788ccd571dd4, []int{15} } + func (m *MsgChangeThoughtBlockResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgChangeThoughtBlockResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgChangeThoughtBlockResponse.Marshal(b, m, deterministic) @@ -619,12 +691,15 @@ func (m *MsgChangeThoughtBlockResponse) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } + func (m *MsgChangeThoughtBlockResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgChangeThoughtBlockResponse.Merge(m, src) } + func (m *MsgChangeThoughtBlockResponse) XXX_Size() int { return m.Size() } + func (m *MsgChangeThoughtBlockResponse) XXX_DiscardUnknown() { xxx_messageInfo_MsgChangeThoughtBlockResponse.DiscardUnknown(m) } @@ -700,8 +775,10 @@ var fileDescriptor_4770788ccd571dd4 = []byte{ } // Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn +var ( + _ context.Context + _ grpc.ClientConn +) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. @@ -814,30 +891,36 @@ type MsgServer interface { } // UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} +type UnimplementedMsgServer struct{} func (*UnimplementedMsgServer) CreateThought(ctx context.Context, req *MsgCreateThought) (*MsgCreateThoughtResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateThought not implemented") } + func (*UnimplementedMsgServer) ForgetThought(ctx context.Context, req *MsgForgetThought) (*MsgForgetThoughtResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ForgetThought not implemented") } + func (*UnimplementedMsgServer) ChangeThoughtParticle(ctx context.Context, req *MsgChangeThoughtParticle) (*MsgChangeThoughtParticleResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ChangeThoughtParticle not implemented") } + func (*UnimplementedMsgServer) ChangeThoughtName(ctx context.Context, req *MsgChangeThoughtName) (*MsgChangeThoughtNameResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ChangeThoughtName not implemented") } + func (*UnimplementedMsgServer) ChangeThoughtInput(ctx context.Context, req *MsgChangeThoughtInput) (*MsgChangeThoughtInputResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ChangeThoughtInput not implemented") } + func (*UnimplementedMsgServer) ChangeThoughtGasPrice(ctx context.Context, req *MsgChangeThoughtGasPrice) (*MsgChangeThoughtGasPriceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ChangeThoughtGasPrice not implemented") } + func (*UnimplementedMsgServer) ChangeThoughtPeriod(ctx context.Context, req *MsgChangeThoughtPeriod) (*MsgChangeThoughtPeriodResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ChangeThoughtPeriod not implemented") } + func (*UnimplementedMsgServer) ChangeThoughtBlock(ctx context.Context, req *MsgChangeThoughtBlock) (*MsgChangeThoughtBlockResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ChangeThoughtBlock not implemented") } @@ -1590,6 +1673,7 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *MsgCreateThought) Size() (n int) { if m == nil { return 0 @@ -1829,9 +1913,11 @@ func (m *MsgChangeThoughtBlockResponse) Size() (n int) { func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *MsgCreateThought) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2044,6 +2130,7 @@ func (m *MsgCreateThought) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgForgetThought) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2158,6 +2245,7 @@ func (m *MsgForgetThought) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgChangeThoughtParticle) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2304,6 +2392,7 @@ func (m *MsgChangeThoughtParticle) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgChangeThoughtName) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2450,6 +2539,7 @@ func (m *MsgChangeThoughtName) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgChangeThoughtInput) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2596,6 +2686,7 @@ func (m *MsgChangeThoughtInput) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgChangeThoughtGasPrice) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2743,6 +2834,7 @@ func (m *MsgChangeThoughtGasPrice) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgChangeThoughtPeriod) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2876,6 +2968,7 @@ func (m *MsgChangeThoughtPeriod) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgChangeThoughtBlock) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3009,6 +3102,7 @@ func (m *MsgChangeThoughtBlock) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgCreateThoughtResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3059,6 +3153,7 @@ func (m *MsgCreateThoughtResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgForgetThoughtResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3109,6 +3204,7 @@ func (m *MsgForgetThoughtResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgChangeThoughtParticleResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3159,6 +3255,7 @@ func (m *MsgChangeThoughtParticleResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgChangeThoughtNameResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3209,6 +3306,7 @@ func (m *MsgChangeThoughtNameResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgChangeThoughtInputResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3259,6 +3357,7 @@ func (m *MsgChangeThoughtInputResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgChangeThoughtGasPriceResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3309,6 +3408,7 @@ func (m *MsgChangeThoughtGasPriceResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgChangeThoughtPeriodResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3359,6 +3459,7 @@ func (m *MsgChangeThoughtPeriodResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgChangeThoughtBlockResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3409,6 +3510,7 @@ func (m *MsgChangeThoughtBlockResponse) Unmarshal(dAtA []byte) error { } return nil } + func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/dmn/types/types.pb.go b/x/dmn/types/types.pb.go index 60307c8..c905a64 100644 --- a/x/dmn/types/types.pb.go +++ b/x/dmn/types/types.pb.go @@ -5,19 +5,22 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-sdk/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -37,9 +40,11 @@ func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { return fileDescriptor_a414790454046b0b, []int{0} } + func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_Params.Marshal(b, m, deterministic) @@ -52,12 +57,15 @@ func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } + func (m *Params) XXX_Merge(src proto.Message) { xxx_messageInfo_Params.Merge(m, src) } + func (m *Params) XXX_Size() int { return m.Size() } + func (m *Params) XXX_DiscardUnknown() { xxx_messageInfo_Params.DiscardUnknown(m) } @@ -99,9 +107,11 @@ func (*Thought) ProtoMessage() {} func (*Thought) Descriptor() ([]byte, []int) { return fileDescriptor_a414790454046b0b, []int{1} } + func (m *Thought) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *Thought) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_Thought.Marshal(b, m, deterministic) @@ -114,12 +124,15 @@ func (m *Thought) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } + func (m *Thought) XXX_Merge(src proto.Message) { xxx_messageInfo_Thought.Merge(m, src) } + func (m *Thought) XXX_Size() int { return m.Size() } + func (m *Thought) XXX_DiscardUnknown() { xxx_messageInfo_Thought.DiscardUnknown(m) } @@ -137,9 +150,11 @@ func (*Trigger) ProtoMessage() {} func (*Trigger) Descriptor() ([]byte, []int) { return fileDescriptor_a414790454046b0b, []int{2} } + func (m *Trigger) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *Trigger) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_Trigger.Marshal(b, m, deterministic) @@ -152,12 +167,15 @@ func (m *Trigger) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } + func (m *Trigger) XXX_Merge(src proto.Message) { xxx_messageInfo_Trigger.Merge(m, src) } + func (m *Trigger) XXX_Size() int { return m.Size() } + func (m *Trigger) XXX_DiscardUnknown() { xxx_messageInfo_Trigger.DiscardUnknown(m) } @@ -175,9 +193,11 @@ func (*Load) ProtoMessage() {} func (*Load) Descriptor() ([]byte, []int) { return fileDescriptor_a414790454046b0b, []int{3} } + func (m *Load) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *Load) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_Load.Marshal(b, m, deterministic) @@ -190,12 +210,15 @@ func (m *Load) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } + func (m *Load) XXX_Merge(src proto.Message) { xxx_messageInfo_Load.Merge(m, src) } + func (m *Load) XXX_Size() int { return m.Size() } + func (m *Load) XXX_DiscardUnknown() { xxx_messageInfo_Load.DiscardUnknown(m) } @@ -217,9 +240,11 @@ func (*ThoughtStats) ProtoMessage() {} func (*ThoughtStats) Descriptor() ([]byte, []int) { return fileDescriptor_a414790454046b0b, []int{4} } + func (m *ThoughtStats) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *ThoughtStats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_ThoughtStats.Marshal(b, m, deterministic) @@ -232,12 +257,15 @@ func (m *ThoughtStats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } + func (m *ThoughtStats) XXX_Merge(src proto.Message) { xxx_messageInfo_ThoughtStats.Merge(m, src) } + func (m *ThoughtStats) XXX_Size() int { return m.Size() } + func (m *ThoughtStats) XXX_DiscardUnknown() { xxx_messageInfo_ThoughtStats.DiscardUnknown(m) } @@ -322,6 +350,7 @@ func (this *Params) Equal(that interface{}) bool { } return true } + func (m *Params) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -565,6 +594,7 @@ func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *Params) Size() (n int) { if m == nil { return 0 @@ -670,9 +700,11 @@ func (m *ThoughtStats) Size() (n int) { func sovTypes(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozTypes(x uint64) (n int) { return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *Params) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -780,6 +812,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } + func (m *Thought) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -992,6 +1025,7 @@ func (m *Thought) Unmarshal(dAtA []byte) error { } return nil } + func (m *Trigger) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1080,6 +1114,7 @@ func (m *Trigger) Unmarshal(dAtA []byte) error { } return nil } + func (m *Load) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1195,6 +1230,7 @@ func (m *Load) Unmarshal(dAtA []byte) error { } return nil } + func (m *ThoughtStats) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1385,6 +1421,7 @@ func (m *ThoughtStats) Unmarshal(dAtA []byte) error { } return nil } + func skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/dmn/wasm/interface.go b/x/dmn/wasm/interface.go index 6980424..ecb61cc 100644 --- a/x/dmn/wasm/interface.go +++ b/x/dmn/wasm/interface.go @@ -6,17 +6,21 @@ import ( "github.com/CosmWasm/wasmd/x/wasm" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + wasmplugins "github.com/cybercongress/go-cyber/plugins" wasmTypes "github.com/CosmWasm/wasmvm/types" wasmvmtypes "github.com/CosmWasm/wasmvm/types" + "github.com/cybercongress/go-cyber/x/dmn/keeper" "github.com/cybercongress/go-cyber/x/dmn/types" ) -var _ WasmQuerierInterface = WasmQuerier{} -var _ WasmMsgParserInterface = WasmMsgParser{} +var ( + _ WasmQuerierInterface = WasmQuerier{} + _ WasmMsgParserInterface = WasmMsgParser{} +) //-------------------------------------------------- @@ -31,7 +35,9 @@ func NewWasmMsgParser() WasmMsgParser { return WasmMsgParser{} } -func (WasmMsgParser) Parse(_ sdk.AccAddress, _ wasmTypes.CosmosMsg) ([]sdk.Msg, error) { return nil, nil } +func (WasmMsgParser) Parse(_ sdk.AccAddress, _ wasmTypes.CosmosMsg) ([]sdk.Msg, error) { + return nil, nil +} type CosmosMsg struct { CreateThought *types.MsgCreateThought `json:"create_thought,omitempty"` @@ -106,16 +112,16 @@ type Load struct { } type QueryThoughtParams struct { - Program string `json:"program"` - Name string `json:"name"` + Program string `json:"program"` + Name string `json:"name"` } type ThoughtQueryResponse struct { - Program string `json:"program"` + Program string `json:"program"` Trigger Trigger `json:"trigger"` - Load Load `json:"load"` - Name string `json:"name"` - Particle string `json:"particle"` + Load Load `json:"load"` + Name string `json:"name"` + Particle string `json:"particle"` } type ThoughtStatsQueryResponse struct { @@ -134,7 +140,6 @@ type LowestFeeResponse struct { func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) { var query CosmosQuery err := json.Unmarshal(data, &query) - if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } @@ -144,7 +149,8 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ if query.Thought != nil { program, _ := sdk.AccAddressFromBech32(query.Thought.Program) - thought, found := querier.Keeper.GetThought(ctx, program, query.Thought.Name); if found != true { + thought, found := querier.Keeper.GetThought(ctx, program, query.Thought.Name) + if found != true { return nil, sdkerrors.ErrInvalidRequest } @@ -155,22 +161,23 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ Load: convertLoadToWasmLoad(thought.Load), Name: thought.Name, Particle: thought.Particle, - }) + }) } else if query.ThoughtStats != nil { program, _ := sdk.AccAddressFromBech32(query.ThoughtStats.Program) - thoughtStats, found := querier.Keeper.GetThoughtStats(ctx, program, query.ThoughtStats.Name); if found != true { + thoughtStats, found := querier.Keeper.GetThoughtStats(ctx, program, query.ThoughtStats.Name) + if found != true { return nil, sdkerrors.ErrInvalidRequest } bz, err = json.Marshal( ThoughtStatsQueryResponse{ Program: thoughtStats.Program, - Name : thoughtStats.Name, + Name: thoughtStats.Name, Calls: thoughtStats.Calls, Fees: thoughtStats.Fees, Gas: thoughtStats.Gas, LastBlock: thoughtStats.LastBlock, - }) + }) } else if query.LowestFee != nil { lowestFee := querier.Keeper.GetLowestFee(ctx) bz, err = json.Marshal( @@ -193,4 +200,4 @@ func convertLoadToWasmLoad(load types.Load) Load { load.Input, wasmplugins.ConvertSdkCoinToWasmCoin(load.GasPrice), } -} \ No newline at end of file +} diff --git a/x/graph/abci.go b/x/graph/abci.go index b907540..6b6fc73 100644 --- a/x/graph/abci.go +++ b/x/graph/abci.go @@ -18,5 +18,5 @@ func EndBlocker(ctx sdk.Context, gk *keeper.GraphKeeper, ik *keeper.IndexKeeper) defer telemetry.ModuleSetGauge(types.ModuleName, float32(amountParticles), "total_particles") gk.UpdateMemNeudegs(ctx) - //ik.MergeContextLinks(ctx) -} \ No newline at end of file + // ik.MergeContextLinks(ctx) +} diff --git a/x/graph/client/cli/query.go b/x/graph/client/cli/query.go index e63668c..c82aad5 100644 --- a/x/graph/client/cli/query.go +++ b/x/graph/client/cli/query.go @@ -27,7 +27,7 @@ func GetQueryCmd() *cobra.Command { return graphQueryCmd } -func GetCmdGraphStats() *cobra.Command{ +func GetCmdGraphStats() *cobra.Command { cmd := &cobra.Command{ Use: "stats", Short: "Query the graph stats", @@ -54,4 +54,4 @@ func GetCmdGraphStats() *cobra.Command{ flags.AddQueryFlagsToCmd(cmd) return cmd -} \ No newline at end of file +} diff --git a/x/graph/client/cli/tx.go b/x/graph/client/cli/tx.go index fcf1a6b..6fec6ae 100644 --- a/x/graph/client/cli/tx.go +++ b/x/graph/client/cli/tx.go @@ -1,4 +1,3 @@ - package cli import ( @@ -59,7 +58,7 @@ $ %s tx link cyberlink QmWZYRj344JSLShtBnrMS4vw5DQ2zsGqrytYKMqcQgEneB QmfZwbahFL } cidFrom := types.Cid(args[0]) - cidTo := types.Cid(args[1]) + cidTo := types.Cid(args[1]) if _, err := cid.Decode(string(cidFrom)); err != nil { return types.ErrInvalidParticle @@ -87,6 +86,5 @@ $ %s tx link cyberlink QmWZYRj344JSLShtBnrMS4vw5DQ2zsGqrytYKMqcQgEneB QmfZwbahFL flags.AddTxFlagsToCmd(cmd) - return cmd -} \ No newline at end of file +} diff --git a/x/graph/client/rest/query.go b/x/graph/client/rest/query.go index 677bdbf..67d8d97 100644 --- a/x/graph/client/rest/query.go +++ b/x/graph/client/rest/query.go @@ -34,4 +34,4 @@ func queryGraphStatsHandlerFn(cliCtx client.Context) http.HandlerFunc { cliCtx = cliCtx.WithHeight(height) rest.PostProcessResponse(w, cliCtx, res) } -} \ No newline at end of file +} diff --git a/x/graph/client/rest/rest.go b/x/graph/client/rest/rest.go index f6e4589..2f87a5a 100644 --- a/x/graph/client/rest/rest.go +++ b/x/graph/client/rest/rest.go @@ -8,4 +8,4 @@ import ( func RegisterRoutes(cliCtx client.Context, r *mux.Router) { registerQueryRoutes(cliCtx, r) -} \ No newline at end of file +} diff --git a/x/graph/keeper/genesis.go b/x/graph/keeper/genesis.go index 909cdaa..60ffee5 100644 --- a/x/graph/keeper/genesis.go +++ b/x/graph/keeper/genesis.go @@ -47,7 +47,6 @@ func InitGenesis( func WriteGenesis( ctx sdk.Context, gk GraphKeeper, ik *IndexKeeper, ) (err error) { - linksFilePath := utils.RootifyPath(LinksExportFileName) dirName := filepath.Dir(linksFilePath) if _, err := os.Stat(dirName); err != nil { diff --git a/x/graph/keeper/graph.go b/x/graph/keeper/graph.go index 9d87bf0..e18b2c5 100644 --- a/x/graph/keeper/graph.go +++ b/x/graph/keeper/graph.go @@ -3,15 +3,15 @@ package keeper import ( "encoding/binary" "fmt" + "io" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/telemetry" - . "github.com/cybercongress/go-cyber/types" - "github.com/cybercongress/go-cyber/x/graph/types" "github.com/tendermint/tendermint/libs/log" - "io" + . "github.com/cybercongress/go-cyber/types" + "github.com/cybercongress/go-cyber/x/graph/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -22,11 +22,11 @@ const ( ) type GraphKeeper struct { - key sdk.StoreKey - cdc codec.BinaryCodec - neudeg map[uint64]uint64 + key sdk.StoreKey + cdc codec.BinaryCodec + neudeg map[uint64]uint64 rankNeudeg map[uint64]uint64 - tkey sdk.StoreKey + tkey sdk.StoreKey } func NewKeeper( @@ -35,10 +35,10 @@ func NewKeeper( tkey sdk.StoreKey, ) *GraphKeeper { return &GraphKeeper{ - cdc: cdc, - key: storeKey, - tkey: tkey, - neudeg: make(map[uint64]uint64), + cdc: cdc, + key: storeKey, + tkey: tkey, + neudeg: make(map[uint64]uint64), rankNeudeg: make(map[uint64]uint64), } } @@ -61,7 +61,6 @@ func (gk GraphKeeper) GetAllLinks(ctx sdk.Context) (types.Links, types.Links, er } func (gk GraphKeeper) GetAllLinksFiltered(ctx sdk.Context, filter types.LinkFilter) (types.Links, types.Links, error) { - inLinks := make(map[types.CidNumber]types.CidLinks) outLinks := make(map[types.CidNumber]types.CidLinks) @@ -82,7 +81,7 @@ func (gk GraphKeeper) IterateLinks(ctx sdk.Context, process func(link types.Comp From: sdk.BigEndianToUint64(key[1:9]), To: sdk.BigEndianToUint64(key[17:25]), Account: sdk.BigEndianToUint64(key[9:17]), - } + } process(compactLink) }) } @@ -134,4 +133,4 @@ func (gk GraphKeeper) WriteLinks(ctx sdk.Context, writer io.Writer) (err error) }) return nil -} \ No newline at end of file +} diff --git a/x/graph/keeper/grpc_query.go b/x/graph/keeper/grpc_query.go index 4513cb4..025793d 100644 --- a/x/graph/keeper/grpc_query.go +++ b/x/graph/keeper/grpc_query.go @@ -20,4 +20,4 @@ func (gk GraphKeeper) GraphStats(goCtx context.Context, _ *types.QueryGraphStats links := gk.GetLinksCount(ctx) cids := gk.GetCidsCount(ctx) return &types.QueryGraphStatsResponse{links, cids}, nil -} \ No newline at end of file +} diff --git a/x/graph/keeper/index.go b/x/graph/keeper/index.go index 5dc1078..aad8f73 100644 --- a/x/graph/keeper/index.go +++ b/x/graph/keeper/index.go @@ -2,10 +2,10 @@ package keeper import ( "encoding/binary" - //"fmt" - "io" + //"fmt" + . "github.com/cybercongress/go-cyber/types" "github.com/cybercongress/go-cyber/utils" "github.com/cybercongress/go-cyber/x/graph/types" @@ -26,7 +26,7 @@ type IndexKeeper struct { nextRankOutLinks types.Links // Inter-block cache for cyberlinks, reset on every block during Commit - tkey sdk.StoreKey + tkey sdk.StoreKey currentBlockLinks []types.CompactLink } @@ -50,7 +50,6 @@ func (i *IndexKeeper) LoadState(rankCtx sdk.Context, freshCtx sdk.Context) { newInLinks, newOutLinks, err := i.GraphKeeper.GetAllLinksFiltered(freshCtx, func(l types.CompactLink) bool { return !i.currentRankOutLinks.IsLinkExist(types.CidNumber(l.From), types.CidNumber(l.To), AccNumber(l.Account)) }) - if err != nil { tmos.Exit(err.Error()) } @@ -88,7 +87,9 @@ func (i *IndexKeeper) MergeContextLinks(ctx sdk.Context) { func (i *IndexKeeper) HasNewLinks(ctx sdk.Context) bool { store := ctx.TransientStore(i.tkey) hasLinks := store.Get(types.HasNewLinks) - if hasLinks == nil { return false } + if hasLinks == nil { + return false + } return sdk.BigEndianToUint64(hasLinks) > 0 } @@ -158,5 +159,3 @@ func (i *IndexKeeper) LoadFromReader(ctx sdk.Context, reader io.Reader) (err err } return } - - diff --git a/x/graph/keeper/msg_server.go b/x/graph/keeper/msg_server.go index 30c546c..316be0c 100644 --- a/x/graph/keeper/msg_server.go +++ b/x/graph/keeper/msg_server.go @@ -2,16 +2,18 @@ package keeper import ( "context" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdk "github.com/cosmos/cosmos-sdk/types" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + ctypes "github.com/cybercongress/go-cyber/types" bandwidthkeeper "github.com/cybercongress/go-cyber/x/bandwidth/keeper" bandwidthtypes "github.com/cybercongress/go-cyber/x/bandwidth/types" cyberbankkeeper "github.com/cybercongress/go-cyber/x/cyberbank/keeper" - //sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + // sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cybercongress/go-cyber/x/graph/types" ) @@ -51,7 +53,8 @@ func (k msgServer) Cyberlink(goCtx context.Context, msg *types.MsgCyberlink) (*t if err != nil { return nil, err } - acc := k.GetAccount(ctx, addr); if (acc != nil) { + acc := k.GetAccount(ctx, addr) + if acc != nil { accNumber = ctypes.AccNumber(acc.GetAccountNumber()) } else { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "Invalid neuron address") @@ -79,7 +82,8 @@ func (k msgServer) Cyberlink(goCtx context.Context, msg *types.MsgCyberlink) (*t } else if (cost + currentBlockSpentBandwidth) > maxBlockBandwidth { return nil, bandwidthtypes.ErrExceededMaxBlockBandwidth } else { - err = k.ConsumeAccountBandwidth(ctx, accountBandwidth, cost); if err != nil { + err = k.ConsumeAccountBandwidth(ctx, accountBandwidth, cost) + if err != nil { return nil, bandwidthtypes.ErrNotEnoughBandwidth } k.AddToBlockBandwidth(cost) @@ -88,8 +92,14 @@ func (k msgServer) Cyberlink(goCtx context.Context, msg *types.MsgCyberlink) (*t for _, link := range msg.Links { // if cid not exists it automatically means that this is new link - fromCidNumber, exists := k.GetCidNumber(ctx, types.Cid(link.From)); if !exists { continue } - toCidNumber, exists := k.GetCidNumber(ctx, types.Cid(link.To)); if !exists { continue } + fromCidNumber, exists := k.GetCidNumber(ctx, types.Cid(link.From)) + if !exists { + continue + } + toCidNumber, exists := k.GetCidNumber(ctx, types.Cid(link.To)) + if !exists { + continue + } compactLink := types.NewLink(fromCidNumber, toCidNumber, accNumber) @@ -132,4 +142,4 @@ func (k msgServer) Cyberlink(goCtx context.Context, msg *types.MsgCyberlink) (*t }) return &types.MsgCyberlinkResponse{}, nil -} \ No newline at end of file +} diff --git a/x/graph/keeper/neudeg.go b/x/graph/keeper/neudeg.go index bfd6b48..35f87e4 100644 --- a/x/graph/keeper/neudeg.go +++ b/x/graph/keeper/neudeg.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cybercongress/go-cyber/x/graph/types" ) @@ -36,14 +37,18 @@ func (gk GraphKeeper) IncrementNeudeg(ctx sdk.Context, accNumber uint64) { func (gk GraphKeeper) GetNeudeg(ctx sdk.Context, accNumber uint64) uint64 { store := ctx.KVStore(gk.key) neudeg := store.Get(types.NeudegStoreKey(accNumber)) - if neudeg == nil { return 0 } + if neudeg == nil { + return 0 + } return sdk.BigEndianToUint64(neudeg) } func (gk GraphKeeper) GetTNeudeg(ctx sdk.Context, accNumber uint64) uint64 { store := ctx.TransientStore(gk.tkey) neudeg := store.Get(types.NeudegTStoreKey(accNumber)) - if neudeg == nil { return 0 } + if neudeg == nil { + return 0 + } return sdk.BigEndianToUint64(neudeg) } diff --git a/x/graph/keeper/particles.go b/x/graph/keeper/particles.go index 11c5e12..580f651 100644 --- a/x/graph/keeper/particles.go +++ b/x/graph/keeper/particles.go @@ -2,14 +2,13 @@ package keeper import ( "encoding/binary" + "io" "github.com/cosmos/cosmos-sdk/telemetry" "github.com/cybercongress/go-cyber/utils" "github.com/cybercongress/go-cyber/x/graph/types" - "io" - sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -19,7 +18,6 @@ const ( CidCountBytesSize = uint64(8) ) - // Return cid number and true, if cid exists func (gk GraphKeeper) GetCidNumber(ctx sdk.Context, cid types.Cid) (types.CidNumber, bool) { store := ctx.KVStore(gk.key) @@ -43,7 +41,6 @@ func (gk GraphKeeper) GetCid(ctx sdk.Context, num types.CidNumber) types.Cid { // for given link, CIDs added in order [CID1, CID2] (if they both new to chain) // This method performs lookup of CIDs, returns index value, or create and put in index new value if not exists. func (gk GraphKeeper) GetOrPutCidNumber(ctx sdk.Context, cid types.Cid) types.CidNumber { - store := ctx.KVStore(gk.key) cidIndexAsBytes := store.Get(types.CidStoreKey(cid)) @@ -97,7 +94,7 @@ func (gk GraphKeeper) IterateCids(ctx sdk.Context, process func(types.Cid, types // write CIDs to writer in binary format: .... func (gk GraphKeeper) WriteCids(ctx sdk.Context, writer io.Writer) (err error) { - uintAsBytes := make([]byte, 8) //common bytes array to convert uints + uintAsBytes := make([]byte, 8) // common bytes array to convert uints cidsCount := gk.GetCidsCount(ctx) binary.LittleEndian.PutUint64(uintAsBytes, cidsCount) @@ -109,7 +106,7 @@ func (gk GraphKeeper) WriteCids(ctx sdk.Context, writer io.Writer) (err error) { gk.IterateCids(ctx, func(cid types.Cid, number types.CidNumber) { cidLength := len(cid) if cidLength > 255 { - //err = errors.New("cid length cannot be over 255") + // err = errors.New("cid length cannot be over 255") return } diff --git a/x/graph/keeper/querier.go b/x/graph/keeper/querier.go index 36276cd..af595d6 100644 --- a/x/graph/keeper/querier.go +++ b/x/graph/keeper/querier.go @@ -21,12 +21,11 @@ func NewQuerier(gk GraphKeeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier } } -func queryGraphStats(ctx sdk.Context, _ abci.RequestQuery, gk GraphKeeper, legacyQuerierCdc *codec.LegacyAmino,) ([]byte, error) { +func queryGraphStats(ctx sdk.Context, _ abci.RequestQuery, gk GraphKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { links := gk.GetLinksCount(ctx) cids := gk.GetCidsCount(ctx) res, err := codec.MarshalJSONIndent(legacyQuerierCdc, types.QueryGraphStatsResponse{links, cids}) - if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) } diff --git a/x/graph/module.go b/x/graph/module.go index 95f2b0b..c701ff6 100644 --- a/x/graph/module.go +++ b/x/graph/module.go @@ -1,24 +1,27 @@ package graph import ( + "context" "encoding/json" - //"fmt" - "context" + //"fmt" "github.com/cosmos/cosmos-sdk/client" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - bandwidthkeeper "github.com/cybercongress/go-cyber/x/bandwidth/keeper" "github.com/grpc-ecosystem/grpc-gateway/runtime" abci "github.com/tendermint/tendermint/abci/types" + + bandwidthkeeper "github.com/cybercongress/go-cyber/x/bandwidth/keeper" + //"github.com/gogo/protobuf/codec" "github.com/cosmos/cosmos-sdk/codec" //"github.com/cosmos/cosmos-sdk/types/module" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/gorilla/mux" "github.com/spf13/cobra" + //"github.com/tendermint/tendermint/abci/types" cyberbankkeeper "github.com/cybercongress/go-cyber/x/cyberbank/keeper" @@ -29,11 +32,11 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} ) -type AppModuleBasic struct{ +type AppModuleBasic struct { cdc codec.Codec } @@ -45,7 +48,9 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { func (AppModuleBasic) DefaultGenesis(_ codec.JSONCodec) json.RawMessage { return nil } -func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, _ client.TxEncodingConfig, _ json.RawMessage) error { return nil } +func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, _ client.TxEncodingConfig, _ json.RawMessage) error { + return nil +} func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { rest.RegisterRoutes(clientCtx, rtr) @@ -80,11 +85,11 @@ type AppModule struct { } func NewAppModule( - cdc codec.Codec, - graphKeeper *keeper.GraphKeeper, - indexKeeper *keeper.IndexKeeper, - accountKeeper authkeeper.AccountKeeper, - bankKeeper *cyberbankkeeper.IndexedKeeper, + cdc codec.Codec, + graphKeeper *keeper.GraphKeeper, + indexKeeper *keeper.IndexKeeper, + accountKeeper authkeeper.AccountKeeper, + bankKeeper *cyberbankkeeper.IndexedKeeper, bandwidthKeeper *bandwidthkeeper.BandwidthMeter, ) AppModule { return AppModule{ @@ -92,8 +97,8 @@ func NewAppModule( gk: graphKeeper, ik: indexKeeper, ak: accountKeeper, - bk: bankKeeper, - bm: bandwidthKeeper, + bk: bankKeeper, + bm: bandwidthKeeper, } } @@ -140,4 +145,3 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val EndBlocker(ctx, am.gk, am.ik) return []abci.ValidatorUpdate{} } - diff --git a/x/graph/types/compact_link.go b/x/graph/types/compact_link.go index 473ee46..d5e9278 100644 --- a/x/graph/types/compact_link.go +++ b/x/graph/types/compact_link.go @@ -16,9 +16,9 @@ type LinkFilter func(CompactLink) bool func NewLink(from CidNumber, to CidNumber, acc AccNumber) CompactLink { return CompactLink{ - From: uint64(from), - To: uint64(to), - Account: uint64(acc), + From: uint64(from), + To: uint64(to), + Account: uint64(acc), } } @@ -37,5 +37,3 @@ func (l CompactLink) MarshalBinaryLink() []byte { binary.LittleEndian.PutUint64(b[16:24], l.Account) return b } - - diff --git a/x/graph/types/cyberlinks.go b/x/graph/types/cyberlinks.go index 6027b6e..3d15ad8 100644 --- a/x/graph/types/cyberlinks.go +++ b/x/graph/types/cyberlinks.go @@ -6,11 +6,15 @@ import ( // map of map, where first key is cid, second key is account.String() // second map is used as set for fast contains check -type Links map[CidNumber]CidLinks -type CidLinks map[CidNumber]map[AccNumber]struct{} +type ( + Links map[CidNumber]CidLinks + CidLinks map[CidNumber]map[AccNumber]struct{} +) -type Cid string -type CidNumber uint64 +type ( + Cid string + CidNumber uint64 +) func (links Links) Put(from CidNumber, to CidNumber, acc AccNumber) { cidLinks := links[from] @@ -37,7 +41,6 @@ func (links Links) PutAll(newLinks Links) { } func (links Links) Copy() Links { - linksCopy := make(Links, len(links)) for from := range links { @@ -55,7 +58,6 @@ func (links Links) Copy() Links { } func (links Links) IsAnyLinkExist(from CidNumber, to CidNumber) bool { - toLinks, fromExists := links[from] if fromExists { linkAccs, toExists := toLinks[to] @@ -68,7 +70,6 @@ func (links Links) IsAnyLinkExist(from CidNumber, to CidNumber) bool { } func (links Links) IsLinkExist(from CidNumber, to CidNumber, acc AccNumber) bool { - toLinks, fromExists := links[from] if fromExists { linkAccs, toExists := toLinks[to] diff --git a/x/graph/types/errors.go b/x/graph/types/errors.go index 4926f09..e5ec87c 100644 --- a/x/graph/types/errors.go +++ b/x/graph/types/errors.go @@ -5,11 +5,11 @@ import ( ) var ( - ErrCyberlinkExist = sdkerrors.Register(ModuleName, 2, "your cyberlink already exists") - ErrZeroLinks = sdkerrors.Register(ModuleName, 3, "cyberlinks not found") - ErrSelfLink = sdkerrors.Register(ModuleName, 4, "loop cyberlink not allowed") - ErrInvalidParticle = sdkerrors.Register(ModuleName, 5, "invalid particle") - ErrCidNotFound = sdkerrors.Register(ModuleName, 6, "particle not found") - ErrCidVersion = sdkerrors.Register(ModuleName, 7, "unsupported cid version") - ErrZeroPower = sdkerrors.Register(ModuleName, 8, "neuron has zero power") -) \ No newline at end of file + ErrCyberlinkExist = sdkerrors.Register(ModuleName, 2, "your cyberlink already exists") + ErrZeroLinks = sdkerrors.Register(ModuleName, 3, "cyberlinks not found") + ErrSelfLink = sdkerrors.Register(ModuleName, 4, "loop cyberlink not allowed") + ErrInvalidParticle = sdkerrors.Register(ModuleName, 5, "invalid particle") + ErrCidNotFound = sdkerrors.Register(ModuleName, 6, "particle not found") + ErrCidVersion = sdkerrors.Register(ModuleName, 7, "unsupported cid version") + ErrZeroPower = sdkerrors.Register(ModuleName, 8, "neuron has zero power") +) diff --git a/x/graph/types/events.go b/x/graph/types/events.go index b5867f7..a21cefb 100644 --- a/x/graph/types/events.go +++ b/x/graph/types/events.go @@ -1,11 +1,11 @@ package types const ( - EventTypeCyberlink = "cyberlink" + EventTypeCyberlink = "cyberlink" AttributeKeyParticleFrom = "particleFrom" AttributeKeyParticleTo = "particleTo" AttributeKeyNeuron = "neuron" - AttributeValueCategory = ModuleName + AttributeValueCategory = ModuleName ) diff --git a/x/graph/types/keys.go b/x/graph/types/keys.go index 13fd7db..34cb011 100644 --- a/x/graph/types/keys.go +++ b/x/graph/types/keys.go @@ -5,26 +5,26 @@ import ( ) const ( - ModuleName = "graph" - RouterKey = ModuleName - StoreKey = ModuleName - QuerierRoute = ModuleName + ModuleName = "graph" + RouterKey = ModuleName + StoreKey = ModuleName + QuerierRoute = ModuleName - TStoreKey = "transient_index" + TStoreKey = "transient_index" ) var ( - GlobalStoreKeyPrefix = []byte{0x00} - CidStoreKeyPrefix = []byte{0x01} + GlobalStoreKeyPrefix = []byte{0x00} + CidStoreKeyPrefix = []byte{0x01} CidReverseStoreKeyPrefix = []byte{0x02} CyberlinkStoreKeyPrefix = []byte{0x03} CyberlinkTStoreKeyPrefix = []byte{0x04} // inter-block cache for cyberlinks NeudegStoreKeyPrefix = []byte{0x05} NeudegTStoreKeyPrefix = []byte{0x06} // inter-block cache for neurons cyberlink' degree - LastCidNumber = append(GlobalStoreKeyPrefix, []byte("lastParticleNumber")...) - LinksCount = append(GlobalStoreKeyPrefix, []byte("cyberlinksAmount")...) - HasNewLinks = append(GlobalStoreKeyPrefix, []byte("blockHasNewLinks")...) + LastCidNumber = append(GlobalStoreKeyPrefix, []byte("lastParticleNumber")...) + LinksCount = append(GlobalStoreKeyPrefix, []byte("cyberlinksAmount")...) + HasNewLinks = append(GlobalStoreKeyPrefix, []byte("blockHasNewLinks")...) ) func CidStoreKey(cid Cid) []byte { @@ -53,8 +53,8 @@ func NeudegTStoreKey(accNumber uint64) []byte { func CyberlinkRawKey(link CompactLink) []byte { keyAsBytes := make([]byte, 24) - copy(keyAsBytes[0:8],sdk.Uint64ToBigEndian(link.From)) - copy(keyAsBytes[8:16],sdk.Uint64ToBigEndian(link.Account)) - copy(keyAsBytes[16:24],sdk.Uint64ToBigEndian(link.To)) + copy(keyAsBytes[0:8], sdk.Uint64ToBigEndian(link.From)) + copy(keyAsBytes[8:16], sdk.Uint64ToBigEndian(link.Account)) + copy(keyAsBytes[16:24], sdk.Uint64ToBigEndian(link.To)) return keyAsBytes } diff --git a/x/graph/types/msgs.go b/x/graph/types/msgs.go index 9835a96..82e183e 100644 --- a/x/graph/types/msgs.go +++ b/x/graph/types/msgs.go @@ -7,23 +7,21 @@ import ( ) const ( - TypeMsgCyberlink = "cyberlink" + TypeMsgCyberlink = "cyberlink" ) -var ( - _ sdk.Msg = &MsgCyberlink{} -) +var _ sdk.Msg = &MsgCyberlink{} func NewMsgCyberlink(address sdk.AccAddress, links []Link) *MsgCyberlink { return &MsgCyberlink{ Neuron: address.String(), - Links: links, + Links: links, } } func (msg MsgCyberlink) Route() string { return RouterKey } -func (msg MsgCyberlink) Type() string { return TypeMsgCyberlink } +func (msg MsgCyberlink) Type() string { return TypeMsgCyberlink } func (msg MsgCyberlink) GetSigners() []sdk.AccAddress { addr, _ := sdk.AccAddressFromBech32(msg.Neuron) @@ -35,7 +33,6 @@ func (msg MsgCyberlink) GetSignBytes() []byte { } func (msg MsgCyberlink) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Neuron) if err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid neuron address: %s", err) @@ -45,7 +42,7 @@ func (msg MsgCyberlink) ValidateBasic() error { return ErrZeroLinks } - var filter = make(CidsFilter) + filter := make(CidsFilter) for _, link := range msg.Links { if link.From == link.To { return ErrSelfLink @@ -77,4 +74,4 @@ func (msg MsgCyberlink) ValidateBasic() error { } return nil -} \ No newline at end of file +} diff --git a/x/graph/types/particles_filter.go b/x/graph/types/particles_filter.go index b990e95..27a3bed 100644 --- a/x/graph/types/particles_filter.go +++ b/x/graph/types/particles_filter.go @@ -3,7 +3,6 @@ package types type CidsFilter map[Cid]map[Cid]struct{} func (cf CidsFilter) Put(from Cid, to Cid) { - cidLinks := cf[from] if cidLinks == nil { cidLinks = make(map[Cid]struct{}) @@ -13,7 +12,6 @@ func (cf CidsFilter) Put(from Cid, to Cid) { } func (cf CidsFilter) Contains(from Cid, to Cid) bool { - cidLinks := cf[from] if cidLinks == nil { return false diff --git a/x/graph/types/querier.go b/x/graph/types/querier.go index 525a0cc..e92a92d 100644 --- a/x/graph/types/querier.go +++ b/x/graph/types/querier.go @@ -1,5 +1,5 @@ package types const ( - QueryGraphStats = "graph_stats" -) \ No newline at end of file + QueryGraphStats = "graph_stats" +) diff --git a/x/graph/types/query.pb.go b/x/graph/types/query.pb.go index bc2a732..778f675 100644 --- a/x/graph/types/query.pb.go +++ b/x/graph/types/query.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -13,15 +17,14 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -29,8 +32,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type QueryGraphStatsRequest struct { -} +type QueryGraphStatsRequest struct{} func (m *QueryGraphStatsRequest) Reset() { *m = QueryGraphStatsRequest{} } func (m *QueryGraphStatsRequest) String() string { return proto.CompactTextString(m) } @@ -38,9 +40,11 @@ func (*QueryGraphStatsRequest) ProtoMessage() {} func (*QueryGraphStatsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_1588f994db3ad35c, []int{0} } + func (m *QueryGraphStatsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryGraphStatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryGraphStatsRequest.Marshal(b, m, deterministic) @@ -53,12 +57,15 @@ func (m *QueryGraphStatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } + func (m *QueryGraphStatsRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryGraphStatsRequest.Merge(m, src) } + func (m *QueryGraphStatsRequest) XXX_Size() int { return m.Size() } + func (m *QueryGraphStatsRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryGraphStatsRequest.DiscardUnknown(m) } @@ -76,9 +83,11 @@ func (*QueryGraphStatsResponse) ProtoMessage() {} func (*QueryGraphStatsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_1588f994db3ad35c, []int{1} } + func (m *QueryGraphStatsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryGraphStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryGraphStatsResponse.Marshal(b, m, deterministic) @@ -91,12 +100,15 @@ func (m *QueryGraphStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } + func (m *QueryGraphStatsResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryGraphStatsResponse.Merge(m, src) } + func (m *QueryGraphStatsResponse) XXX_Size() int { return m.Size() } + func (m *QueryGraphStatsResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryGraphStatsResponse.DiscardUnknown(m) } @@ -148,8 +160,10 @@ var fileDescriptor_1588f994db3ad35c = []byte{ } // Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn +var ( + _ context.Context + _ grpc.ClientConn +) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. @@ -185,8 +199,7 @@ type QueryServer interface { } // UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} +type UnimplementedQueryServer struct{} func (*UnimplementedQueryServer) GraphStats(ctx context.Context, req *QueryGraphStatsRequest) (*QueryGraphStatsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GraphStats not implemented") @@ -294,6 +307,7 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *QueryGraphStatsRequest) Size() (n int) { if m == nil { return 0 @@ -321,9 +335,11 @@ func (m *QueryGraphStatsResponse) Size() (n int) { func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *QueryGraphStatsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -374,6 +390,7 @@ func (m *QueryGraphStatsRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryGraphStatsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -462,6 +479,7 @@ func (m *QueryGraphStatsResponse) Unmarshal(dAtA []byte) error { } return nil } + func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/graph/types/query.pb.gw.go b/x/graph/types/query.pb.gw.go index 76a6fc5..10c6a4e 100644 --- a/x/graph/types/query.pb.gw.go +++ b/x/graph/types/query.pb.gw.go @@ -24,12 +24,14 @@ import ( ) // Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = runtime.String + _ = utilities.NewDoubleArray + _ = descriptor.ForMessage +) func request_Query_GraphStats_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryGraphStatsRequest @@ -37,7 +39,6 @@ func request_Query_GraphStats_0(ctx context.Context, marshaler runtime.Marshaler msg, err := client.GraphStats(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_GraphStats_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -46,7 +47,6 @@ func local_request_Query_GraphStats_0(ctx context.Context, marshaler runtime.Mar msg, err := server.GraphStats(ctx, &protoReq) return msg, metadata, err - } // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". @@ -54,7 +54,6 @@ func local_request_Query_GraphStats_0(ctx context.Context, marshaler runtime.Mar // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_GraphStats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -72,7 +71,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_GraphStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) return nil @@ -115,7 +113,6 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_GraphStats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -133,16 +130,11 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_GraphStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) return nil } -var ( - pattern_Query_GraphStats_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cyber", "graph", "v1beta1", "graph_stats"}, "", runtime.AssumeColonVerbOpt(false))) -) +var pattern_Query_GraphStats_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cyber", "graph", "v1beta1", "graph_stats"}, "", runtime.AssumeColonVerbOpt(false))) -var ( - forward_Query_GraphStats_0 = runtime.ForwardResponseMessage -) +var forward_Query_GraphStats_0 = runtime.ForwardResponseMessage diff --git a/x/graph/types/tx.pb.go b/x/graph/types/tx.pb.go index 2483271..e61238f 100644 --- a/x/graph/types/tx.pb.go +++ b/x/graph/types/tx.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" @@ -13,15 +17,14 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -40,9 +43,11 @@ func (*MsgCyberlink) ProtoMessage() {} func (*MsgCyberlink) Descriptor() ([]byte, []int) { return fileDescriptor_39ffdb6b83edbf38, []int{0} } + func (m *MsgCyberlink) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgCyberlink) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgCyberlink.Marshal(b, m, deterministic) @@ -55,20 +60,22 @@ func (m *MsgCyberlink) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } + func (m *MsgCyberlink) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgCyberlink.Merge(m, src) } + func (m *MsgCyberlink) XXX_Size() int { return m.Size() } + func (m *MsgCyberlink) XXX_DiscardUnknown() { xxx_messageInfo_MsgCyberlink.DiscardUnknown(m) } var xxx_messageInfo_MsgCyberlink proto.InternalMessageInfo -type MsgCyberlinkResponse struct { -} +type MsgCyberlinkResponse struct{} func (m *MsgCyberlinkResponse) Reset() { *m = MsgCyberlinkResponse{} } func (m *MsgCyberlinkResponse) String() string { return proto.CompactTextString(m) } @@ -76,9 +83,11 @@ func (*MsgCyberlinkResponse) ProtoMessage() {} func (*MsgCyberlinkResponse) Descriptor() ([]byte, []int) { return fileDescriptor_39ffdb6b83edbf38, []int{1} } + func (m *MsgCyberlinkResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgCyberlinkResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgCyberlinkResponse.Marshal(b, m, deterministic) @@ -91,12 +100,15 @@ func (m *MsgCyberlinkResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte return b[:n], nil } } + func (m *MsgCyberlinkResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgCyberlinkResponse.Merge(m, src) } + func (m *MsgCyberlinkResponse) XXX_Size() int { return m.Size() } + func (m *MsgCyberlinkResponse) XXX_DiscardUnknown() { xxx_messageInfo_MsgCyberlinkResponse.DiscardUnknown(m) } @@ -134,8 +146,10 @@ var fileDescriptor_39ffdb6b83edbf38 = []byte{ } // Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn +var ( + _ context.Context + _ grpc.ClientConn +) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. @@ -171,8 +185,7 @@ type MsgServer interface { } // UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} +type UnimplementedMsgServer struct{} func (*UnimplementedMsgServer) Cyberlink(ctx context.Context, req *MsgCyberlink) (*MsgCyberlinkResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Cyberlink not implemented") @@ -291,6 +304,7 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *MsgCyberlink) Size() (n int) { if m == nil { return 0 @@ -322,9 +336,11 @@ func (m *MsgCyberlinkResponse) Size() (n int) { func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *MsgCyberlink) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -441,6 +457,7 @@ func (m *MsgCyberlink) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgCyberlinkResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -491,6 +508,7 @@ func (m *MsgCyberlinkResponse) Unmarshal(dAtA []byte) error { } return nil } + func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/graph/types/types.pb.go b/x/graph/types/types.pb.go index ab38ef1..b4bf4b1 100644 --- a/x/graph/types/types.pb.go +++ b/x/graph/types/types.pb.go @@ -5,17 +5,20 @@ package types import ( fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -34,9 +37,11 @@ func (*Link) ProtoMessage() {} func (*Link) Descriptor() ([]byte, []int) { return fileDescriptor_71ff86aea4c7c827, []int{0} } + func (m *Link) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *Link) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_Link.Marshal(b, m, deterministic) @@ -49,12 +54,15 @@ func (m *Link) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } + func (m *Link) XXX_Merge(src proto.Message) { xxx_messageInfo_Link.Merge(m, src) } + func (m *Link) XXX_Size() int { return m.Size() } + func (m *Link) XXX_DiscardUnknown() { xxx_messageInfo_Link.DiscardUnknown(m) } @@ -132,6 +140,7 @@ func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *Link) Size() (n int) { if m == nil { return 0 @@ -152,9 +161,11 @@ func (m *Link) Size() (n int) { func sovTypes(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozTypes(x uint64) (n int) { return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *Link) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -269,6 +280,7 @@ func (m *Link) Unmarshal(dAtA []byte) error { } return nil } + func skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/graph/wasm/interface.go b/x/graph/wasm/interface.go index 8d50e7d..e18afd1 100644 --- a/x/graph/wasm/interface.go +++ b/x/graph/wasm/interface.go @@ -13,8 +13,10 @@ import ( "github.com/cybercongress/go-cyber/x/graph/types" ) -var _ WasmQuerierInterface = WasmQuerier{} -var _ WasmMsgParserInterface = WasmMsgParser{} +var ( + _ WasmQuerierInterface = WasmQuerier{} + _ WasmMsgParserInterface = WasmMsgParser{} +) //-------------------------------------------------- @@ -29,7 +31,9 @@ func NewWasmMsgParser() WasmMsgParser { return WasmMsgParser{} } -func (WasmMsgParser) Parse(_ sdk.AccAddress, _ wasmvmtypes.CosmosMsg) ([]sdk.Msg, error) { return nil, nil } +func (WasmMsgParser) Parse(_ sdk.AccAddress, _ wasmvmtypes.CosmosMsg) ([]sdk.Msg, error) { + return nil, nil +} type CosmosMsg struct { Cyberlink *types.MsgCyberlink `json:"cyberlink,omitempty"` @@ -82,7 +86,6 @@ type CyberlinksAmountQueryResponse struct { func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) { var query CosmosQuery err := json.Unmarshal(data, &query) - if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } @@ -104,4 +107,4 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ } return bz, nil -} \ No newline at end of file +} diff --git a/x/grid/client/cli/query.go b/x/grid/client/cli/query.go index 9c4d15b..ebe5667 100644 --- a/x/grid/client/cli/query.go +++ b/x/grid/client/cli/query.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + //"github.com/cosmos/cosmos-sdk/codec" "github.com/cybercongress/go-cyber/x/grid/types" @@ -71,7 +72,7 @@ func GetCmdQuerySourceRoutes() *cobra.Command { cmd := &cobra.Command{ Use: "routes-from [source]", Short: "Query all grid routes that made from source account", - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -88,7 +89,6 @@ func GetCmdQuerySourceRoutes() *cobra.Command { context.Background(), &types.QuerySourceRequest{Source: src.String()}, ) - if err != nil { return err } @@ -106,7 +106,7 @@ func GetCmdQueryDestinationRoutes() *cobra.Command { cmd := &cobra.Command{ Use: "routes-to [destination]", Short: "Query all grid routes that routed to destination account", - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -123,7 +123,6 @@ func GetCmdQueryDestinationRoutes() *cobra.Command { context.Background(), &types.QueryDestinationRequest{Destination: dst.String()}, ) - if err != nil { return err } @@ -141,7 +140,7 @@ func GetCmdQuerySourceRoutedEnergy() *cobra.Command { cmd := &cobra.Command{ Use: "routed-from [source]", Short: "Query grid value that routed from source account", - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -158,7 +157,6 @@ func GetCmdQuerySourceRoutedEnergy() *cobra.Command { context.Background(), &types.QuerySourceRequest{Source: src.String()}, ) - if err != nil { return err } @@ -176,7 +174,7 @@ func GetCmdQueryDestinationRoutedEnergy() *cobra.Command { cmd := &cobra.Command{ Use: "routed-to [destination]", Short: "Query grid value that routed to destination account", - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -193,7 +191,6 @@ func GetCmdQueryDestinationRoutedEnergy() *cobra.Command { context.Background(), &types.QueryDestinationRequest{Destination: dst.String()}, ) - if err != nil { return err } @@ -211,7 +208,7 @@ func GetCmdQueryRoute() *cobra.Command { cmd := &cobra.Command{ Use: "route [source] [destination]", Short: "Query grid route that routes for given source and destination accounts", - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -232,7 +229,7 @@ func GetCmdQueryRoute() *cobra.Command { res, err := queryClient.Route( context.Background(), &types.QueryRouteRequest{ - Source: src.String(), + Source: src.String(), Destination: dst.String(), }, ) @@ -253,7 +250,7 @@ func GetCmdQueryRoutes() *cobra.Command { cmd := &cobra.Command{ Use: "routes", Short: "Query all grid routes", - Args: cobra.ExactArgs(0), + Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -284,4 +281,3 @@ func GetCmdQueryRoutes() *cobra.Command { return cmd } - diff --git a/x/grid/client/rest/query.go b/x/grid/client/rest/query.go index 815f54b..6112bc5 100644 --- a/x/grid/client/rest/query.go +++ b/x/grid/client/rest/query.go @@ -46,7 +46,6 @@ func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { func queryParamsHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryParams) res, _, err := cliCtx.QueryWithData(route, nil) @@ -61,7 +60,6 @@ func queryParamsHandlerFn(cliCtx client.Context) http.HandlerFunc { func querySourceRoutesHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) src, err := sdk.AccAddressFromBech32(vars[Source]) @@ -96,7 +94,6 @@ func querySourceRoutesHandlerFn(cliCtx client.Context) http.HandlerFunc { func queryDestinationRoutesHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) dst, err := sdk.AccAddressFromBech32(vars[Destination]) @@ -131,7 +128,6 @@ func queryDestinationRoutesHandlerFn(cliCtx client.Context) http.HandlerFunc { func querySourceRoutedEnergyHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) src, err := sdk.AccAddressFromBech32(vars[Source]) @@ -166,7 +162,6 @@ func querySourceRoutedEnergyHandlerFn(cliCtx client.Context) http.HandlerFunc { func queryDestinationRoutedEnergyHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) dst, err := sdk.AccAddressFromBech32(vars[Destination]) @@ -201,7 +196,6 @@ func queryDestinationRoutedEnergyHandlerFn(cliCtx client.Context) http.HandlerFu func queryRouteHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) src, err := sdk.AccAddressFromBech32(vars[Source]) @@ -264,4 +258,4 @@ func queryRoutesHandlerFn(cliCtx client.Context) http.HandlerFunc { cliCtx = cliCtx.WithHeight(height) rest.PostProcessResponse(w, cliCtx, res) } -} \ No newline at end of file +} diff --git a/x/grid/keeper/genesis.go b/x/grid/keeper/genesis.go index a125d75..76c5f67 100644 --- a/x/grid/keeper/genesis.go +++ b/x/grid/keeper/genesis.go @@ -2,13 +2,15 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cybercongress/go-cyber/x/grid/types" ) func InitGenesis(ctx sdk.Context, k Keeper, data types.GenesisState) { // TODO check EnergyGrid balance aggregated value on genesis k.SetParams(ctx, data.Params) - err := k.SetRoutes(ctx, data.Routes); if err != nil { + err := k.SetRoutes(ctx, data.Routes) + if err != nil { panic(err) } } diff --git a/x/grid/keeper/grpc_query.go b/x/grid/keeper/grpc_query.go index 624ff9a..4e24c39 100644 --- a/x/grid/keeper/grpc_query.go +++ b/x/grid/keeper/grpc_query.go @@ -167,4 +167,4 @@ func (k Keeper) Routes(goCtx context.Context, request *types.QueryRoutesRequest) } return &types.QueryRoutesResponse{Routes: routes, Pagination: pageRes}, nil -} \ No newline at end of file +} diff --git a/x/grid/keeper/keeper.go b/x/grid/keeper/keeper.go index 0c7144f..daaab6f 100644 --- a/x/grid/keeper/keeper.go +++ b/x/grid/keeper/keeper.go @@ -5,9 +5,10 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - ctypes "github.com/cybercongress/go-cyber/types" "github.com/tendermint/tendermint/libs/log" + ctypes "github.com/cybercongress/go-cyber/types" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -75,7 +76,7 @@ func (k Keeper) CreateEnergyRoute(ctx sdk.Context, src, dst sdk.AccAddress, name routes := k.GetSourceRoutes(ctx, src, k.MaxSourceRoutes(ctx)) if uint32(len(routes)) == k.MaxSourceRoutes(ctx) { - return types.ErrMaxRoutes + return types.ErrMaxRoutes } acc := k.accountKeeper.GetAccount(ctx, dst) @@ -129,7 +130,7 @@ func (k Keeper) EditEnergyRoute(ctx sdk.Context, src, dst sdk.AccAddress, value } ampers := route.Value.AmountOf(ctypes.AMPERE) - volts := route.Value.AmountOf(ctypes.VOLT) + volts := route.Value.AmountOf(ctypes.VOLT) newValues := sdk.Coins{} if value.Denom == ctypes.VOLT { newValues = sdk.NewCoins(value, sdk.NewCoin(ctypes.AMPERE, ampers)) @@ -327,4 +328,4 @@ func (k Keeper) GetRoutedFromEnergy(ctx sdk.Context, src sdk.AccAddress) (amount } return amount -} \ No newline at end of file +} diff --git a/x/grid/keeper/querier.go b/x/grid/keeper/querier.go index d4b61d8..45946ec 100644 --- a/x/grid/keeper/querier.go +++ b/x/grid/keeper/querier.go @@ -47,7 +47,8 @@ func queryParams(ctx sdk.Context, k Keeper, legacyQuerierCdc *codec.LegacyAmino) func querySourceRoutes(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QuerySourceParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); if err != nil { + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } @@ -65,7 +66,8 @@ func querySourceRoutes(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQ func queryDestinationRoutes(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QueryDestinationParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); if err != nil { + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } @@ -82,7 +84,8 @@ func queryDestinationRoutes(ctx sdk.Context, req abci.RequestQuery, k Keeper, le func queryDestinationRoutedEnergy(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QueryDestinationParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); if err != nil { + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } @@ -99,7 +102,8 @@ func queryDestinationRoutedEnergy(ctx sdk.Context, req abci.RequestQuery, k Keep func querySourceRoutedEnergy(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QuerySourceParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); if err != nil { + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } @@ -116,7 +120,8 @@ func querySourceRoutedEnergy(ctx sdk.Context, req abci.RequestQuery, k Keeper, l func queryRoute(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QueryRouteParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); if err != nil { + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } diff --git a/x/grid/module.go b/x/grid/module.go index 36cd343..ff8f828 100644 --- a/x/grid/module.go +++ b/x/grid/module.go @@ -28,7 +28,7 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -type AppModuleBasic struct{ +type AppModuleBasic struct { cdc codec.Codec } @@ -45,7 +45,8 @@ func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { var data types.GenesisState - err := cdc.UnmarshalJSON(bz, &data); if err != nil { + err := cdc.UnmarshalJSON(bz, &data) + if err != nil { return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) } return types.ValidateGenesis(data) @@ -77,7 +78,7 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) type AppModule struct { AppModuleBasic - keeper keeper.Keeper + keeper keeper.Keeper } func NewAppModule( diff --git a/x/grid/types/errors.go b/x/grid/types/errors.go index 27e968e..45ce674 100644 --- a/x/grid/types/errors.go +++ b/x/grid/types/errors.go @@ -5,10 +5,10 @@ import ( ) var ( - ErrWrongName = sdkerrors.Register(ModuleName, 2, "length of the name is not valid") - ErrRouteNotExist = sdkerrors.Register(ModuleName, 3, "the route does not exist") - ErrRouteExist = sdkerrors.Register(ModuleName, 4, "the route exists") - ErrWrongValueDenom = sdkerrors.Register(ModuleName, 5, "the denom of value is not supported") - ErrMaxRoutes = sdkerrors.Register(ModuleName, 6, "max routes are exceeded") - ErrSelfRoute = sdkerrors.Register(ModuleName, 7, "routing to self is not allowed") + ErrWrongName = sdkerrors.Register(ModuleName, 2, "length of the name is not valid") + ErrRouteNotExist = sdkerrors.Register(ModuleName, 3, "the route does not exist") + ErrRouteExist = sdkerrors.Register(ModuleName, 4, "the route exists") + ErrWrongValueDenom = sdkerrors.Register(ModuleName, 5, "the denom of value is not supported") + ErrMaxRoutes = sdkerrors.Register(ModuleName, 6, "max routes are exceeded") + ErrSelfRoute = sdkerrors.Register(ModuleName, 7, "routing to self is not allowed") ) diff --git a/x/grid/types/events.go b/x/grid/types/events.go index 6db0ade..0d5f3e6 100644 --- a/x/grid/types/events.go +++ b/x/grid/types/events.go @@ -1,16 +1,15 @@ package types const ( - EventTypeCreateRoute = "create_route" - EventTypeEditRoute = "edit_route" - EventTypeDeleteRoute = "delete_route" - EventTypeEditRouteName = "edit_route_name" - + EventTypeCreateRoute = "create_route" + EventTypeEditRoute = "edit_route" + EventTypeDeleteRoute = "delete_route" + EventTypeEditRouteName = "edit_route_name" AttributeKeySource = "source" AttributeKeyDestination = "destination" AttributeKeyName = "name" AttributeKeyValue = "value" - AttributeValueCategory = ModuleName + AttributeValueCategory = ModuleName ) diff --git a/x/grid/types/expected_keepers.go b/x/grid/types/expected_keepers.go index c427c29..49fc25d 100644 --- a/x/grid/types/expected_keepers.go +++ b/x/grid/types/expected_keepers.go @@ -3,7 +3,6 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - //"github.com/cosmos/cosmos-sdk/x/auth/exported" //"github.com/cosmos/cosmos-sdk/x/params" //bankexported "github.com/cosmos/cosmos-sdk/x/bank/exported" @@ -22,4 +21,4 @@ type AccountKeeper interface { SetAccount(ctx sdk.Context, acc authtypes.AccountI) GetModuleAddress(name string) sdk.AccAddress NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI -} \ No newline at end of file +} diff --git a/x/grid/types/genesis.go b/x/grid/types/genesis.go index ffade98..d9bf207 100644 --- a/x/grid/types/genesis.go +++ b/x/grid/types/genesis.go @@ -2,8 +2,8 @@ package types func NewGenesisState(params Params, routes []Route) *GenesisState { return &GenesisState{ - Params: params, - Routes: routes, + Params: params, + Routes: routes, } } diff --git a/x/grid/types/genesis.pb.go b/x/grid/types/genesis.pb.go index 97c823d..b640b62 100644 --- a/x/grid/types/genesis.pb.go +++ b/x/grid/types/genesis.pb.go @@ -5,17 +5,20 @@ package types import ( fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -34,9 +37,11 @@ func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { return fileDescriptor_e1ab9a0f068eb924, []int{0} } + func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) @@ -49,12 +54,15 @@ func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } + func (m *GenesisState) XXX_Merge(src proto.Message) { xxx_messageInfo_GenesisState.Merge(m, src) } + func (m *GenesisState) XXX_Size() int { return m.Size() } + func (m *GenesisState) XXX_DiscardUnknown() { xxx_messageInfo_GenesisState.DiscardUnknown(m) } @@ -159,6 +167,7 @@ func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *GenesisState) Size() (n int) { if m == nil { return 0 @@ -179,9 +188,11 @@ func (m *GenesisState) Size() (n int) { func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozGenesis(x uint64) (n int) { return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *GenesisState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -299,6 +310,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } return nil } + func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/grid/types/keys.go b/x/grid/types/keys.go index 2eac26b..ff9dcf4 100644 --- a/x/grid/types/keys.go +++ b/x/grid/types/keys.go @@ -3,12 +3,12 @@ package types import sdk "github.com/cosmos/cosmos-sdk/types" const ( - ModuleName = "grid" - StoreKey = ModuleName - RouterKey = ModuleName - QuerierRoute = ModuleName + ModuleName = "grid" + StoreKey = ModuleName + RouterKey = ModuleName + QuerierRoute = ModuleName - GridPoolName = "energy_grid" + GridPoolName = "energy_grid" ) var ( @@ -27,4 +27,3 @@ func GetRouteKey(src sdk.AccAddress, dst sdk.AccAddress) []byte { func GetRoutesKey(src sdk.AccAddress) []byte { return append(RouteKey, src.Bytes()...) } - diff --git a/x/grid/types/msgs.go b/x/grid/types/msgs.go index 0d1d114..a78584f 100644 --- a/x/grid/types/msgs.go +++ b/x/grid/types/msgs.go @@ -3,17 +3,17 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + ctypes "github.com/cybercongress/go-cyber/types" ) -const( - ActionCreateRoute = "create_route" - ActionEditRoute = "edit_route" - ActionDeleteRoute = "delete_route" - ActionEditRouteName = "edit_route_name" +const ( + ActionCreateRoute = "create_route" + ActionEditRoute = "edit_route" + ActionDeleteRoute = "delete_route" + ActionEditRouteName = "edit_route_name" ) - var ( _ sdk.Msg = &MsgCreateRoute{} _ sdk.Msg = &MsgEditRoute{} @@ -31,7 +31,7 @@ func NewMsgCreateRoute(src sdk.AccAddress, dst sdk.AccAddress, name string) *Msg func (msg MsgCreateRoute) Route() string { return RouterKey } -func (msg MsgCreateRoute) Type() string { return ActionCreateRoute } +func (msg MsgCreateRoute) Type() string { return ActionCreateRoute } func (msg MsgCreateRoute) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Source) @@ -62,18 +62,17 @@ func (msg MsgCreateRoute) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{addr} } - func NewMsgEditRoute(src sdk.AccAddress, dst sdk.AccAddress, value sdk.Coin) *MsgEditRoute { return &MsgEditRoute{ - Source: src.String(), + Source: src.String(), Destination: dst.String(), - Value: value, + Value: value, } } func (msg MsgEditRoute) Route() string { return RouterKey } -func (msg MsgEditRoute) Type() string { return ActionEditRoute } +func (msg MsgEditRoute) Type() string { return ActionEditRoute } func (msg MsgEditRoute) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Source) @@ -104,17 +103,16 @@ func (msg MsgEditRoute) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{addr} } - func NewMsgDeleteRoute(src sdk.AccAddress, dst sdk.AccAddress) *MsgDeleteRoute { return &MsgDeleteRoute{ - Source: src.String(), + Source: src.String(), Destination: dst.String(), } } func (msg MsgDeleteRoute) Route() string { return RouterKey } -func (msg MsgDeleteRoute) Type() string { return ActionDeleteRoute } +func (msg MsgDeleteRoute) Type() string { return ActionDeleteRoute } func (msg MsgDeleteRoute) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Source) @@ -152,7 +150,7 @@ func NewMsgEditRouteName(src sdk.AccAddress, dst sdk.AccAddress, name string) *M func (msg MsgEditRouteName) Route() string { return RouterKey } -func (msg MsgEditRouteName) Type() string { return ActionEditRouteName } +func (msg MsgEditRouteName) Type() string { return ActionEditRouteName } func (msg MsgEditRouteName) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Source) @@ -182,5 +180,3 @@ func (msg MsgEditRouteName) GetSigners() []sdk.AccAddress { } return []sdk.AccAddress{addr} } - - diff --git a/x/grid/types/params.go b/x/grid/types/params.go index f2a866e..68615fd 100644 --- a/x/grid/types/params.go +++ b/x/grid/types/params.go @@ -11,9 +11,7 @@ const ( DefaultMaxRoutes = uint32(8) ) -var ( - KeyMaxRoutes = []byte("MaxRoutes") -) +var KeyMaxRoutes = []byte("MaxRoutes") func ParamKeyTable() paramstypes.KeyTable { return paramstypes.NewKeyTable().RegisterParamSet(&Params{}) diff --git a/x/grid/types/querier.go b/x/grid/types/querier.go index 5dd9601..51f39e9 100644 --- a/x/grid/types/querier.go +++ b/x/grid/types/querier.go @@ -3,18 +3,17 @@ package types import sdk "github.com/cosmos/cosmos-sdk/types" const ( - QueryParams = "params" - QuerySourceRoutes = "source_routes" - QueryDestinationRoutes = "destination_routes" + QueryParams = "params" + QuerySourceRoutes = "source_routes" + QueryDestinationRoutes = "destination_routes" QuerySourceRoutedEnergy = "source_routed_energy" QueryDestinationRoutedEnergy = "destination_routed_energy" - QueryRoute = "route" - QueryRoutes = "routes" + QueryRoute = "route" + QueryRoutes = "routes" ) - type QueryRoutesParams struct { - Page, Limit int + Page, Limit int } func NewQueryRoutesParams(page, limit int) QueryRoutesParams { @@ -22,7 +21,7 @@ func NewQueryRoutesParams(page, limit int) QueryRoutesParams { } type QueryRouteParams struct { - Source, Destination sdk.AccAddress + Source, Destination sdk.AccAddress } func NewQueryRouteParams(source, destination sdk.AccAddress) QueryRouteParams { @@ -30,7 +29,7 @@ func NewQueryRouteParams(source, destination sdk.AccAddress) QueryRouteParams { } type QuerySourceParams struct { - Source sdk.AccAddress + Source sdk.AccAddress } func NewQuerySourceParams(source sdk.AccAddress) QuerySourceParams { @@ -38,9 +37,9 @@ func NewQuerySourceParams(source sdk.AccAddress) QuerySourceParams { } type QueryDestinationParams struct { - Destination sdk.AccAddress + Destination sdk.AccAddress } func NewQueryDestinationParams(destination sdk.AccAddress) QueryDestinationParams { return QueryDestinationParams{destination} -} \ No newline at end of file +} diff --git a/x/grid/types/query.pb.go b/x/grid/types/query.pb.go index 6193a70..5428222 100644 --- a/x/grid/types/query.pb.go +++ b/x/grid/types/query.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" query "github.com/cosmos/cosmos-sdk/types/query" @@ -16,15 +20,14 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -32,8 +35,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type QueryParamsRequest struct { -} +type QueryParamsRequest struct{} func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } @@ -41,9 +43,11 @@ func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f6ec0dbd7f0bdd2b, []int{0} } + func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) @@ -56,12 +60,15 @@ func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryParamsRequest.Merge(m, src) } + func (m *QueryParamsRequest) XXX_Size() int { return m.Size() } + func (m *QueryParamsRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) } @@ -78,9 +85,11 @@ func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f6ec0dbd7f0bdd2b, []int{1} } + func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) @@ -93,12 +102,15 @@ func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryParamsResponse.Merge(m, src) } + func (m *QueryParamsResponse) XXX_Size() int { return m.Size() } + func (m *QueryParamsResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) } @@ -115,9 +127,11 @@ func (*QuerySourceRequest) ProtoMessage() {} func (*QuerySourceRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f6ec0dbd7f0bdd2b, []int{2} } + func (m *QuerySourceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QuerySourceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QuerySourceRequest.Marshal(b, m, deterministic) @@ -130,12 +144,15 @@ func (m *QuerySourceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QuerySourceRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QuerySourceRequest.Merge(m, src) } + func (m *QuerySourceRequest) XXX_Size() int { return m.Size() } + func (m *QuerySourceRequest) XXX_DiscardUnknown() { xxx_messageInfo_QuerySourceRequest.DiscardUnknown(m) } @@ -152,9 +169,11 @@ func (*QueryDestinationRequest) ProtoMessage() {} func (*QueryDestinationRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f6ec0dbd7f0bdd2b, []int{3} } + func (m *QueryDestinationRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryDestinationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryDestinationRequest.Marshal(b, m, deterministic) @@ -167,12 +186,15 @@ func (m *QueryDestinationRequest) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } + func (m *QueryDestinationRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryDestinationRequest.Merge(m, src) } + func (m *QueryDestinationRequest) XXX_Size() int { return m.Size() } + func (m *QueryDestinationRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryDestinationRequest.DiscardUnknown(m) } @@ -189,9 +211,11 @@ func (*QueryRoutedEnergyResponse) ProtoMessage() {} func (*QueryRoutedEnergyResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f6ec0dbd7f0bdd2b, []int{4} } + func (m *QueryRoutedEnergyResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryRoutedEnergyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryRoutedEnergyResponse.Marshal(b, m, deterministic) @@ -204,12 +228,15 @@ func (m *QueryRoutedEnergyResponse) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } + func (m *QueryRoutedEnergyResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryRoutedEnergyResponse.Merge(m, src) } + func (m *QueryRoutedEnergyResponse) XXX_Size() int { return m.Size() } + func (m *QueryRoutedEnergyResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryRoutedEnergyResponse.DiscardUnknown(m) } @@ -227,9 +254,11 @@ func (*QueryRouteRequest) ProtoMessage() {} func (*QueryRouteRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f6ec0dbd7f0bdd2b, []int{5} } + func (m *QueryRouteRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryRouteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryRouteRequest.Marshal(b, m, deterministic) @@ -242,12 +271,15 @@ func (m *QueryRouteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } + func (m *QueryRouteRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryRouteRequest.Merge(m, src) } + func (m *QueryRouteRequest) XXX_Size() int { return m.Size() } + func (m *QueryRouteRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryRouteRequest.DiscardUnknown(m) } @@ -264,9 +296,11 @@ func (*QueryRouteResponse) ProtoMessage() {} func (*QueryRouteResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f6ec0dbd7f0bdd2b, []int{6} } + func (m *QueryRouteResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryRouteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryRouteResponse.Marshal(b, m, deterministic) @@ -279,12 +313,15 @@ func (m *QueryRouteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QueryRouteResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryRouteResponse.Merge(m, src) } + func (m *QueryRouteResponse) XXX_Size() int { return m.Size() } + func (m *QueryRouteResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryRouteResponse.DiscardUnknown(m) } @@ -301,9 +338,11 @@ func (*QueryRoutesRequest) ProtoMessage() {} func (*QueryRoutesRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f6ec0dbd7f0bdd2b, []int{7} } + func (m *QueryRoutesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryRoutesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryRoutesRequest.Marshal(b, m, deterministic) @@ -316,12 +355,15 @@ func (m *QueryRoutesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QueryRoutesRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryRoutesRequest.Merge(m, src) } + func (m *QueryRoutesRequest) XXX_Size() int { return m.Size() } + func (m *QueryRoutesRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryRoutesRequest.DiscardUnknown(m) } @@ -339,9 +381,11 @@ func (*QueryRoutesResponse) ProtoMessage() {} func (*QueryRoutesResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f6ec0dbd7f0bdd2b, []int{8} } + func (m *QueryRoutesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryRoutesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryRoutesResponse.Marshal(b, m, deterministic) @@ -354,12 +398,15 @@ func (m *QueryRoutesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QueryRoutesResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryRoutesResponse.Merge(m, src) } + func (m *QueryRoutesResponse) XXX_Size() int { return m.Size() } + func (m *QueryRoutesResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryRoutesResponse.DiscardUnknown(m) } @@ -429,8 +476,10 @@ var fileDescriptor_f6ec0dbd7f0bdd2b = []byte{ } // Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn +var ( + _ context.Context + _ grpc.ClientConn +) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. @@ -532,27 +581,32 @@ type QueryServer interface { } // UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} +type UnimplementedQueryServer struct{} func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } + func (*UnimplementedQueryServer) SourceRoutes(ctx context.Context, req *QuerySourceRequest) (*QueryRoutesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SourceRoutes not implemented") } + func (*UnimplementedQueryServer) DestinationRoutes(ctx context.Context, req *QueryDestinationRequest) (*QueryRoutesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DestinationRoutes not implemented") } + func (*UnimplementedQueryServer) DestinationRoutedEnergy(ctx context.Context, req *QueryDestinationRequest) (*QueryRoutedEnergyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DestinationRoutedEnergy not implemented") } + func (*UnimplementedQueryServer) SourceRoutedEnergy(ctx context.Context, req *QuerySourceRequest) (*QueryRoutedEnergyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SourceRoutedEnergy not implemented") } + func (*UnimplementedQueryServer) Route(ctx context.Context, req *QueryRouteRequest) (*QueryRouteResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Route not implemented") } + func (*UnimplementedQueryServer) Routes(ctx context.Context, req *QueryRoutesRequest) (*QueryRoutesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Routes not implemented") } @@ -1042,6 +1096,7 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *QueryParamsRequest) Size() (n int) { if m == nil { return 0 @@ -1166,9 +1221,11 @@ func (m *QueryRoutesResponse) Size() (n int) { func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1219,6 +1276,7 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1302,6 +1360,7 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QuerySourceRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1384,6 +1443,7 @@ func (m *QuerySourceRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryDestinationRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1466,6 +1526,7 @@ func (m *QueryDestinationRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryRoutedEnergyResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1550,6 +1611,7 @@ func (m *QueryRoutedEnergyResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryRouteRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1664,6 +1726,7 @@ func (m *QueryRouteRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryRouteResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1747,6 +1810,7 @@ func (m *QueryRouteResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryRoutesRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1833,6 +1897,7 @@ func (m *QueryRoutesRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryRoutesResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1953,6 +2018,7 @@ func (m *QueryRoutesResponse) Unmarshal(dAtA []byte) error { } return nil } + func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/grid/types/query.pb.gw.go b/x/grid/types/query.pb.gw.go index 052890d..6e782ff 100644 --- a/x/grid/types/query.pb.gw.go +++ b/x/grid/types/query.pb.gw.go @@ -24,12 +24,14 @@ import ( ) // Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = runtime.String + _ = utilities.NewDoubleArray + _ = descriptor.ForMessage +) func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -37,7 +39,6 @@ func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, cl msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -46,12 +47,9 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal msg, err := server.Params(ctx, &protoReq) return msg, metadata, err - } -var ( - filter_Query_SourceRoutes_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) +var filter_Query_SourceRoutes_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_Query_SourceRoutes_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QuerySourceRequest @@ -66,7 +64,6 @@ func request_Query_SourceRoutes_0(ctx context.Context, marshaler runtime.Marshal msg, err := client.SourceRoutes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_SourceRoutes_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -82,12 +79,9 @@ func local_request_Query_SourceRoutes_0(ctx context.Context, marshaler runtime.M msg, err := server.SourceRoutes(ctx, &protoReq) return msg, metadata, err - } -var ( - filter_Query_DestinationRoutes_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) +var filter_Query_DestinationRoutes_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_Query_DestinationRoutes_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryDestinationRequest @@ -102,7 +96,6 @@ func request_Query_DestinationRoutes_0(ctx context.Context, marshaler runtime.Ma msg, err := client.DestinationRoutes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_DestinationRoutes_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -118,12 +111,9 @@ func local_request_Query_DestinationRoutes_0(ctx context.Context, marshaler runt msg, err := server.DestinationRoutes(ctx, &protoReq) return msg, metadata, err - } -var ( - filter_Query_DestinationRoutedEnergy_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) +var filter_Query_DestinationRoutedEnergy_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_Query_DestinationRoutedEnergy_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryDestinationRequest @@ -138,7 +128,6 @@ func request_Query_DestinationRoutedEnergy_0(ctx context.Context, marshaler runt msg, err := client.DestinationRoutedEnergy(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_DestinationRoutedEnergy_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -154,12 +143,9 @@ func local_request_Query_DestinationRoutedEnergy_0(ctx context.Context, marshale msg, err := server.DestinationRoutedEnergy(ctx, &protoReq) return msg, metadata, err - } -var ( - filter_Query_SourceRoutedEnergy_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) +var filter_Query_SourceRoutedEnergy_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_Query_SourceRoutedEnergy_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QuerySourceRequest @@ -174,7 +160,6 @@ func request_Query_SourceRoutedEnergy_0(ctx context.Context, marshaler runtime.M msg, err := client.SourceRoutedEnergy(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_SourceRoutedEnergy_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -190,12 +175,9 @@ func local_request_Query_SourceRoutedEnergy_0(ctx context.Context, marshaler run msg, err := server.SourceRoutedEnergy(ctx, &protoReq) return msg, metadata, err - } -var ( - filter_Query_Route_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) +var filter_Query_Route_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_Query_Route_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryRouteRequest @@ -210,7 +192,6 @@ func request_Query_Route_0(ctx context.Context, marshaler runtime.Marshaler, cli msg, err := client.Route(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Route_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -226,12 +207,9 @@ func local_request_Query_Route_0(ctx context.Context, marshaler runtime.Marshale msg, err := server.Route(ctx, &protoReq) return msg, metadata, err - } -var ( - filter_Query_Routes_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) +var filter_Query_Routes_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_Query_Routes_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryRoutesRequest @@ -246,7 +224,6 @@ func request_Query_Routes_0(ctx context.Context, marshaler runtime.Marshaler, cl msg, err := client.Routes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Routes_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -262,7 +239,6 @@ func local_request_Query_Routes_0(ctx context.Context, marshaler runtime.Marshal msg, err := server.Routes(ctx, &protoReq) return msg, metadata, err - } // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". @@ -270,7 +246,6 @@ func local_request_Query_Routes_0(ctx context.Context, marshaler runtime.Marshal // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -288,7 +263,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_SourceRoutes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -308,7 +282,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_SourceRoutes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_DestinationRoutes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -328,7 +301,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_DestinationRoutes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_DestinationRoutedEnergy_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -348,7 +320,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_DestinationRoutedEnergy_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_SourceRoutedEnergy_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -368,7 +339,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_SourceRoutedEnergy_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Route_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -388,7 +358,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Route_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Routes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -408,7 +377,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Routes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) return nil @@ -451,7 +419,6 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -469,7 +436,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_SourceRoutes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -489,7 +455,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_SourceRoutes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_DestinationRoutes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -509,7 +474,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_DestinationRoutes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_DestinationRoutedEnergy_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -529,7 +493,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_DestinationRoutedEnergy_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_SourceRoutedEnergy_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -549,7 +512,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_SourceRoutedEnergy_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Route_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -569,7 +531,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Route_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Routes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -589,7 +550,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Routes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) return nil diff --git a/x/grid/types/route.go b/x/grid/types/route.go index 4f7d5c9..a2252c8 100644 --- a/x/grid/types/route.go +++ b/x/grid/types/route.go @@ -39,4 +39,4 @@ func MustUnmarshalRoute(cdc codec.BinaryCodec, value []byte) Route { func UnmarshalRoute(cdc codec.BinaryCodec, value []byte) (route Route, err error) { err = cdc.Unmarshal(value, &route) return route, err -} \ No newline at end of file +} diff --git a/x/grid/types/tx.pb.go b/x/grid/types/tx.pb.go index 1b1c466..ea6968b 100644 --- a/x/grid/types/tx.pb.go +++ b/x/grid/types/tx.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-sdk/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" @@ -14,15 +18,14 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -42,9 +45,11 @@ func (*MsgCreateRoute) ProtoMessage() {} func (*MsgCreateRoute) Descriptor() ([]byte, []int) { return fileDescriptor_c3762e80adb8270a, []int{0} } + func (m *MsgCreateRoute) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgCreateRoute) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgCreateRoute.Marshal(b, m, deterministic) @@ -57,12 +62,15 @@ func (m *MsgCreateRoute) XXX_Marshal(b []byte, deterministic bool) ([]byte, erro return b[:n], nil } } + func (m *MsgCreateRoute) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgCreateRoute.Merge(m, src) } + func (m *MsgCreateRoute) XXX_Size() int { return m.Size() } + func (m *MsgCreateRoute) XXX_DiscardUnknown() { xxx_messageInfo_MsgCreateRoute.DiscardUnknown(m) } @@ -81,9 +89,11 @@ func (*MsgEditRoute) ProtoMessage() {} func (*MsgEditRoute) Descriptor() ([]byte, []int) { return fileDescriptor_c3762e80adb8270a, []int{1} } + func (m *MsgEditRoute) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgEditRoute) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgEditRoute.Marshal(b, m, deterministic) @@ -96,12 +106,15 @@ func (m *MsgEditRoute) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } + func (m *MsgEditRoute) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgEditRoute.Merge(m, src) } + func (m *MsgEditRoute) XXX_Size() int { return m.Size() } + func (m *MsgEditRoute) XXX_DiscardUnknown() { xxx_messageInfo_MsgEditRoute.DiscardUnknown(m) } @@ -119,9 +132,11 @@ func (*MsgDeleteRoute) ProtoMessage() {} func (*MsgDeleteRoute) Descriptor() ([]byte, []int) { return fileDescriptor_c3762e80adb8270a, []int{2} } + func (m *MsgDeleteRoute) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgDeleteRoute) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgDeleteRoute.Marshal(b, m, deterministic) @@ -134,12 +149,15 @@ func (m *MsgDeleteRoute) XXX_Marshal(b []byte, deterministic bool) ([]byte, erro return b[:n], nil } } + func (m *MsgDeleteRoute) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgDeleteRoute.Merge(m, src) } + func (m *MsgDeleteRoute) XXX_Size() int { return m.Size() } + func (m *MsgDeleteRoute) XXX_DiscardUnknown() { xxx_messageInfo_MsgDeleteRoute.DiscardUnknown(m) } @@ -158,9 +176,11 @@ func (*MsgEditRouteName) ProtoMessage() {} func (*MsgEditRouteName) Descriptor() ([]byte, []int) { return fileDescriptor_c3762e80adb8270a, []int{3} } + func (m *MsgEditRouteName) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgEditRouteName) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgEditRouteName.Marshal(b, m, deterministic) @@ -173,20 +193,22 @@ func (m *MsgEditRouteName) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } + func (m *MsgEditRouteName) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgEditRouteName.Merge(m, src) } + func (m *MsgEditRouteName) XXX_Size() int { return m.Size() } + func (m *MsgEditRouteName) XXX_DiscardUnknown() { xxx_messageInfo_MsgEditRouteName.DiscardUnknown(m) } var xxx_messageInfo_MsgEditRouteName proto.InternalMessageInfo -type MsgCreateRouteResponse struct { -} +type MsgCreateRouteResponse struct{} func (m *MsgCreateRouteResponse) Reset() { *m = MsgCreateRouteResponse{} } func (m *MsgCreateRouteResponse) String() string { return proto.CompactTextString(m) } @@ -194,9 +216,11 @@ func (*MsgCreateRouteResponse) ProtoMessage() {} func (*MsgCreateRouteResponse) Descriptor() ([]byte, []int) { return fileDescriptor_c3762e80adb8270a, []int{4} } + func (m *MsgCreateRouteResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgCreateRouteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgCreateRouteResponse.Marshal(b, m, deterministic) @@ -209,20 +233,22 @@ func (m *MsgCreateRouteResponse) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } + func (m *MsgCreateRouteResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgCreateRouteResponse.Merge(m, src) } + func (m *MsgCreateRouteResponse) XXX_Size() int { return m.Size() } + func (m *MsgCreateRouteResponse) XXX_DiscardUnknown() { xxx_messageInfo_MsgCreateRouteResponse.DiscardUnknown(m) } var xxx_messageInfo_MsgCreateRouteResponse proto.InternalMessageInfo -type MsgEditRouteResponse struct { -} +type MsgEditRouteResponse struct{} func (m *MsgEditRouteResponse) Reset() { *m = MsgEditRouteResponse{} } func (m *MsgEditRouteResponse) String() string { return proto.CompactTextString(m) } @@ -230,9 +256,11 @@ func (*MsgEditRouteResponse) ProtoMessage() {} func (*MsgEditRouteResponse) Descriptor() ([]byte, []int) { return fileDescriptor_c3762e80adb8270a, []int{5} } + func (m *MsgEditRouteResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgEditRouteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgEditRouteResponse.Marshal(b, m, deterministic) @@ -245,20 +273,22 @@ func (m *MsgEditRouteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte return b[:n], nil } } + func (m *MsgEditRouteResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgEditRouteResponse.Merge(m, src) } + func (m *MsgEditRouteResponse) XXX_Size() int { return m.Size() } + func (m *MsgEditRouteResponse) XXX_DiscardUnknown() { xxx_messageInfo_MsgEditRouteResponse.DiscardUnknown(m) } var xxx_messageInfo_MsgEditRouteResponse proto.InternalMessageInfo -type MsgDeleteRouteResponse struct { -} +type MsgDeleteRouteResponse struct{} func (m *MsgDeleteRouteResponse) Reset() { *m = MsgDeleteRouteResponse{} } func (m *MsgDeleteRouteResponse) String() string { return proto.CompactTextString(m) } @@ -266,9 +296,11 @@ func (*MsgDeleteRouteResponse) ProtoMessage() {} func (*MsgDeleteRouteResponse) Descriptor() ([]byte, []int) { return fileDescriptor_c3762e80adb8270a, []int{6} } + func (m *MsgDeleteRouteResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgDeleteRouteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgDeleteRouteResponse.Marshal(b, m, deterministic) @@ -281,20 +313,22 @@ func (m *MsgDeleteRouteResponse) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } + func (m *MsgDeleteRouteResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgDeleteRouteResponse.Merge(m, src) } + func (m *MsgDeleteRouteResponse) XXX_Size() int { return m.Size() } + func (m *MsgDeleteRouteResponse) XXX_DiscardUnknown() { xxx_messageInfo_MsgDeleteRouteResponse.DiscardUnknown(m) } var xxx_messageInfo_MsgDeleteRouteResponse proto.InternalMessageInfo -type MsgEditRouteNameResponse struct { -} +type MsgEditRouteNameResponse struct{} func (m *MsgEditRouteNameResponse) Reset() { *m = MsgEditRouteNameResponse{} } func (m *MsgEditRouteNameResponse) String() string { return proto.CompactTextString(m) } @@ -302,9 +336,11 @@ func (*MsgEditRouteNameResponse) ProtoMessage() {} func (*MsgEditRouteNameResponse) Descriptor() ([]byte, []int) { return fileDescriptor_c3762e80adb8270a, []int{7} } + func (m *MsgEditRouteNameResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgEditRouteNameResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgEditRouteNameResponse.Marshal(b, m, deterministic) @@ -317,12 +353,15 @@ func (m *MsgEditRouteNameResponse) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } + func (m *MsgEditRouteNameResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgEditRouteNameResponse.Merge(m, src) } + func (m *MsgEditRouteNameResponse) XXX_Size() int { return m.Size() } + func (m *MsgEditRouteNameResponse) XXX_DiscardUnknown() { xxx_messageInfo_MsgEditRouteNameResponse.DiscardUnknown(m) } @@ -376,8 +415,10 @@ var fileDescriptor_c3762e80adb8270a = []byte{ } // Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn +var ( + _ context.Context + _ grpc.ClientConn +) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. @@ -446,18 +487,20 @@ type MsgServer interface { } // UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} +type UnimplementedMsgServer struct{} func (*UnimplementedMsgServer) CreateRoute(ctx context.Context, req *MsgCreateRoute) (*MsgCreateRouteResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateRoute not implemented") } + func (*UnimplementedMsgServer) EditRoute(ctx context.Context, req *MsgEditRoute) (*MsgEditRouteResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method EditRoute not implemented") } + func (*UnimplementedMsgServer) DeleteRoute(ctx context.Context, req *MsgDeleteRoute) (*MsgDeleteRouteResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DeleteRoute not implemented") } + func (*UnimplementedMsgServer) EditRouteName(ctx context.Context, req *MsgEditRouteName) (*MsgEditRouteNameResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method EditRouteName not implemented") } @@ -838,6 +881,7 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *MsgCreateRoute) Size() (n int) { if m == nil { return 0 @@ -955,9 +999,11 @@ func (m *MsgEditRouteNameResponse) Size() (n int) { func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *MsgCreateRoute) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1104,6 +1150,7 @@ func (m *MsgCreateRoute) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgEditRoute) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1251,6 +1298,7 @@ func (m *MsgEditRoute) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgDeleteRoute) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1365,6 +1413,7 @@ func (m *MsgDeleteRoute) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgEditRouteName) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1511,6 +1560,7 @@ func (m *MsgEditRouteName) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgCreateRouteResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1561,6 +1611,7 @@ func (m *MsgCreateRouteResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgEditRouteResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1611,6 +1662,7 @@ func (m *MsgEditRouteResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgDeleteRouteResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1661,6 +1713,7 @@ func (m *MsgDeleteRouteResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgEditRouteNameResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1711,6 +1764,7 @@ func (m *MsgEditRouteNameResponse) Unmarshal(dAtA []byte) error { } return nil } + func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/grid/types/types.pb.go b/x/grid/types/types.pb.go index 2837b87..2643e30 100644 --- a/x/grid/types/types.pb.go +++ b/x/grid/types/types.pb.go @@ -5,19 +5,22 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -35,9 +38,11 @@ func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { return fileDescriptor_1673181069a7f05c, []int{0} } + func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_Params.Marshal(b, m, deterministic) @@ -50,12 +55,15 @@ func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } + func (m *Params) XXX_Merge(src proto.Message) { xxx_messageInfo_Params.Merge(m, src) } + func (m *Params) XXX_Size() int { return m.Size() } + func (m *Params) XXX_DiscardUnknown() { xxx_messageInfo_Params.DiscardUnknown(m) } @@ -82,9 +90,11 @@ func (*Route) ProtoMessage() {} func (*Route) Descriptor() ([]byte, []int) { return fileDescriptor_1673181069a7f05c, []int{1} } + func (m *Route) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *Route) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_Route.Marshal(b, m, deterministic) @@ -97,12 +107,15 @@ func (m *Route) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } + func (m *Route) XXX_Merge(src proto.Message) { xxx_messageInfo_Route.Merge(m, src) } + func (m *Route) XXX_Size() int { return m.Size() } + func (m *Route) XXX_DiscardUnknown() { xxx_messageInfo_Route.DiscardUnknown(m) } @@ -119,9 +132,11 @@ func (*Value) ProtoMessage() {} func (*Value) Descriptor() ([]byte, []int) { return fileDescriptor_1673181069a7f05c, []int{2} } + func (m *Value) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *Value) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_Value.Marshal(b, m, deterministic) @@ -134,12 +149,15 @@ func (m *Value) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } + func (m *Value) XXX_Merge(src proto.Message) { xxx_messageInfo_Value.Merge(m, src) } + func (m *Value) XXX_Size() int { return m.Size() } + func (m *Value) XXX_DiscardUnknown() { xxx_messageInfo_Value.DiscardUnknown(m) } @@ -204,6 +222,7 @@ func (this *Params) Equal(that interface{}) bool { } return true } + func (m *Params) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -338,6 +357,7 @@ func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *Params) Size() (n int) { if m == nil { return 0 @@ -395,9 +415,11 @@ func (m *Value) Size() (n int) { func sovTypes(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozTypes(x uint64) (n int) { return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *Params) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -467,6 +489,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } + func (m *Route) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -647,6 +670,7 @@ func (m *Route) Unmarshal(dAtA []byte) error { } return nil } + func (m *Value) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -731,6 +755,7 @@ func (m *Value) Unmarshal(dAtA []byte) error { } return nil } + func skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/grid/wasm/interface.go b/x/grid/wasm/interface.go index 327246b..94fb63e 100644 --- a/x/grid/wasm/interface.go +++ b/x/grid/wasm/interface.go @@ -8,6 +8,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" wasmvmtypes "github.com/CosmWasm/wasmvm/types" + wasmplugins "github.com/cybercongress/go-cyber/plugins" "github.com/cybercongress/go-cyber/x/grid/keeper" "github.com/cybercongress/go-cyber/x/grid/types" @@ -28,13 +29,15 @@ func NewWasmMsgParser() WasmMsgParser { return WasmMsgParser{} } -func (WasmMsgParser) Parse(_ sdk.AccAddress, _ wasmvmtypes.CosmosMsg) ([]sdk.Msg, error) { return nil, nil } +func (WasmMsgParser) Parse(_ sdk.AccAddress, _ wasmvmtypes.CosmosMsg) ([]sdk.Msg, error) { + return nil, nil +} type CosmosMsg struct { - CreateEnergyRoute *types.MsgCreateRoute `json:"create_energy_route,omitempty"` - EditEnergyRoute *types.MsgEditRoute `json:"edit_energy_route,omitempty"` - EditEnergyRouteName *types.MsgEditRouteName `json:"edit_energy_route_name,omitempty"` - DeleteEnergyRoute *types.MsgDeleteRoute `json:"delete_energy_route,omitempty"` + CreateEnergyRoute *types.MsgCreateRoute `json:"create_energy_route,omitempty"` + EditEnergyRoute *types.MsgEditRoute `json:"edit_energy_route,omitempty"` + EditEnergyRouteName *types.MsgEditRouteName `json:"edit_energy_route_name,omitempty"` + DeleteEnergyRoute *types.MsgDeleteRoute `json:"delete_energy_route,omitempty"` } func (WasmMsgParser) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessage) ([]sdk.Msg, error) { @@ -79,17 +82,17 @@ func NewWasmQuerier(keeper keeper.Keeper) WasmQuerier { func (WasmQuerier) Query(_ sdk.Context, _ wasmvmtypes.QueryRequest) ([]byte, error) { return nil, nil } type CosmosQuery struct { - SourceRoutes *QuerySourceParams `json:"source_routes,omitempty"` - SourceRoutedEnergy *QuerySourceParams `json:"source_routed_energy,omitempty"` + SourceRoutes *QuerySourceParams `json:"source_routes,omitempty"` + SourceRoutedEnergy *QuerySourceParams `json:"source_routed_energy,omitempty"` DestinationRoutedEnergy *QueryDestinationParams `json:"destination_routed_energy,omitempty"` - Route *QueryRouteParams `json:"route,omitempty"` + Route *QueryRouteParams `json:"route,omitempty"` } type Route struct { - Source string `json:"source"` - Destination string `json:"destination"` - Name string `json:"name"` - Value wasmvmtypes.Coins `json:"value"` + Source string `json:"source"` + Destination string `json:"destination"` + Name string `json:"name"` + Value wasmvmtypes.Coins `json:"value"` } type Routes []Route @@ -103,7 +106,7 @@ type QueryDestinationParams struct { } type QueryRouteParams struct { - Source string `json:"source"` + Source string `json:"source"` Destination string `json:"destination"` } @@ -122,7 +125,6 @@ type RouteResponse struct { func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) { var query CosmosQuery err := json.Unmarshal(data, &query) - if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } @@ -153,7 +155,8 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ } else if query.Route != nil { source, _ := sdk.AccAddressFromBech32(query.Route.Source) destination, _ := sdk.AccAddressFromBech32(query.Route.Destination) - route, found := querier.Keeper.GetRoute(ctx, source, destination); if found != true { + route, found := querier.Keeper.GetRoute(ctx, source, destination) + if found != true { return nil, sdkerrors.ErrInvalidRequest } @@ -185,4 +188,4 @@ func convertCyberRouteToWasmRoute(route types.Route) Route { route.Name, wasmplugins.ConvertSdkCoinsToWasmCoins(route.Value), } -} \ No newline at end of file +} diff --git a/x/rank/abci.go b/x/rank/abci.go index 30ce11e..03c426f 100644 --- a/x/rank/abci.go +++ b/x/rank/abci.go @@ -8,4 +8,4 @@ import ( func EndBlocker(ctx sdk.Context, k *keeper.StateKeeper) { k.EndBlocker(ctx) -} \ No newline at end of file +} diff --git a/x/rank/client/cli/query.go b/x/rank/client/cli/query.go index 448ce7c..3757b64 100644 --- a/x/rank/client/cli/query.go +++ b/x/rank/client/cli/query.go @@ -7,10 +7,11 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" sdk "github.com/cosmos/cosmos-sdk/types" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" "github.com/ipfs/go-cid" "github.com/spf13/cobra" + graphtypes "github.com/cybercongress/go-cyber/x/graph/types" + "github.com/cybercongress/go-cyber/types/query" "github.com/cybercongress/go-cyber/x/rank/types" ) @@ -40,7 +41,6 @@ func GetQueryCmd() *cobra.Command { return rankingQueryCmd } - func GetCmdQueryParams() *cobra.Command { cmd := &cobra.Command{ Use: "params", @@ -70,7 +70,7 @@ func GetCmdQueryParams() *cobra.Command { return cmd } -func GetCmdQueryRank() *cobra.Command{ +func GetCmdQueryRank() *cobra.Command { cmd := &cobra.Command{ Use: "rank [particle]", Short: "Query the current rank of given particle", @@ -103,7 +103,7 @@ func GetCmdQueryRank() *cobra.Command{ return cmd } -func GetCmdQuerySearch() *cobra.Command{ +func GetCmdQuerySearch() *cobra.Command { cmd := &cobra.Command{ Use: "search [particle] [page] [limit]", Short: "Query search of given particle", @@ -153,7 +153,7 @@ func GetCmdQuerySearch() *cobra.Command{ return cmd } -func GetCmdQueryBacklinks() *cobra.Command{ +func GetCmdQueryBacklinks() *cobra.Command { cmd := &cobra.Command{ Use: "backlinks [particle] [page] [limit]", Short: "Query backlinks of given particle", @@ -203,7 +203,7 @@ func GetCmdQueryBacklinks() *cobra.Command{ return cmd } -func GetCmdQueryTop() *cobra.Command{ +func GetCmdQueryTop() *cobra.Command { cmd := &cobra.Command{ Use: "top", Short: "Query top", @@ -249,7 +249,7 @@ func GetCmdQueryTop() *cobra.Command{ return cmd } -func GetCmdQueryIsLinkExist() *cobra.Command{ +func GetCmdQueryIsLinkExist() *cobra.Command { cmd := &cobra.Command{ Use: "is-exist [from] [to] [account]", Short: "Query is link exist between particles for given account", @@ -291,7 +291,7 @@ func GetCmdQueryIsLinkExist() *cobra.Command{ return cmd } -func GetCmdQueryIsAnyLinkExist() *cobra.Command{ +func GetCmdQueryIsAnyLinkExist() *cobra.Command { cmd := &cobra.Command{ Use: "is-exist-any [from] [to]", Short: "Query is any link exist between particles", @@ -328,7 +328,7 @@ func GetCmdQueryIsAnyLinkExist() *cobra.Command{ return cmd } -func GetCmdQueryNegentropyParticle() *cobra.Command{ +func GetCmdQueryNegentropyParticle() *cobra.Command { cmd := &cobra.Command{ Use: "negentropy [particle]", Short: "Query the current negentropy of given particle", @@ -361,7 +361,7 @@ func GetCmdQueryNegentropyParticle() *cobra.Command{ return cmd } -func GetCmdQueryNegentropy() *cobra.Command{ +func GetCmdQueryNegentropy() *cobra.Command { cmd := &cobra.Command{ Use: "negentropy", Short: "Query the current negentropy of whole graph", @@ -390,7 +390,7 @@ func GetCmdQueryNegentropy() *cobra.Command{ return cmd } -func GetCmdQueryKarma() *cobra.Command{ +func GetCmdQueryKarma() *cobra.Command { cmd := &cobra.Command{ Use: "karma [neuron]", Short: "Query the current karma of given neuron", @@ -422,4 +422,4 @@ func GetCmdQueryKarma() *cobra.Command{ flags.AddQueryFlagsToCmd(cmd) return cmd -} \ No newline at end of file +} diff --git a/x/rank/client/rest/query.go b/x/rank/client/rest/query.go index 51f5902..b59b41a 100644 --- a/x/rank/client/rest/query.go +++ b/x/rank/client/rest/query.go @@ -51,7 +51,6 @@ func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { func queryParamsHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryParameters) res, height, err := cliCtx.QueryWithData(route, nil) @@ -453,5 +452,3 @@ func queryKarmaHandlerFn(cliCtx client.Context) http.HandlerFunc { rest.PostProcessResponse(w, cliCtx, res) } } - - diff --git a/x/rank/client/rest/rest.go b/x/rank/client/rest/rest.go index cefc7ec..eee7f72 100644 --- a/x/rank/client/rest/rest.go +++ b/x/rank/client/rest/rest.go @@ -1,8 +1,8 @@ package rest import ( - "github.com/gorilla/mux" "github.com/cosmos/cosmos-sdk/client" + "github.com/gorilla/mux" ) func RegisterRoutes(cliCtx client.Context, r *mux.Router) { diff --git a/x/rank/keeper/calculate.go b/x/rank/keeper/calculate.go index 4cef255..d269b96 100644 --- a/x/rank/keeper/calculate.go +++ b/x/rank/keeper/calculate.go @@ -1,15 +1,15 @@ package keeper import ( + "fmt" "runtime/debug" + "time" "github.com/cosmos/cosmos-sdk/telemetry" + "github.com/cybercongress/go-cyber/x/rank/types" "github.com/tendermint/tendermint/libs/log" - - "fmt" - "time" ) func CalculateRank(ctx *types.CalculationContext, unit types.ComputeUnit, logger log.Logger) (rank types.Rank) { @@ -17,7 +17,7 @@ func CalculateRank(ctx *types.CalculationContext, unit types.ComputeUnit, logger defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), "rank_calculation") if unit == types.CPU { - //used only for development + // used only for development rank = types.NewRank(calculateRankCPU(ctx), logger, ctx.FullTree) } else { rank = types.NewRank(calculateRankGPU(ctx, logger), logger, ctx.FullTree) diff --git a/x/rank/keeper/calculate_cpu.go b/x/rank/keeper/calculate_cpu.go index 16df1b8..a0b7bde 100755 --- a/x/rank/keeper/calculate_cpu.go +++ b/x/rank/keeper/calculate_cpu.go @@ -9,15 +9,13 @@ import ( "github.com/cybercongress/go-cyber/x/rank/types" ) - func calculateRankCPU(ctx *types.CalculationContext) types.EMState { - inLinks := ctx.GetInLinks() tolerance := ctx.GetTolerance() dampingFactor := ctx.GetDampingFactor() size := ctx.GetCidsCount() - if size == 0 || len(ctx.GetStakes()) == 0 { + if size == 0 || len(ctx.GetStakes()) == 0 { return types.EMState{ []float64{}, []float64{}, @@ -65,7 +63,6 @@ func calculateRankCPU(ctx *types.CalculationContext) types.EMState { } func step(ctx *types.CalculationContext, defaultRankWithCorrection float64, dampingFactor float64, prevrank []float64) []float64 { - rank := append(make([]float64, 0, len(prevrank)), prevrank...) for cid := range ctx.GetInLinks() { @@ -82,10 +79,10 @@ func step(ctx *types.CalculationContext, defaultRankWithCorrection float64, damp continue } weight := float64(linkStake) / float64(jCidOutStake) - //if math.IsNaN(weight) { weight = float64(0) } - ksum = prevrank[j]*weight + ksum //force no-fma here by explicit conversion + // if math.IsNaN(weight) { weight = float64(0) } + ksum = prevrank[j]*weight + ksum // force no-fma here by explicit conversion } - rank[cid] = ksum*dampingFactor + defaultRankWithCorrection //force no-fma here by explicit conversion + rank[cid] = ksum*dampingFactor + defaultRankWithCorrection // force no-fma here by explicit conversion } } @@ -93,18 +90,16 @@ func step(ctx *types.CalculationContext, defaultRankWithCorrection float64, damp } func getOverallLinkStake(ctx *types.CalculationContext, from graphtypes.CidNumber, to graphtypes.CidNumber) uint64 { - stake := uint64(0) users := ctx.GetOutLinks()[from][to] for user := range users { - //stake += ctx.GetStakes()[uint64(user)] + // stake += ctx.GetStakes()[uint64(user)] stake += getNormalizedStake(ctx, uint64(user)) } return stake } func getOverallOutLinksStake(ctx *types.CalculationContext, from graphtypes.CidNumber) uint64 { - stake := uint64(0) for to := range ctx.GetOutLinks()[from] { stake += getOverallLinkStake(ctx, from, to) @@ -113,7 +108,6 @@ func getOverallOutLinksStake(ctx *types.CalculationContext, from graphtypes.CidN } func getOverallInLinksStake(ctx *types.CalculationContext, from graphtypes.CidNumber) uint64 { - stake := uint64(0) for to := range ctx.GetInLinks()[from] { stake += getOverallLinkStake(ctx, to, from) // reverse order here @@ -126,7 +120,6 @@ func getNormalizedStake(ctx *types.CalculationContext, agent uint64) uint64 { } func calculateChange(prevrank, rank []float64) float64 { - maxDiff := 0.0 diff := 0.0 for i, pForI := range prevrank { @@ -146,13 +139,13 @@ func calculateChange(prevrank, rank []float64) float64 { func entropyCalc(ctx *types.CalculationContext, entropy []float64, cidsCount int64, dampingFactor float64) { swd := make([]float64, cidsCount) sumswd := make([]float64, cidsCount) - for i, _ := range swd { + for i := range swd { swd[i] = dampingFactor*float64( getOverallInLinksStake(ctx, graphtypes.CidNumber(i))) + (1-dampingFactor)*float64( getOverallOutLinksStake(ctx, graphtypes.CidNumber(i))) } - for i, _ := range sumswd { + for i := range sumswd { for to := range ctx.GetInLinks()[graphtypes.CidNumber(i)] { sumswd[i] += dampingFactor * swd[to] } @@ -161,14 +154,20 @@ func entropyCalc(ctx *types.CalculationContext, entropy []float64, cidsCount int } } - for i, _ := range entropy { - if swd[i] == 0 { continue } + for i := range entropy { + if swd[i] == 0 { + continue + } for to := range ctx.GetInLinks()[graphtypes.CidNumber(i)] { - if sumswd[to] == 0 { continue } + if sumswd[to] == 0 { + continue + } entropy[i] += math.Abs(-swd[i] / sumswd[to] * math.Log2(swd[i]/sumswd[to])) } for to := range ctx.GetOutLinks()[graphtypes.CidNumber(i)] { - if sumswd[to] == 0 { continue } + if sumswd[to] == 0 { + continue + } entropy[i] += math.Abs(-swd[i] / sumswd[to] * math.Log2(swd[i]/sumswd[to])) } } @@ -178,16 +177,22 @@ func karmaCalc(ctx *types.CalculationContext, rank []float64, entropy []float64, for from := range ctx.GetOutLinks() { stake := getOverallOutLinksStake(ctx, from) for to := range ctx.GetOutLinks()[from] { - if (stake == 0) { continue } + if stake == 0 { + continue + } users := ctx.GetOutLinks()[from][to] for user := range users { - //if (ctx.GetStakes()[uint64(user)] == 0) { continue } - if getNormalizedStake(ctx, uint64(user)) == 0 { continue } - //w := float64(ctx.GetStakes()[uint64(user)]) / float64(stake) + // if (ctx.GetStakes()[uint64(user)] == 0) { continue } + if getNormalizedStake(ctx, uint64(user)) == 0 { + continue + } + // w := float64(ctx.GetStakes()[uint64(user)]) / float64(stake) w := float64(getNormalizedStake(ctx, uint64(user))) / float64(stake) - if math.IsNaN(w) { w = float64(0) } + if math.IsNaN(w) { + w = float64(0) + } luminosity := rank[from] * entropy[from] - karma[user] += w*float64(luminosity) + karma[user] += w * float64(luminosity) } } } diff --git a/x/rank/keeper/calculate_gpu.go b/x/rank/keeper/calculate_gpu.go index a4a33f4..d0a7c8d 100755 --- a/x/rank/keeper/calculate_gpu.go +++ b/x/rank/keeper/calculate_gpu.go @@ -1,14 +1,15 @@ +//go:build cuda // +build cuda package keeper import ( + "time" + "github.com/tendermint/tendermint/libs/log" graphtypes "github.com/cybercongress/go-cyber/x/graph/types" "github.com/cybercongress/go-cyber/x/rank/types" - - "time" ) /* @@ -22,9 +23,9 @@ func calculateRankGPU(ctx *types.CalculationContext, logger log.Logger) types.EM start := time.Now() if ctx.GetCidsCount() == 0 { return types.EMState{ - RankValues: make([]float64, 0), - EntropyValues: make([]float64, 0), - KarmaValues: make([]float64, 0), + RankValues: make([]float64, 0), + EntropyValues: make([]float64, 0), + KarmaValues: make([]float64, 0), } } @@ -61,7 +62,7 @@ func calculateRankGPU(ctx *types.CalculationContext, logger log.Logger) types.EM if inLinks, sortedCids, ok := ctx.GetSortedInLinks(graphtypes.CidNumber(i)); ok { for _, cid := range sortedCids { - inLinksCount[i] += uint32(len(inLinks[cid])) + inLinksCount[i] += uint32(len(inLinks[cid])) for acc := range inLinks[cid] { inLinksOuts = append(inLinksOuts, uint64(cid)) inLinksUsers = append(inLinksUsers, uint64(acc)) @@ -109,17 +110,17 @@ func calculateRankGPU(ctx *types.CalculationContext, logger log.Logger) types.EM C.calculate_rank( cStakes, cStakesSize, cCidsSize, cLinksSize, cInLinksCount, cOutLinksCount, - cInLinksOuts, cOutLinksIns, + cInLinksOuts, cOutLinksIns, cInLinksUsers, cOutLinksUsers, cDampingFactor, cTolerance, cRank, cEntropy, cLuminosity, cKarma, ) logger.Info("Rank computation", "duration", time.Since(start).String()) - //return rank + // return rank return types.EMState{ - RankValues: rank, - EntropyValues: entropy, - KarmaValues: karma, + RankValues: rank, + EntropyValues: entropy, + KarmaValues: karma, } } diff --git a/x/rank/keeper/calculate_gpu_nop.go b/x/rank/keeper/calculate_gpu_nop.go index a6cbaad..203965d 100644 --- a/x/rank/keeper/calculate_gpu_nop.go +++ b/x/rank/keeper/calculate_gpu_nop.go @@ -1,3 +1,4 @@ +//go:build !cuda // +build !cuda package keeper diff --git a/x/rank/keeper/genesis.go b/x/rank/keeper/genesis.go index e769ee7..e446441 100644 --- a/x/rank/keeper/genesis.go +++ b/x/rank/keeper/genesis.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cybercongress/go-cyber/x/rank/types" ) diff --git a/x/rank/keeper/grpc_query.go b/x/rank/keeper/grpc_query.go index 1eb8a73..0ae966c 100644 --- a/x/rank/keeper/grpc_query.go +++ b/x/rank/keeper/grpc_query.go @@ -25,7 +25,8 @@ func (bk StateKeeper) Params(goCtx context.Context, _ *types.QueryParamsRequest) func (bk StateKeeper) Rank(goCtx context.Context, req *types.QueryRankRequest) (*types.QueryRankResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - cidNum, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.Particle)); if exist != true { + cidNum, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.Particle)) + if exist != true { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, req.Particle) } @@ -40,7 +41,8 @@ func (bk *StateKeeper) Search(goCtx context.Context, req *types.QuerySearchReque ctx := sdk.UnwrapSDKContext(goCtx) - cidNum, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.Particle)); if exist != true { + cidNum, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.Particle)) + if exist != true { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, "") } @@ -68,7 +70,8 @@ func (bk *StateKeeper) Backlinks(goCtx context.Context, req *types.QuerySearchRe ctx := sdk.UnwrapSDKContext(goCtx) - cidNum, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.Particle)); if exist != true { + cidNum, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.Particle)) + if exist != true { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, req.Particle) } @@ -117,17 +120,20 @@ func (bk StateKeeper) IsLinkExist(goCtx context.Context, req *types.QueryIsLinkE return nil, status.Errorf(codes.InvalidArgument, "empty request") } - addr, err := sdk.AccAddressFromBech32(req.Address); if err != nil { + addr, err := sdk.AccAddressFromBech32(req.Address) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, err.Error()) } ctx := sdk.UnwrapSDKContext(goCtx) - cidNumFrom, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.From)); if exist != true { + cidNumFrom, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.From)) + if exist != true { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, req.From) } - cidNumTo, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.To)); if exist != true { + cidNumTo, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.To)) + if exist != true { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, req.To) } @@ -155,11 +161,13 @@ func (bk StateKeeper) IsAnyLinkExist(goCtx context.Context, req *types.QueryIsAn ctx := sdk.UnwrapSDKContext(goCtx) - cidNumFrom, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.From)); if exist != true { + cidNumFrom, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.From)) + if exist != true { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, req.From) } - cidNumTo, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.To)); if exist != true { + cidNumTo, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.To)) + if exist != true { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, req.To) } @@ -175,7 +183,8 @@ func (s *StateKeeper) ParticleNegentropy(goCtx context.Context, request *types.Q ctx := sdk.UnwrapSDKContext(goCtx) - cidNum, exist := s.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(request.Particle)); if exist != true { + cidNum, exist := s.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(request.Particle)) + if exist != true { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, request.Particle) } @@ -193,7 +202,8 @@ func (s *StateKeeper) Karma(goCtx context.Context, request *types.QueryKarmaRequ return nil, status.Errorf(codes.InvalidArgument, "empty request") } - addr, err := sdk.AccAddressFromBech32(request.Neuron); if err != nil { + addr, err := sdk.AccAddressFromBech32(request.Neuron) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, err.Error()) } diff --git a/x/rank/keeper/keeper.go b/x/rank/keeper/keeper.go index 1131041..517bbe4 100644 --- a/x/rank/keeper/keeper.go +++ b/x/rank/keeper/keeper.go @@ -3,8 +3,11 @@ package keeper import ( "bytes" "encoding/binary" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "fmt" "strconv" + "time" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/keeper" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -17,13 +20,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/tendermint/tendermint/libs/log" - - "fmt" - "time" ) type StateKeeper struct { - networkCidRank types.Rank nextCidRank types.Rank @@ -42,21 +41,21 @@ type StateKeeper struct { graphIndexedKeeper *graphkeeper.IndexKeeper accountKeeper keeper.AccountKeeper - storeKey sdk.StoreKey - paramSpace paramstypes.Subspace + storeKey sdk.StoreKey + paramSpace paramstypes.Subspace index types.SearchIndex getIndexError types.GetError } func NewKeeper( - key sdk.StoreKey, - paramSpace paramstypes.Subspace, - allowSearch bool, - stakeIndex types.StakeKeeper, - graphIndexedKeeper *graphkeeper.IndexKeeper, - graphKeeper types.GraphKeeper, - accountKeeper keeper.AccountKeeper, + key sdk.StoreKey, + paramSpace paramstypes.Subspace, + allowSearch bool, + stakeIndex types.StakeKeeper, + graphIndexedKeeper *graphkeeper.IndexKeeper, + graphKeeper types.GraphKeeper, + accountKeeper keeper.AccountKeeper, unit types.ComputeUnit, ) *StateKeeper { if !paramSpace.HasKeyTable() { @@ -64,18 +63,18 @@ func NewKeeper( } return &StateKeeper{ - storeKey: key, - paramSpace: paramSpace, - allowSearch: allowSearch, - rankCalcChan: make(chan types.Rank, 1), - rankErrChan: make(chan error), + storeKey: key, + paramSpace: paramSpace, + allowSearch: allowSearch, + rankCalcChan: make(chan types.Rank, 1), + rankErrChan: make(chan error), rankCalculationFinished: true, - stakeKeeper: stakeIndex, - graphIndexedKeeper: graphIndexedKeeper, - graphKeeper: graphKeeper, - accountKeeper: accountKeeper, - computeUnit: unit, - hasNewLinksForPeriod: true, + stakeKeeper: stakeIndex, + graphIndexedKeeper: graphIndexedKeeper, + graphKeeper: graphKeeper, + accountKeeper: accountKeeper, + computeUnit: unit, + hasNewLinksForPeriod: true, } } @@ -178,7 +177,6 @@ func (s *StateKeeper) startRankCalculation(ctx sdk.Context, dampingFactor float6 } func (s *StateKeeper) checkRankCalcFinished(ctx sdk.Context, block bool) { - if !s.rankCalculationFinished { for { select { @@ -220,12 +218,15 @@ func (s *StateKeeper) applyNextRank(ctx sdk.Context) { } func (s *StateKeeper) GetRankValueByNumber(number uint64) uint64 { - if number >= uint64(len(s.networkCidRank.RankValues)) { return 0 } + if number >= uint64(len(s.networkCidRank.RankValues)) { + return 0 + } return s.networkCidRank.RankValues[number] } func (s *StateKeeper) GetRankValueByParticle(ctx sdk.Context, particle string) (uint64, error) { - number, exist := s.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(particle)); if exist != true { + number, exist := s.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(particle)) + if exist != true { return 0, sdkerrors.ErrInvalidRequest } return s.networkCidRank.RankValues[number], nil @@ -319,7 +320,7 @@ func (sk StateKeeper) GetNextMerkleTree(ctx sdk.Context) []byte { func (sk StateKeeper) StoreNextMerkleTree(ctx sdk.Context, treeAsBytes []byte) { store := ctx.KVStore(sk.storeKey) - if bytes.Compare(sk.GetNextMerkleTree(ctx), treeAsBytes) !=0 { + if bytes.Compare(sk.GetNextMerkleTree(ctx), treeAsBytes) != 0 { store.Set(types.NextMerkleTree, treeAsBytes) } } @@ -385,4 +386,4 @@ func (s *StateKeeper) prepareContext(ctx sdk.Context) { func (s *StateKeeper) GetAccountCount(ctx sdk.Context) uint64 { return s.stakeKeeper.GetNextAccountNumber(ctx) -} \ No newline at end of file +} diff --git a/x/rank/keeper/querier.go b/x/rank/keeper/querier.go index cc9d04e..73a0337 100644 --- a/x/rank/keeper/querier.go +++ b/x/rank/keeper/querier.go @@ -41,7 +41,7 @@ func NewQuerier(sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querie } } -func queryParams(ctx sdk.Context, _ abci.RequestQuery, sk StateKeeper, legacyQuerierCdc *codec.LegacyAmino,) ([]byte, error) { +func queryParams(ctx sdk.Context, _ abci.RequestQuery, sk StateKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { params := sk.GetParams(ctx) res, err := codec.MarshalJSONIndent(legacyQuerierCdc, params) @@ -52,14 +52,16 @@ func queryParams(ctx sdk.Context, _ abci.RequestQuery, sk StateKeeper, legacyQue return res, nil } -func queryRank(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino,) ([]byte, error) { +func queryRank(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QueryRankParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); if err != nil { + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } - cidNum, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.Cid)); if exist != true { + cidNum, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.Cid)) + if exist != true { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, params.Cid) } @@ -73,14 +75,16 @@ func queryRank(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQu return res, nil } -func querySearch(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino,) ([]byte, error) { +func querySearch(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QuerySearchParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); if err != nil { + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } - cidNum, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.Cid)); if exist != true { + cidNum, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.Cid)) + if exist != true { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, "") } @@ -102,14 +106,16 @@ func querySearch(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacy return res, nil } -func queryBacklinks(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino,) ([]byte, error) { +func queryBacklinks(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QuerySearchParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); if err != nil { + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } - cidNum, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.Cid)); if exist != true { + cidNum, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.Cid)) + if exist != true { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, params.Cid) } @@ -131,10 +137,11 @@ func queryBacklinks(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, leg return res, nil } -func queryTop(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino,) ([]byte, error) { +func queryTop(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QueryTopParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); if err != nil { + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } @@ -156,18 +163,21 @@ func queryTop(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQue return res, nil } -func queryIsLinkExist(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino,) ([]byte, error) { +func queryIsLinkExist(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QueryIsLinkExistParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); if err != nil { + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } - cidNumFrom, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.From)); if exist != true { + cidNumFrom, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.From)) + if exist != true { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, params.From) } - cidNumTo, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.To)); if exist != true { + cidNumTo, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.To)) + if exist != true { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, params.To) } @@ -193,18 +203,21 @@ func queryIsLinkExist(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, l return res, nil } -func queryIsAnyLinkExist(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino,) ([]byte, error) { +func queryIsAnyLinkExist(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QueryIsAnyLinkExistParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); if err != nil { + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } - cidNumFrom, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.From)); if exist != true { + cidNumFrom, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.From)) + if exist != true { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, params.From) } - cidNumTo, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.To)); if exist != true { + cidNumTo, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.To)) + if exist != true { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, params.To) } @@ -218,14 +231,16 @@ func queryIsAnyLinkExist(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper return res, nil } -func queryEntropy(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino,) ([]byte, error) { +func queryEntropy(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QueryEntropyParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); if err != nil { + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } - cidNum, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.Cid)); if exist != true { + cidNum, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.Cid)) + if exist != true { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, params.Cid) } @@ -239,7 +254,7 @@ func queryEntropy(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legac return res, nil } -func queryNegentropy(ctx sdk.Context, _ abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino,) ([]byte, error) { +func queryNegentropy(ctx sdk.Context, _ abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { negentropy := sk.GetNegEntropy() res, err := codec.MarshalJSONIndent(legacyQuerierCdc, &types.QueryNegentropyResponse{Negentropy: negentropy}) @@ -250,10 +265,11 @@ func queryNegentropy(ctx sdk.Context, _ abci.RequestQuery, sk *StateKeeper, lega return res, nil } -func queryKarma(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino,) ([]byte, error) { +func queryKarma(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QueryKarmaParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); if err != nil { + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } @@ -274,4 +290,3 @@ func queryKarma(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQ return res, nil } - diff --git a/x/rank/module.go b/x/rank/module.go index 7e314e3..5ec8491 100644 --- a/x/rank/module.go +++ b/x/rank/module.go @@ -34,7 +34,7 @@ const ( FlagSearchAPI = "search-api" ) -type AppModuleBasic struct{ +type AppModuleBasic struct { cdc codec.Codec } diff --git a/x/rank/types/context.go b/x/rank/types/context.go index fc88136..ca03759 100644 --- a/x/rank/types/context.go +++ b/x/rank/types/context.go @@ -7,20 +7,20 @@ import ( ) type CalculationContext struct { - CidsCount int64 - LinksCount int64 + CidsCount int64 + LinksCount int64 NeuronsCount int64 inLinks map[graphtypes.CidNumber]graphtypes.CidLinks outLinks map[graphtypes.CidNumber]graphtypes.CidLinks - stakes map[uint64]uint64 + stakes map[uint64]uint64 neudegs map[uint64]uint64 FullTree bool DampingFactor float64 - Tolerance float64 + Tolerance float64 } func NewCalcContext( @@ -28,23 +28,21 @@ func NewCalcContext( stakeKeeper StakeKeeper, fullTree bool, dampingFactor float64, tolerance float64, cidsCount, linksCount, neuronsCount uint64, ) *CalculationContext { - return &CalculationContext{ - - CidsCount: int64(cidsCount), - LinksCount: int64(linksCount), + CidsCount: int64(cidsCount), + LinksCount: int64(linksCount), NeuronsCount: int64(neuronsCount), inLinks: linkIndex.GetInLinks(), outLinks: linkIndex.GetOutLinks(), - stakes: stakeKeeper.GetTotalStakesAmpere(), + stakes: stakeKeeper.GetTotalStakesAmpere(), neudegs: graphKeeper.GetNeudegs(), FullTree: fullTree, DampingFactor: dampingFactor, - Tolerance: tolerance, + Tolerance: tolerance, } } @@ -112,4 +110,4 @@ func (с *CalculationContext) GetSortedOutLinks(cid graphtypes.CidNumber) (graph sort.Slice(numbers, func(i, j int) bool { return numbers[i] < numbers[j] }) return links, numbers, true -} \ No newline at end of file +} diff --git a/x/rank/types/genesis.pb.go b/x/rank/types/genesis.pb.go index eee6353..22e343e 100644 --- a/x/rank/types/genesis.pb.go +++ b/x/rank/types/genesis.pb.go @@ -5,17 +5,20 @@ package types import ( fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -33,9 +36,11 @@ func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { return fileDescriptor_2c3626db1bd06e3d, []int{0} } + func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) @@ -48,12 +53,15 @@ func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } + func (m *GenesisState) XXX_Merge(src proto.Message) { xxx_messageInfo_GenesisState.Merge(m, src) } + func (m *GenesisState) XXX_Size() int { return m.Size() } + func (m *GenesisState) XXX_DiscardUnknown() { xxx_messageInfo_GenesisState.DiscardUnknown(m) } @@ -134,6 +142,7 @@ func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *GenesisState) Size() (n int) { if m == nil { return 0 @@ -148,9 +157,11 @@ func (m *GenesisState) Size() (n int) { func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozGenesis(x uint64) (n int) { return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *GenesisState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -234,6 +245,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } return nil } + func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/rank/types/index.go b/x/rank/types/index.go index 831beff..7081ddb 100644 --- a/x/rank/types/index.go +++ b/x/rank/types/index.go @@ -13,17 +13,17 @@ import ( ) type BaseSearchIndex struct { - links []cidLinks - backlinks []cidLinks - rank Rank + links []cidLinks + backlinks []cidLinks + rank Rank - linksChan chan graphtypes.CompactLink - rankChan chan Rank - errChan chan error + linksChan chan graphtypes.CompactLink + rankChan chan Rank + errChan chan error - locked bool + locked bool - logger log.Logger + logger log.Logger } func NewBaseSearchIndex(log log.Logger) *BaseSearchIndex { @@ -45,7 +45,6 @@ func (i *BaseSearchIndex) Run() GetError { // LoadState links with zero rank values. No sorting. Index should be unavailable for read func (i *BaseSearchIndex) Load(links graphtypes.Links) { - startTime := time.Now() i.lock() // lock index for read @@ -55,7 +54,7 @@ func (i *BaseSearchIndex) Load(links graphtypes.Links) { for from, toCids := range links { i.extendIndex(uint64(from)) - for to, _ := range toCids { + for to := range toCids { i.putLinkIntoIndex(from, to) i.extendReverseIndex(uint64(to)) @@ -77,7 +76,6 @@ func (i *BaseSearchIndex) PutNewRank(rank Rank) { } func (i *BaseSearchIndex) Search(cidNumber graphtypes.CidNumber, page, perPage uint32) ([]RankedCidNumber, uint32, error) { - i.logger.Info("Search query", "particle", cidNumber, "page", page, "perPage", perPage) if i.locked { @@ -110,7 +108,6 @@ func (i *BaseSearchIndex) Search(cidNumber graphtypes.CidNumber, page, perPage u } func (i *BaseSearchIndex) Backlinks(cidNumber graphtypes.CidNumber, page, perPage uint32) ([]RankedCidNumber, uint32, error) { - i.logger.Info("Backlinks query", "cid", cidNumber, "page", page, "perPage", perPage) if i.locked { @@ -165,7 +162,6 @@ func (i *BaseSearchIndex) Top(page, perPage uint32) ([]RankedCidNumber, uint32, // make sure that this link (from-to) is new func (i *BaseSearchIndex) handleLink(link graphtypes.CompactLink) { - i.extendIndex(uint64(link.From)) fromIndex := i.links[link.From] @@ -181,7 +177,6 @@ func (i *BaseSearchIndex) handleLink(link graphtypes.CompactLink) { } func (i *BaseSearchIndex) handleBacklink(link graphtypes.CompactLink) { - i.extendReverseIndex(uint64(link.To)) toIndex := i.backlinks[link.To] @@ -253,7 +248,7 @@ func (i *BaseSearchIndex) startListenNewLinks() { } }() - //i.logger.Info("The search index is starting to listen to new links") + // i.logger.Info("The search index is starting to listen to new links") for { link := <-i.linksChan i.handleLink(link) @@ -269,7 +264,7 @@ func (i *BaseSearchIndex) startListenNewRank() { } }() - //i.logger.Info("The search index is starting to listen to new rank") + // i.logger.Info("The search index is starting to listen to new rank") for { rank := <-i.rankChan // TODO could be problems if recalculation lasts more than rank period i.rank = rank diff --git a/x/rank/types/index_types.go b/x/rank/types/index_types.go index 4d592b2..4f28e59 100644 --- a/x/rank/types/index_types.go +++ b/x/rank/types/index_types.go @@ -12,7 +12,7 @@ type RankedCidNumber struct { } func (c RankedCidNumber) GetNumber() graphtypes.CidNumber { return c.number } -func (c RankedCidNumber) GetRank() uint64 { return c.rank } +func (c RankedCidNumber) GetRank() uint64 { return c.rank } // Local type for sorting type cidLinks struct { @@ -67,14 +67,16 @@ func (i NoopSearchIndex) Load(links graphtypes.Links) {} func (i NoopSearchIndex) Search(cidNumber graphtypes.CidNumber, page, perPage uint32) ([]RankedCidNumber, uint32, error) { return nil, 0, errors.New("The search API is not enabled on this node") } + func (i NoopSearchIndex) Backlinks(cidNumber graphtypes.CidNumber, page, perPage uint32) ([]RankedCidNumber, uint32, error) { return nil, 0, errors.New("The search API is not enabled on this node") } + func (i NoopSearchIndex) Top(page, perPage uint32) ([]RankedCidNumber, uint32, error) { return nil, 0, errors.New("The search API is not enabled on this node") } func (i NoopSearchIndex) PutNewLinks(links []graphtypes.CompactLink) {} -func (i NoopSearchIndex) PutNewRank(rank Rank) {} +func (i NoopSearchIndex) PutNewRank(rank Rank) {} func (i NoopSearchIndex) GetRankValue(cidNumber graphtypes.CidNumber) uint64 { return 0 } diff --git a/x/rank/types/keys.go b/x/rank/types/keys.go index f2486e5..a10806b 100644 --- a/x/rank/types/keys.go +++ b/x/rank/types/keys.go @@ -1,20 +1,19 @@ package types const ( - ModuleName = "rank" - StoreKey = ModuleName - RouterKey = ModuleName - QuerierRoute = ModuleName + ModuleName = "rank" + StoreKey = ModuleName + RouterKey = ModuleName + QuerierRoute = ModuleName ) var ( - GlobalStoreKeyPrefix = []byte{0x00} + GlobalStoreKeyPrefix = []byte{0x00} - LatestBlockNumber = append(GlobalStoreKeyPrefix, []byte("latestBlockNumber")...) - LatestMerkleTree = append(GlobalStoreKeyPrefix, []byte("latestMerkleTree")...) - NextMerkleTree = append(GlobalStoreKeyPrefix, []byte("nextMerkleTree")...) - NextRankCidCount = append(GlobalStoreKeyPrefix, []byte("nextRankParticlesAmount")...) - ContextCidCount = append(GlobalStoreKeyPrefix, []byte("contextParticlesAmount")...) - ContextLinkCount = append(GlobalStoreKeyPrefix, []byte("contextLinkAmount")...) + LatestBlockNumber = append(GlobalStoreKeyPrefix, []byte("latestBlockNumber")...) + LatestMerkleTree = append(GlobalStoreKeyPrefix, []byte("latestMerkleTree")...) + NextMerkleTree = append(GlobalStoreKeyPrefix, []byte("nextMerkleTree")...) + NextRankCidCount = append(GlobalStoreKeyPrefix, []byte("nextRankParticlesAmount")...) + ContextCidCount = append(GlobalStoreKeyPrefix, []byte("contextParticlesAmount")...) + ContextLinkCount = append(GlobalStoreKeyPrefix, []byte("contextLinkAmount")...) ) - diff --git a/x/rank/types/params.go b/x/rank/types/params.go index 376397d..1426df5 100644 --- a/x/rank/types/params.go +++ b/x/rank/types/params.go @@ -10,7 +10,7 @@ import ( var ( KeyCalculationPeriod = []byte("CalculationPeriod") KeyDampingFactor = []byte("DampingFactor") - KeyTolerance = []byte("Tolerance") + KeyTolerance = []byte("Tolerance") ) func ParamKeyTable() paramstypes.KeyTable { @@ -20,7 +20,7 @@ func ParamKeyTable() paramstypes.KeyTable { func DefaultParams() Params { return Params{ CalculationPeriod: int64(5), - DampingFactor: sdk.NewDecWithPrec(85, 2), + DampingFactor: sdk.NewDecWithPrec(85, 2), Tolerance: sdk.NewDecWithPrec(1, 3), } } @@ -68,11 +68,11 @@ func validateDampingFactor(i interface{}) error { return fmt.Errorf("invalid parameter type: %T", i) } - if v.LTE(sdk.NewDecWithPrec(7,1)) { + if v.LTE(sdk.NewDecWithPrec(7, 1)) { return fmt.Errorf("damping factor should be equal or more than 0.7: %s", v) } - if v.GTE(sdk.NewDecWithPrec(9,1)) { + if v.GTE(sdk.NewDecWithPrec(9, 1)) { return fmt.Errorf("damping factor should be equal or less than 0.9: %s", v) } diff --git a/x/rank/types/querier.go b/x/rank/types/querier.go index 3140d31..75be191 100644 --- a/x/rank/types/querier.go +++ b/x/rank/types/querier.go @@ -3,19 +3,18 @@ package types import sdk "github.com/cosmos/cosmos-sdk/types" const ( - QueryParameters = "params" - QueryRank = "rank" - QuerySearch = "search" - QueryBacklinks = "backlinks" - QueryTop = "top" - QueryIsLinkExist = "is_link_exist" + QueryParameters = "params" + QueryRank = "rank" + QuerySearch = "search" + QueryBacklinks = "backlinks" + QueryTop = "top" + QueryIsLinkExist = "is_link_exist" QueryIsAnyLinkExist = "is_any_link_exist" - QueryKarma = "karma" - QueryEntropy = "entropy" - QueryNegentropy = "negentropy" + QueryKarma = "karma" + QueryEntropy = "entropy" + QueryNegentropy = "negentropy" ) - type QueryRankParams struct { Cid string } @@ -25,7 +24,7 @@ func NewQueryRankParams(cid string) QueryRankParams { } type QuerySearchParams struct { - Cid string + Cid string Page, PerPage uint32 } @@ -41,10 +40,9 @@ func NewQueryTopParams(page, perPage uint32) QueryTopParams { return QueryTopParams{page, perPage} } - type QueryIsLinkExistParams struct { From, To string - Address sdk.AccAddress + Address sdk.AccAddress } func NewQueryIsLinkExistParams(from, to string, account sdk.AccAddress) QueryIsLinkExistParams { @@ -73,4 +71,4 @@ type QueryKarmaParams struct { func NewQueryKarmaParams(account sdk.AccAddress) QueryKarmaParams { return QueryKarmaParams{account} -} \ No newline at end of file +} diff --git a/x/rank/types/query.pb.go b/x/rank/types/query.pb.go index 522f24b..2cf5164 100644 --- a/x/rank/types/query.pb.go +++ b/x/rank/types/query.pb.go @@ -6,7 +6,10 @@ package types import ( context "context" fmt "fmt" - query "github.com/cybercongress/go-cyber/types/query" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -14,15 +17,16 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" + + query "github.com/cybercongress/go-cyber/types/query" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -30,8 +34,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type QueryParamsRequest struct { -} +type QueryParamsRequest struct{} func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } @@ -39,9 +42,11 @@ func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f72c23904714eae6, []int{0} } + func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) @@ -54,12 +59,15 @@ func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryParamsRequest.Merge(m, src) } + func (m *QueryParamsRequest) XXX_Size() int { return m.Size() } + func (m *QueryParamsRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) } @@ -76,9 +84,11 @@ func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f72c23904714eae6, []int{1} } + func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) @@ -91,12 +101,15 @@ func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryParamsResponse.Merge(m, src) } + func (m *QueryParamsResponse) XXX_Size() int { return m.Size() } + func (m *QueryParamsResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) } @@ -113,9 +126,11 @@ func (*QueryRankRequest) ProtoMessage() {} func (*QueryRankRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f72c23904714eae6, []int{2} } + func (m *QueryRankRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryRankRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryRankRequest.Marshal(b, m, deterministic) @@ -128,12 +143,15 @@ func (m *QueryRankRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } + func (m *QueryRankRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryRankRequest.Merge(m, src) } + func (m *QueryRankRequest) XXX_Size() int { return m.Size() } + func (m *QueryRankRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryRankRequest.DiscardUnknown(m) } @@ -150,9 +168,11 @@ func (*QueryRankResponse) ProtoMessage() {} func (*QueryRankResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f72c23904714eae6, []int{3} } + func (m *QueryRankResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryRankResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryRankResponse.Marshal(b, m, deterministic) @@ -165,12 +185,15 @@ func (m *QueryRankResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } + func (m *QueryRankResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryRankResponse.Merge(m, src) } + func (m *QueryRankResponse) XXX_Size() int { return m.Size() } + func (m *QueryRankResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryRankResponse.DiscardUnknown(m) } @@ -188,9 +211,11 @@ func (*QuerySearchRequest) ProtoMessage() {} func (*QuerySearchRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f72c23904714eae6, []int{4} } + func (m *QuerySearchRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QuerySearchRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QuerySearchRequest.Marshal(b, m, deterministic) @@ -203,12 +228,15 @@ func (m *QuerySearchRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QuerySearchRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QuerySearchRequest.Merge(m, src) } + func (m *QuerySearchRequest) XXX_Size() int { return m.Size() } + func (m *QuerySearchRequest) XXX_DiscardUnknown() { xxx_messageInfo_QuerySearchRequest.DiscardUnknown(m) } @@ -226,9 +254,11 @@ func (*QuerySearchResponse) ProtoMessage() {} func (*QuerySearchResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f72c23904714eae6, []int{5} } + func (m *QuerySearchResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QuerySearchResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QuerySearchResponse.Marshal(b, m, deterministic) @@ -241,20 +271,22 @@ func (m *QuerySearchResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QuerySearchResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QuerySearchResponse.Merge(m, src) } + func (m *QuerySearchResponse) XXX_Size() int { return m.Size() } + func (m *QuerySearchResponse) XXX_DiscardUnknown() { xxx_messageInfo_QuerySearchResponse.DiscardUnknown(m) } var xxx_messageInfo_QuerySearchResponse proto.InternalMessageInfo -type QueryTopRequest struct { -} +type QueryTopRequest struct{} func (m *QueryTopRequest) Reset() { *m = QueryTopRequest{} } func (m *QueryTopRequest) String() string { return proto.CompactTextString(m) } @@ -262,9 +294,11 @@ func (*QueryTopRequest) ProtoMessage() {} func (*QueryTopRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f72c23904714eae6, []int{6} } + func (m *QueryTopRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryTopRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryTopRequest.Marshal(b, m, deterministic) @@ -277,12 +311,15 @@ func (m *QueryTopRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, err return b[:n], nil } } + func (m *QueryTopRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryTopRequest.Merge(m, src) } + func (m *QueryTopRequest) XXX_Size() int { return m.Size() } + func (m *QueryTopRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryTopRequest.DiscardUnknown(m) } @@ -301,9 +338,11 @@ func (*QueryIsLinkExistRequest) ProtoMessage() {} func (*QueryIsLinkExistRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f72c23904714eae6, []int{7} } + func (m *QueryIsLinkExistRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryIsLinkExistRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryIsLinkExistRequest.Marshal(b, m, deterministic) @@ -316,12 +355,15 @@ func (m *QueryIsLinkExistRequest) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } + func (m *QueryIsLinkExistRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryIsLinkExistRequest.Merge(m, src) } + func (m *QueryIsLinkExistRequest) XXX_Size() int { return m.Size() } + func (m *QueryIsLinkExistRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryIsLinkExistRequest.DiscardUnknown(m) } @@ -339,9 +381,11 @@ func (*QueryIsAnyLinkExistRequest) ProtoMessage() {} func (*QueryIsAnyLinkExistRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f72c23904714eae6, []int{8} } + func (m *QueryIsAnyLinkExistRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryIsAnyLinkExistRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryIsAnyLinkExistRequest.Marshal(b, m, deterministic) @@ -354,12 +398,15 @@ func (m *QueryIsAnyLinkExistRequest) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } + func (m *QueryIsAnyLinkExistRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryIsAnyLinkExistRequest.Merge(m, src) } + func (m *QueryIsAnyLinkExistRequest) XXX_Size() int { return m.Size() } + func (m *QueryIsAnyLinkExistRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryIsAnyLinkExistRequest.DiscardUnknown(m) } @@ -376,9 +423,11 @@ func (*QueryLinkExistResponse) ProtoMessage() {} func (*QueryLinkExistResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f72c23904714eae6, []int{9} } + func (m *QueryLinkExistResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryLinkExistResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryLinkExistResponse.Marshal(b, m, deterministic) @@ -391,12 +440,15 @@ func (m *QueryLinkExistResponse) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } + func (m *QueryLinkExistResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryLinkExistResponse.Merge(m, src) } + func (m *QueryLinkExistResponse) XXX_Size() int { return m.Size() } + func (m *QueryLinkExistResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryLinkExistResponse.DiscardUnknown(m) } @@ -413,9 +465,11 @@ func (*QueryNegentropyPartilceRequest) ProtoMessage() {} func (*QueryNegentropyPartilceRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f72c23904714eae6, []int{10} } + func (m *QueryNegentropyPartilceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryNegentropyPartilceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryNegentropyPartilceRequest.Marshal(b, m, deterministic) @@ -428,12 +482,15 @@ func (m *QueryNegentropyPartilceRequest) XXX_Marshal(b []byte, deterministic boo return b[:n], nil } } + func (m *QueryNegentropyPartilceRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryNegentropyPartilceRequest.Merge(m, src) } + func (m *QueryNegentropyPartilceRequest) XXX_Size() int { return m.Size() } + func (m *QueryNegentropyPartilceRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryNegentropyPartilceRequest.DiscardUnknown(m) } @@ -450,9 +507,11 @@ func (*QueryNegentropyParticleResponse) ProtoMessage() {} func (*QueryNegentropyParticleResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f72c23904714eae6, []int{11} } + func (m *QueryNegentropyParticleResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryNegentropyParticleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryNegentropyParticleResponse.Marshal(b, m, deterministic) @@ -465,20 +524,22 @@ func (m *QueryNegentropyParticleResponse) XXX_Marshal(b []byte, deterministic bo return b[:n], nil } } + func (m *QueryNegentropyParticleResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryNegentropyParticleResponse.Merge(m, src) } + func (m *QueryNegentropyParticleResponse) XXX_Size() int { return m.Size() } + func (m *QueryNegentropyParticleResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryNegentropyParticleResponse.DiscardUnknown(m) } var xxx_messageInfo_QueryNegentropyParticleResponse proto.InternalMessageInfo -type QueryNegentropyRequest struct { -} +type QueryNegentropyRequest struct{} func (m *QueryNegentropyRequest) Reset() { *m = QueryNegentropyRequest{} } func (m *QueryNegentropyRequest) String() string { return proto.CompactTextString(m) } @@ -486,9 +547,11 @@ func (*QueryNegentropyRequest) ProtoMessage() {} func (*QueryNegentropyRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f72c23904714eae6, []int{12} } + func (m *QueryNegentropyRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryNegentropyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryNegentropyRequest.Marshal(b, m, deterministic) @@ -501,12 +564,15 @@ func (m *QueryNegentropyRequest) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } + func (m *QueryNegentropyRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryNegentropyRequest.Merge(m, src) } + func (m *QueryNegentropyRequest) XXX_Size() int { return m.Size() } + func (m *QueryNegentropyRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryNegentropyRequest.DiscardUnknown(m) } @@ -523,9 +589,11 @@ func (*QueryNegentropyResponse) ProtoMessage() {} func (*QueryNegentropyResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f72c23904714eae6, []int{13} } + func (m *QueryNegentropyResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryNegentropyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryNegentropyResponse.Marshal(b, m, deterministic) @@ -538,12 +606,15 @@ func (m *QueryNegentropyResponse) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } + func (m *QueryNegentropyResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryNegentropyResponse.Merge(m, src) } + func (m *QueryNegentropyResponse) XXX_Size() int { return m.Size() } + func (m *QueryNegentropyResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryNegentropyResponse.DiscardUnknown(m) } @@ -560,9 +631,11 @@ func (*QueryKarmaRequest) ProtoMessage() {} func (*QueryKarmaRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f72c23904714eae6, []int{14} } + func (m *QueryKarmaRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryKarmaRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryKarmaRequest.Marshal(b, m, deterministic) @@ -575,12 +648,15 @@ func (m *QueryKarmaRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } + func (m *QueryKarmaRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryKarmaRequest.Merge(m, src) } + func (m *QueryKarmaRequest) XXX_Size() int { return m.Size() } + func (m *QueryKarmaRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryKarmaRequest.DiscardUnknown(m) } @@ -597,9 +673,11 @@ func (*QueryKarmaResponse) ProtoMessage() {} func (*QueryKarmaResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f72c23904714eae6, []int{15} } + func (m *QueryKarmaResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryKarmaResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryKarmaResponse.Marshal(b, m, deterministic) @@ -612,12 +690,15 @@ func (m *QueryKarmaResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QueryKarmaResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryKarmaResponse.Merge(m, src) } + func (m *QueryKarmaResponse) XXX_Size() int { return m.Size() } + func (m *QueryKarmaResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryKarmaResponse.DiscardUnknown(m) } @@ -707,8 +788,10 @@ var fileDescriptor_f72c23904714eae6 = []byte{ } // Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn +var ( + _ context.Context + _ grpc.ClientConn +) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. @@ -843,36 +926,44 @@ type QueryServer interface { } // UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} +type UnimplementedQueryServer struct{} func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } + func (*UnimplementedQueryServer) Rank(ctx context.Context, req *QueryRankRequest) (*QueryRankResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Rank not implemented") } + func (*UnimplementedQueryServer) Search(ctx context.Context, req *QuerySearchRequest) (*QuerySearchResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Search not implemented") } + func (*UnimplementedQueryServer) Backlinks(ctx context.Context, req *QuerySearchRequest) (*QuerySearchResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Backlinks not implemented") } + func (*UnimplementedQueryServer) Top(ctx context.Context, req *query.PageRequest) (*QuerySearchResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Top not implemented") } + func (*UnimplementedQueryServer) IsLinkExist(ctx context.Context, req *QueryIsLinkExistRequest) (*QueryLinkExistResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method IsLinkExist not implemented") } + func (*UnimplementedQueryServer) IsAnyLinkExist(ctx context.Context, req *QueryIsAnyLinkExistRequest) (*QueryLinkExistResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method IsAnyLinkExist not implemented") } + func (*UnimplementedQueryServer) ParticleNegentropy(ctx context.Context, req *QueryNegentropyPartilceRequest) (*QueryNegentropyParticleResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ParticleNegentropy not implemented") } + func (*UnimplementedQueryServer) Negentropy(ctx context.Context, req *QueryNegentropyRequest) (*QueryNegentropyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Negentropy not implemented") } + func (*UnimplementedQueryServer) Karma(ctx context.Context, req *QueryKarmaRequest) (*QueryKarmaResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Karma not implemented") } @@ -1630,6 +1721,7 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *QueryParamsRequest) Size() (n int) { if m == nil { return 0 @@ -1844,9 +1936,11 @@ func (m *QueryKarmaResponse) Size() (n int) { func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1897,6 +1991,7 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1980,6 +2075,7 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryRankRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2062,6 +2158,7 @@ func (m *QueryRankRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryRankResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2131,6 +2228,7 @@ func (m *QueryRankResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QuerySearchRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2249,6 +2347,7 @@ func (m *QuerySearchRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QuerySearchResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2369,6 +2468,7 @@ func (m *QuerySearchResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryTopRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2419,6 +2519,7 @@ func (m *QueryTopRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryIsLinkExistRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2565,6 +2666,7 @@ func (m *QueryIsLinkExistRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryIsAnyLinkExistRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2679,6 +2781,7 @@ func (m *QueryIsAnyLinkExistRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryLinkExistResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2749,6 +2852,7 @@ func (m *QueryLinkExistResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryNegentropyPartilceRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2831,6 +2935,7 @@ func (m *QueryNegentropyPartilceRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryNegentropyParticleResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2900,6 +3005,7 @@ func (m *QueryNegentropyParticleResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryNegentropyRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2950,6 +3056,7 @@ func (m *QueryNegentropyRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryNegentropyResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3019,6 +3126,7 @@ func (m *QueryNegentropyResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryKarmaRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3101,6 +3209,7 @@ func (m *QueryKarmaRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryKarmaResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3170,6 +3279,7 @@ func (m *QueryKarmaResponse) Unmarshal(dAtA []byte) error { } return nil } + func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/rank/types/query.pb.gw.go b/x/rank/types/query.pb.gw.go index 14d2a9d..56b9580 100644 --- a/x/rank/types/query.pb.gw.go +++ b/x/rank/types/query.pb.gw.go @@ -13,7 +13,6 @@ import ( "io" "net/http" - "github.com/cybercongress/go-cyber/types/query" "github.com/golang/protobuf/descriptor" "github.com/golang/protobuf/proto" "github.com/grpc-ecosystem/grpc-gateway/runtime" @@ -22,15 +21,19 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/status" + + "github.com/cybercongress/go-cyber/types/query" ) // Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = runtime.String + _ = utilities.NewDoubleArray + _ = descriptor.ForMessage +) func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -38,7 +41,6 @@ func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, cl msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -47,7 +49,6 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal msg, err := server.Params(ctx, &protoReq) return msg, metadata, err - } func request_Query_Rank_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -74,7 +75,6 @@ func request_Query_Rank_0(ctx context.Context, marshaler runtime.Marshaler, clie msg, err := client.Rank(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Rank_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -101,12 +101,9 @@ func local_request_Query_Rank_0(ctx context.Context, marshaler runtime.Marshaler msg, err := server.Rank(ctx, &protoReq) return msg, metadata, err - } -var ( - filter_Query_Search_0 = &utilities.DoubleArray{Encoding: map[string]int{"particle": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) +var filter_Query_Search_0 = &utilities.DoubleArray{Encoding: map[string]int{"particle": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_Query_Search_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QuerySearchRequest @@ -139,7 +136,6 @@ func request_Query_Search_0(ctx context.Context, marshaler runtime.Marshaler, cl msg, err := client.Search(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Search_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -173,12 +169,9 @@ func local_request_Query_Search_0(ctx context.Context, marshaler runtime.Marshal msg, err := server.Search(ctx, &protoReq) return msg, metadata, err - } -var ( - filter_Query_Backlinks_0 = &utilities.DoubleArray{Encoding: map[string]int{"particle": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) +var filter_Query_Backlinks_0 = &utilities.DoubleArray{Encoding: map[string]int{"particle": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_Query_Backlinks_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QuerySearchRequest @@ -211,7 +204,6 @@ func request_Query_Backlinks_0(ctx context.Context, marshaler runtime.Marshaler, msg, err := client.Backlinks(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Backlinks_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -245,12 +237,9 @@ func local_request_Query_Backlinks_0(ctx context.Context, marshaler runtime.Mars msg, err := server.Backlinks(ctx, &protoReq) return msg, metadata, err - } -var ( - filter_Query_Top_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) +var filter_Query_Top_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_Query_Top_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq query.PageRequest @@ -265,7 +254,6 @@ func request_Query_Top_0(ctx context.Context, marshaler runtime.Marshaler, clien msg, err := client.Top(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Top_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -281,12 +269,9 @@ func local_request_Query_Top_0(ctx context.Context, marshaler runtime.Marshaler, msg, err := server.Top(ctx, &protoReq) return msg, metadata, err - } -var ( - filter_Query_IsLinkExist_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) +var filter_Query_IsLinkExist_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_Query_IsLinkExist_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryIsLinkExistRequest @@ -301,7 +286,6 @@ func request_Query_IsLinkExist_0(ctx context.Context, marshaler runtime.Marshale msg, err := client.IsLinkExist(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_IsLinkExist_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -317,12 +301,9 @@ func local_request_Query_IsLinkExist_0(ctx context.Context, marshaler runtime.Ma msg, err := server.IsLinkExist(ctx, &protoReq) return msg, metadata, err - } -var ( - filter_Query_IsAnyLinkExist_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) +var filter_Query_IsAnyLinkExist_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_Query_IsAnyLinkExist_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryIsAnyLinkExistRequest @@ -337,7 +318,6 @@ func request_Query_IsAnyLinkExist_0(ctx context.Context, marshaler runtime.Marsh msg, err := client.IsAnyLinkExist(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_IsAnyLinkExist_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -353,7 +333,6 @@ func local_request_Query_IsAnyLinkExist_0(ctx context.Context, marshaler runtime msg, err := server.IsAnyLinkExist(ctx, &protoReq) return msg, metadata, err - } func request_Query_ParticleNegentropy_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -380,7 +359,6 @@ func request_Query_ParticleNegentropy_0(ctx context.Context, marshaler runtime.M msg, err := client.ParticleNegentropy(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_ParticleNegentropy_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -407,7 +385,6 @@ func local_request_Query_ParticleNegentropy_0(ctx context.Context, marshaler run msg, err := server.ParticleNegentropy(ctx, &protoReq) return msg, metadata, err - } func request_Query_Negentropy_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -416,7 +393,6 @@ func request_Query_Negentropy_0(ctx context.Context, marshaler runtime.Marshaler msg, err := client.Negentropy(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Negentropy_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -425,7 +401,6 @@ func local_request_Query_Negentropy_0(ctx context.Context, marshaler runtime.Mar msg, err := server.Negentropy(ctx, &protoReq) return msg, metadata, err - } func request_Query_Karma_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -452,7 +427,6 @@ func request_Query_Karma_0(ctx context.Context, marshaler runtime.Marshaler, cli msg, err := client.Karma(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Karma_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -479,7 +453,6 @@ func local_request_Query_Karma_0(ctx context.Context, marshaler runtime.Marshale msg, err := server.Karma(ctx, &protoReq) return msg, metadata, err - } // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". @@ -487,7 +460,6 @@ func local_request_Query_Karma_0(ctx context.Context, marshaler runtime.Marshale // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -505,7 +477,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Rank_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -525,7 +496,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Rank_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Search_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -545,7 +515,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Search_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Backlinks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -565,7 +534,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Backlinks_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Top_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -585,7 +553,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Top_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_IsLinkExist_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -605,7 +572,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_IsLinkExist_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_IsAnyLinkExist_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -625,7 +591,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_IsAnyLinkExist_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_ParticleNegentropy_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -645,7 +610,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_ParticleNegentropy_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Negentropy_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -665,7 +629,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Negentropy_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Karma_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -685,7 +648,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Karma_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) return nil @@ -728,7 +690,6 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -746,7 +707,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Rank_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -766,7 +726,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Rank_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Search_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -786,7 +745,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Search_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Backlinks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -806,7 +764,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Backlinks_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Top_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -826,7 +783,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Top_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_IsLinkExist_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -846,7 +802,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_IsLinkExist_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_IsAnyLinkExist_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -866,7 +821,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_IsAnyLinkExist_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_ParticleNegentropy_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -886,7 +840,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_ParticleNegentropy_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Negentropy_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -906,7 +859,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Negentropy_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Karma_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -926,7 +878,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Karma_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) return nil diff --git a/x/rank/types/rank.go b/x/rank/types/rank.go index 878058b..7e16e99 100644 --- a/x/rank/types/rank.go +++ b/x/rank/types/rank.go @@ -3,6 +3,7 @@ package types import ( "crypto/sha256" "encoding/binary" + //"fmt" "sort" "time" @@ -14,36 +15,35 @@ import ( ) type EMState struct { - RankValues []float64 - EntropyValues []float64 - KarmaValues []float64 + RankValues []float64 + EntropyValues []float64 + KarmaValues []float64 } type Rank struct { - RankValues []uint64 - EntropyValues []uint64 - KarmaValues []uint64 - MerkleTree *merkle.Tree // ranks merkle - CidCount uint64 - TopCIDs []RankedCidNumber - NegEntropy uint64 + RankValues []uint64 + EntropyValues []uint64 + KarmaValues []uint64 + MerkleTree *merkle.Tree // ranks merkle + CidCount uint64 + TopCIDs []RankedCidNumber + NegEntropy uint64 } func NewRank(state EMState, logger log.Logger, fullTree bool) Rank { - // Entropy and karma are experimental features start := time.Now() particlesCount := uint64(len(state.RankValues)) rankValues := make([]uint64, particlesCount) for i, f64 := range state.RankValues { - rankValues[i] = uint64(f64*1e15) + rankValues[i] = uint64(f64 * 1e15) } state.RankValues = nil entropyValues := make([]uint64, particlesCount) for i, f64 := range state.EntropyValues { - entropyValues[i] = uint64(f64*1e15) + entropyValues[i] = uint64(f64 * 1e15) } negEntropy := float64(0) for _, f64 := range state.EntropyValues { @@ -53,7 +53,7 @@ func NewRank(state EMState, logger log.Logger, fullTree bool) Rank { karmaValues := make([]uint64, len(state.KarmaValues)) for i, f64 := range state.KarmaValues { - karmaValues[i] = uint64(f64*1e15) + karmaValues[i] = uint64(f64 * 1e15) } state.KarmaValues = nil @@ -71,7 +71,7 @@ func NewRank(state EMState, logger log.Logger, fullTree bool) Rank { // NOTE fulltree true if search index enabled start = time.Now() var newSortedCIDs []RankedCidNumber - if (fullTree == true) { + if fullTree == true { newSortedCIDs = BuildTop(rankValues, 1000) logger.Info("Build top", "duration", time.Since(start).String()) } @@ -91,13 +91,13 @@ func NewRank(state EMState, logger log.Logger, fullTree bool) Rank { func NewFromMerkle(cidCount uint64, treeBytes []byte) Rank { rank := Rank{ - RankValues: nil, - EntropyValues: nil, - KarmaValues: nil, - MerkleTree: merkle.NewTree(sha256.New(), false), - CidCount: cidCount, - TopCIDs: nil, - NegEntropy: 0, + RankValues: nil, + EntropyValues: nil, + KarmaValues: nil, + MerkleTree: merkle.NewTree(sha256.New(), false), + CidCount: cidCount, + TopCIDs: nil, + NegEntropy: 0, } rank.MerkleTree.ImportSubtreesRoots(treeBytes) @@ -119,16 +119,15 @@ func (r *Rank) Clear() { } func (r *Rank) CopyWithoutTree() Rank { - if r.RankValues == nil { return Rank{ - RankValues: nil, + RankValues: nil, EntropyValues: nil, - KarmaValues: nil, - MerkleTree: nil, - CidCount: 0, - TopCIDs: nil, - NegEntropy: 0, + KarmaValues: nil, + MerkleTree: nil, + CidCount: 0, + TopCIDs: nil, + NegEntropy: 0, } } @@ -149,13 +148,13 @@ func (r *Rank) CopyWithoutTree() Rank { n = copy(copiedTopCIDs, r.TopCIDs) return Rank{ - RankValues: copiedRankValues, + RankValues: copiedRankValues, EntropyValues: copiedEntropyValues, - KarmaValues: copiedKarmaValues, - MerkleTree: nil, - CidCount: r.CidCount, - TopCIDs: copiedTopCIDs, - NegEntropy: r.NegEntropy, + KarmaValues: copiedKarmaValues, + MerkleTree: nil, + CidCount: r.CidCount, + TopCIDs: copiedTopCIDs, + NegEntropy: r.NegEntropy, } } @@ -184,13 +183,15 @@ func (r *Rank) AddNewCids(currentCidCount uint64) { func BuildTop(values []uint64, size int) []RankedCidNumber { newSortedCIDs := make(sortableCidNumbers, 0, len(values)) for cid, rank := range values { - if (rank == 0) { continue } + if rank == 0 { + continue + } newRankedCid := RankedCidNumber{graphtypes.CidNumber(cid), rank} newSortedCIDs = append(newSortedCIDs, newRankedCid) } sort.Stable(sort.Reverse(newSortedCIDs)) - if (len(values) > size) { - newSortedCIDs = newSortedCIDs[0:(size-1)] + if len(values) > size { + newSortedCIDs = newSortedCIDs[0:(size - 1)] } return newSortedCIDs } diff --git a/x/rank/types/types.pb.go b/x/rank/types/types.pb.go index b09ba90..d22d7d6 100644 --- a/x/rank/types/types.pb.go +++ b/x/rank/types/types.pb.go @@ -5,18 +5,21 @@ package types import ( fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" io "io" math "math" math_bits "math/bits" + + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -36,9 +39,11 @@ func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { return fileDescriptor_5e38a68eff7d025f, []int{0} } + func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_Params.Marshal(b, m, deterministic) @@ -51,12 +56,15 @@ func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } + func (m *Params) XXX_Merge(src proto.Message) { xxx_messageInfo_Params.Merge(m, src) } + func (m *Params) XXX_Size() int { return m.Size() } + func (m *Params) XXX_DiscardUnknown() { xxx_messageInfo_Params.DiscardUnknown(m) } @@ -81,9 +89,11 @@ func (*RankedParticle) ProtoMessage() {} func (*RankedParticle) Descriptor() ([]byte, []int) { return fileDescriptor_5e38a68eff7d025f, []int{1} } + func (m *RankedParticle) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *RankedParticle) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_RankedParticle.Marshal(b, m, deterministic) @@ -96,12 +106,15 @@ func (m *RankedParticle) XXX_Marshal(b []byte, deterministic bool) ([]byte, erro return b[:n], nil } } + func (m *RankedParticle) XXX_Merge(src proto.Message) { xxx_messageInfo_RankedParticle.Merge(m, src) } + func (m *RankedParticle) XXX_Size() int { return m.Size() } + func (m *RankedParticle) XXX_DiscardUnknown() { xxx_messageInfo_RankedParticle.DiscardUnknown(m) } @@ -183,6 +196,7 @@ func (this *Params) Equal(that interface{}) bool { } return true } + func (m *Params) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -277,6 +291,7 @@ func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *Params) Size() (n int) { if m == nil { return 0 @@ -312,9 +327,11 @@ func (m *RankedParticle) Size() (n int) { func sovTypes(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozTypes(x uint64) (n int) { return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *Params) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -452,6 +469,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } + func (m *RankedParticle) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -553,6 +571,7 @@ func (m *RankedParticle) Unmarshal(dAtA []byte) error { } return nil } + func skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/rank/wasm/interface.go b/x/rank/wasm/interface.go index d07c65a..ea74f7c 100644 --- a/x/rank/wasm/interface.go +++ b/x/rank/wasm/interface.go @@ -2,12 +2,14 @@ package wasm import ( "encoding/json" + "github.com/ipfs/go-cid" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" wasmvmtypes "github.com/CosmWasm/wasmvm/types" + graphtypes "github.com/cybercongress/go-cyber/x/graph/types" "github.com/cybercongress/go-cyber/x/rank/keeper" @@ -31,21 +33,20 @@ func NewWasmQuerier(keeper *keeper.StateKeeper) WasmQuerier { func (WasmQuerier) Query(_ sdk.Context, _ wasmvmtypes.QueryRequest) ([]byte, error) { return nil, nil } type CosmosQuery struct { - ParticleRank *QueryParticleRankParams `json:"particle_rank,omitempty"` + ParticleRank *QueryParticleRankParams `json:"particle_rank,omitempty"` } type QueryParticleRankParams struct { - Particle string `json:"particle"` + Particle string `json:"particle"` } type ParticleRankResponse struct { - Rank uint64 `json:"rank"` + Rank uint64 `json:"rank"` } func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) { var query CosmosQuery err := json.Unmarshal(data, &query) - if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } @@ -76,4 +77,4 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ } return nil, wasmvmtypes.UnsupportedRequest{Kind: "unknown Rank variant"} -} \ No newline at end of file +} diff --git a/x/resources/client/cli/query.go b/x/resources/client/cli/query.go index 68705d9..edf6eca 100644 --- a/x/resources/client/cli/query.go +++ b/x/resources/client/cli/query.go @@ -8,9 +8,10 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" + ctypes "github.com/cybercongress/go-cyber/types" "github.com/cybercongress/go-cyber/x/resources/types" - "github.com/spf13/cobra" ) func GetQueryCmd() *cobra.Command { @@ -63,7 +64,7 @@ func GetCmdQueryInvestmintAmount() *cobra.Command { cmd := &cobra.Command{ Use: "investmint [amount] [resource] [length]", Short: "Query resources return on investmint", - Args: cobra.ExactArgs(3), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -92,12 +93,11 @@ func GetCmdQueryInvestmintAmount() *cobra.Command { res, err := queryClient.Investmint( context.Background(), &types.QueryInvestmintRequest{ - Amount: amount, + Amount: amount, Resource: args[1], - Length: length, + Length: length, }, ) - if err != nil { return err } @@ -110,5 +110,3 @@ func GetCmdQueryInvestmintAmount() *cobra.Command { return cmd } - - diff --git a/x/resources/client/cli/tx.go b/x/resources/client/cli/tx.go index 72f75ee..8330316 100644 --- a/x/resources/client/cli/tx.go +++ b/x/resources/client/cli/tx.go @@ -17,7 +17,6 @@ import ( "github.com/cybercongress/go-cyber/x/resources/types" ) - func NewTxCmd() *cobra.Command { resourcesTxCmd := &cobra.Command{ Use: types.ModuleName, @@ -86,6 +85,5 @@ $ %s tx resources investmint 1000000000hydrogen millivolt 2500000 --from flags.AddTxFlagsToCmd(cmd) - return cmd -} \ No newline at end of file +} diff --git a/x/resources/client/rest/query.go b/x/resources/client/rest/query.go index 32a1eeb..eb3ef85 100644 --- a/x/resources/client/rest/query.go +++ b/x/resources/client/rest/query.go @@ -7,9 +7,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - ctypes "github.com/cybercongress/go-cyber/types" "github.com/gorilla/mux" + ctypes "github.com/cybercongress/go-cyber/types" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/types/rest" @@ -28,7 +29,6 @@ func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { func queryParamsHandlerFn(cliCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryParams) res, _, err := cliCtx.QueryWithData(route, nil) @@ -96,4 +96,4 @@ func queryInvestmintHandlerFn(cliCtx client.Context) http.HandlerFunc { cliCtx = cliCtx.WithHeight(height) rest.PostProcessResponse(w, cliCtx, res) } -} \ No newline at end of file +} diff --git a/x/resources/client/rest/rest.go b/x/resources/client/rest/rest.go index 1e2d784..d9b507f 100644 --- a/x/resources/client/rest/rest.go +++ b/x/resources/client/rest/rest.go @@ -8,4 +8,4 @@ import ( // RegisterRoutes registers power-related REST handlers to a router func RegisterRoutes(cliCtx client.Context, r *mux.Router) { registerQueryRoutes(cliCtx, r) -} \ No newline at end of file +} diff --git a/x/resources/keeper/genesis.go b/x/resources/keeper/genesis.go index 4261648..72c8c47 100644 --- a/x/resources/keeper/genesis.go +++ b/x/resources/keeper/genesis.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cybercongress/go-cyber/x/resources/types" ) diff --git a/x/resources/keeper/grpc_query.go b/x/resources/keeper/grpc_query.go index f8b6118..cd0ebe8 100644 --- a/x/resources/keeper/grpc_query.go +++ b/x/resources/keeper/grpc_query.go @@ -5,10 +5,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - ctypes "github.com/cybercongress/go-cyber/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + ctypes "github.com/cybercongress/go-cyber/types" + "github.com/cybercongress/go-cyber/x/resources/types" ) @@ -39,4 +40,4 @@ func (k Keeper) Investmint(goCtx context.Context, request *types.QueryInvestmint amount := k.CalculateInvestmint(ctx, request.Amount, request.Resource, request.Length) return &types.QueryInvestmintResponse{Amount: amount}, nil -} \ No newline at end of file +} diff --git a/x/resources/keeper/keeper.go b/x/resources/keeper/keeper.go index d0cb328..2f550a5 100644 --- a/x/resources/keeper/keeper.go +++ b/x/resources/keeper/keeper.go @@ -2,12 +2,13 @@ package keeper import ( "fmt" + "math" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - "math" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/tendermint/tendermint/libs/log" @@ -18,18 +19,18 @@ import ( ) type Keeper struct { - cdc codec.BinaryCodec - accountKeeper types.AccountKeeper - bankKeeper types.BankKeeper - bandwidthMeter *bandwithkeeper.BandwidthMeter - paramSpace paramstypes.Subspace + cdc codec.BinaryCodec + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper + bandwidthMeter *bandwithkeeper.BandwidthMeter + paramSpace paramstypes.Subspace } func NewKeeper( cdc codec.BinaryCodec, - ak types.AccountKeeper, - bk types.BankKeeper, - bm *bandwithkeeper.BandwidthMeter, + ak types.AccountKeeper, + bk types.BankKeeper, + bm *bandwithkeeper.BandwidthMeter, paramSpace paramstypes.Subspace, ) Keeper { if addr := ak.GetModuleAddress(types.ResourcesName); addr == nil { @@ -41,11 +42,11 @@ func NewKeeper( } keeper := Keeper{ - cdc: cdc, - accountKeeper: ak, + cdc: cdc, + accountKeeper: ak, bankKeeper: bk, bandwidthMeter: bm, - paramSpace: paramSpace, + paramSpace: paramSpace, } return keeper } @@ -112,7 +113,8 @@ func (k Keeper) AddTimeLockedCoinsToAccount(ctx sdk.Context, recipientAddr sdk.A } func (k Keeper) AddTimeLockedCoinsToPeriodicVestingAccount(ctx sdk.Context, recipientAddr sdk.AccAddress, amt sdk.Coins, length int64, mergeSlot bool) error { - err := k.addCoinsToVestingSchedule(ctx, recipientAddr, amt, length, mergeSlot); if err != nil { + err := k.addCoinsToVestingSchedule(ctx, recipientAddr, amt, length, mergeSlot) + if err != nil { return err } return nil @@ -142,16 +144,16 @@ func (k Keeper) addCoinsToVestingSchedule(ctx sdk.Context, addr sdk.AccAddress, if vacc.EndTime < ctx.BlockTime().Unix() { // edge case one - the vesting account's end time is in the past (ie, all previous vesting periods have completed) // append a new period to the vesting account, update the end time, update the account in the store and return - //newPeriodLength := (ctx.BlockTime().Unix() - vacc.EndTime) + length // 110 - 100 + 6 = 16 - //newPeriod := types.NewPeriod(amt, newPeriodLength) - //vacc.VestingPeriods = append(vacc.VestingPeriods, newPeriod) - //vacc.EndTime = ctx.BlockTime().Unix() + length - //k.accountKeeper.SetAccount(ctx, vacc) - //return nil + // newPeriodLength := (ctx.BlockTime().Unix() - vacc.EndTime) + length // 110 - 100 + 6 = 16 + // newPeriod := types.NewPeriod(amt, newPeriodLength) + // vacc.VestingPeriods = append(vacc.VestingPeriods, newPeriod) + // vacc.EndTime = ctx.BlockTime().Unix() + length + // k.accountKeeper.SetAccount(ctx, vacc) + // return nil // edge case one - the vesting account's end time is in the past (ie, all previous vesting periods have completed) // delete all passed periods, add a new period to the vesting account, update the end time, update the account in the store and return - //newPeriodLength := (ctx.BlockTime().Unix() - vacc.EndTime) + length // 110 - 100 + 6 = 16 + // newPeriodLength := (ctx.BlockTime().Unix() - vacc.EndTime) + length // 110 - 100 + 6 = 16 newPeriod := types.NewPeriod(amt, length) vacc.VestingPeriods = append(vestingtypes.Periods{}, newPeriod) vacc.StartTime = ctx.BlockTime().Unix() @@ -181,7 +183,7 @@ func (k Keeper) addCoinsToVestingSchedule(ctx sdk.Context, addr sdk.AccAddress, if len(vacc.VestingPeriods) == int(k.MaxSlots(ctx)) && !mergeSlot { // case when there are already filled slots and no one already passed - if vacc.StartTime + vacc.VestingPeriods[0].Length > ctx.BlockTime().Unix() { + if vacc.StartTime+vacc.VestingPeriods[0].Length > ctx.BlockTime().Unix() { return types.ErrFullSlots } else { // TODO refactor next code blocks @@ -190,7 +192,7 @@ func (k Keeper) addCoinsToVestingSchedule(ctx sdk.Context, addr sdk.AccAddress, accumulatedLength := int64(0) shiftStartTime := int64(0) for _, period := range vacc.VestingPeriods { - if vacc.StartTime + period.Length + accumulatedLength > ctx.BlockTime().Unix() { + if vacc.StartTime+period.Length+accumulatedLength > ctx.BlockTime().Unix() { activePeriods = append(activePeriods, period) } else { shiftStartTime += period.Length @@ -310,13 +312,13 @@ func (k Keeper) CalculateInvestmint(ctx sdk.Context, amt sdk.Coin, resource stri var halving sdk.Dec switch resource { case ctypes.VOLT: - //cycles := sdk.NewDec(int64(length)).QuoInt64(int64(10)) // for local dev + // cycles := sdk.NewDec(int64(length)).QuoInt64(int64(10)) // for local dev cycles := sdk.NewDec(int64(length)).QuoInt64(int64(k.BaseInvestmintPeriodVolt(ctx))) base := sdk.NewDec(amt.Amount.Int64()).QuoInt64(k.BaseInvestmintAmountVolt(ctx).Amount.Int64()) // NOTE out of parametrization custom code is applied here in order to shift the FIRST HALVING 6M BLOCKS LATER but keep base halving parameter same if ctx.BlockHeight() > 15000000 { - halving = sdk.NewDecWithPrec(int64(math.Pow(0.5, float64((ctx.BlockHeight()-600000) / int64(k.BaseHalvingPeriodVolt(ctx))))*10000),4) + halving = sdk.NewDecWithPrec(int64(math.Pow(0.5, float64((ctx.BlockHeight()-600000)/int64(k.BaseHalvingPeriodVolt(ctx))))*10000), 4) } else { halving = sdk.OneDec() } @@ -329,13 +331,13 @@ func (k Keeper) CalculateInvestmint(ctx sdk.Context, amt sdk.Coin, resource stri k.Logger(ctx).Info("Investmint", "cycles", cycles.String(), "base", base.String(), "halving", halving.String(), "mint", toMint.String()) case ctypes.AMPERE: - //cycles := sdk.NewDec(int64(length)).QuoInt64(int64(10)) // for local dev + // cycles := sdk.NewDec(int64(length)).QuoInt64(int64(10)) // for local dev cycles := sdk.NewDec(int64(length)).QuoInt64(int64(k.BaseInvestmintPeriodAmpere(ctx))) base := sdk.NewDec(amt.Amount.Int64()).QuoInt64(k.BaseInvestmintAmountAmpere(ctx).Amount.Int64()) // NOTE out of parametrization custom code is applied here in order to shift the FIRST HALVING 6M BLOCKS LATER but keep base halving parameter same if ctx.BlockHeight() > 15000000 { - halving = sdk.NewDecWithPrec(int64(math.Pow(0.5, float64((ctx.BlockHeight()-600000) / int64(k.BaseHalvingPeriodAmpere(ctx))))*10000),4) + halving = sdk.NewDecWithPrec(int64(math.Pow(0.5, float64((ctx.BlockHeight()-600000)/int64(k.BaseHalvingPeriodAmpere(ctx))))*10000), 4) } else { halving = sdk.OneDec() } @@ -359,12 +361,12 @@ func (k Keeper) CheckAvailablePeriod(ctx sdk.Context, length uint64, resource st switch resource { case ctypes.VOLT: halvingVolt := k.BaseHalvingPeriodVolt(ctx) - doubling := uint32(math.Pow(2, float64(passed / int64(halvingVolt)))) + doubling := uint32(math.Pow(2, float64(passed/int64(halvingVolt)))) availableLength = uint64(doubling * halvingVolt * 5) case ctypes.AMPERE: halvingAmpere := k.BaseHalvingPeriodAmpere(ctx) - doubling := uint32(math.Pow(2, float64(passed / int64(halvingAmpere)))) + doubling := uint32(math.Pow(2, float64(passed/int64(halvingAmpere)))) availableLength = uint64(doubling * halvingAmpere * 5) } @@ -409,4 +411,4 @@ func (k Keeper) BaseInvestmintAmountAmpere(ctx sdk.Context) (res sdk.Coin) { func (k Keeper) MinInvestmintPeriodSec(ctx sdk.Context) (res uint32) { k.paramSpace.Get(ctx, types.KeyMinInvestmintPeriod, &res) return -} \ No newline at end of file +} diff --git a/x/resources/keeper/msg_server.go b/x/resources/keeper/msg_server.go index 002b5e6..fcb5087 100644 --- a/x/resources/keeper/msg_server.go +++ b/x/resources/keeper/msg_server.go @@ -2,13 +2,16 @@ package keeper import ( "context" + "strconv" + "github.com/armon/go-metrics" "github.com/cosmos/cosmos-sdk/telemetry" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + ctypes "github.com/cybercongress/go-cyber/types" - "strconv" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cybercongress/go-cyber/x/resources/types" ) @@ -69,4 +72,4 @@ func (k msgServer) Investmint(goCtx context.Context, msg *types.MsgInvestmint) ( }) return &types.MsgInvestmintResponse{}, nil -} \ No newline at end of file +} diff --git a/x/resources/keeper/querier.go b/x/resources/keeper/querier.go index b4f63bd..fedda23 100644 --- a/x/resources/keeper/querier.go +++ b/x/resources/keeper/querier.go @@ -4,9 +4,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - ctypes "github.com/cybercongress/go-cyber/types" abci "github.com/tendermint/tendermint/abci/types" + ctypes "github.com/cybercongress/go-cyber/types" + "github.com/cybercongress/go-cyber/x/resources/types" ) @@ -37,7 +38,8 @@ func queryParams(ctx sdk.Context, k Keeper, legacyQuerierCdc *codec.LegacyAmino) func queryInvestmint(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { var params types.QueryInvestmintParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); if err != nil { + err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) } @@ -57,4 +59,4 @@ func queryInvestmint(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQue } return res, nil -} \ No newline at end of file +} diff --git a/x/resources/module.go b/x/resources/module.go index 1abec6b..840dbc6 100644 --- a/x/resources/module.go +++ b/x/resources/module.go @@ -28,7 +28,7 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -type AppModuleBasic struct{ +type AppModuleBasic struct { cdc codec.Codec } @@ -46,7 +46,8 @@ func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { var data types.GenesisState - err := cdc.UnmarshalJSON(bz, &data); if err != nil { + err := cdc.UnmarshalJSON(bz, &data) + if err != nil { return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) } return types.ValidateGenesis(data) @@ -77,15 +78,15 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) type AppModule struct { AppModuleBasic - keeper keeper.Keeper + keeper keeper.Keeper } func NewAppModule( cdc codec.Codec, k keeper.Keeper, ) AppModule { return AppModule{ - AppModuleBasic: AppModuleBasic{cdc: cdc}, - keeper: k, + AppModuleBasic: AppModuleBasic{cdc: cdc}, + keeper: k, } } diff --git a/x/resources/types/codec.go b/x/resources/types/codec.go index 71b07ba..6c278b7 100644 --- a/x/resources/types/codec.go +++ b/x/resources/types/codec.go @@ -30,4 +30,4 @@ func init() { RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) amino.Seal() -} \ No newline at end of file +} diff --git a/x/resources/types/errors.go b/x/resources/types/errors.go index 9332d23..0f42d27 100644 --- a/x/resources/types/errors.go +++ b/x/resources/types/errors.go @@ -3,15 +3,15 @@ package types import sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" var ( - ErrTimeLockCoins = sdkerrors.Register(ModuleName, 2, "error timelock coins") - ErrIssueCoins = sdkerrors.Register(ModuleName, 3, "error issue coins") - ErrMintCoins = sdkerrors.Register(ModuleName, 4, "error mint coins") - ErrBurnCoins = sdkerrors.Register(ModuleName, 5, "error burn coins") - ErrSendMintedCoins = sdkerrors.Register(ModuleName, 6, "error send minted coins") - ErrNotAvailablePeriod = sdkerrors.Register(ModuleName, 7, "period not available") - ErrInvalidAccountType = sdkerrors.Register(ModuleName, 8, "receiver account type not supported") - ErrAccountNotFound = sdkerrors.Register(ModuleName, 9, "account not found") - ErrResourceNotExist = sdkerrors.Register(ModuleName, 10, "resource does not exist") + ErrTimeLockCoins = sdkerrors.Register(ModuleName, 2, "error timelock coins") + ErrIssueCoins = sdkerrors.Register(ModuleName, 3, "error issue coins") + ErrMintCoins = sdkerrors.Register(ModuleName, 4, "error mint coins") + ErrBurnCoins = sdkerrors.Register(ModuleName, 5, "error burn coins") + ErrSendMintedCoins = sdkerrors.Register(ModuleName, 6, "error send minted coins") + ErrNotAvailablePeriod = sdkerrors.Register(ModuleName, 7, "period not available") + ErrInvalidAccountType = sdkerrors.Register(ModuleName, 8, "receiver account type not supported") + ErrAccountNotFound = sdkerrors.Register(ModuleName, 9, "account not found") + ErrResourceNotExist = sdkerrors.Register(ModuleName, 10, "resource does not exist") ErrFullSlots = sdkerrors.Register(ModuleName, 11, "all slots are full") ErrSmallReturn = sdkerrors.Register(ModuleName, 12, "insufficient resources return amount") ErrInvalidBaseResource = sdkerrors.Register(ModuleName, 13, "invalid base resource") diff --git a/x/resources/types/events.go b/x/resources/types/events.go index 91fcb65..1e73d5d 100644 --- a/x/resources/types/events.go +++ b/x/resources/types/events.go @@ -1,13 +1,13 @@ package types const ( - EventTypeInvestmint = "investmint" + EventTypeInvestmint = "investmint" - AttributeKeyNeuron = "neuron" - AttributeKeyAmount = "amount" - AttributeKeyResource = "resource" - AttributeKeyLength = "length" - AttributeKeyMinted = "minted" + AttributeKeyNeuron = "neuron" + AttributeKeyAmount = "amount" + AttributeKeyResource = "resource" + AttributeKeyLength = "length" + AttributeKeyMinted = "minted" - AttributeValueCategory = ModuleName -) \ No newline at end of file + AttributeValueCategory = ModuleName +) diff --git a/x/resources/types/expected_keepers.go b/x/resources/types/expected_keepers.go index 1c79bb0..907bfbd 100644 --- a/x/resources/types/expected_keepers.go +++ b/x/resources/types/expected_keepers.go @@ -1,4 +1,5 @@ package types + import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -15,4 +16,3 @@ type BankKeeper interface { MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins } - diff --git a/x/resources/types/genesis.go b/x/resources/types/genesis.go index 49e99d1..b616201 100644 --- a/x/resources/types/genesis.go +++ b/x/resources/types/genesis.go @@ -2,7 +2,7 @@ package types func NewGenesisState(params Params) *GenesisState { return &GenesisState{ - Params: params, + Params: params, } } diff --git a/x/resources/types/genesis.pb.go b/x/resources/types/genesis.pb.go index c1ff495..e1946f3 100644 --- a/x/resources/types/genesis.pb.go +++ b/x/resources/types/genesis.pb.go @@ -5,17 +5,20 @@ package types import ( fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -33,9 +36,11 @@ func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { return fileDescriptor_72c3da48739423c6, []int{0} } + func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) @@ -48,12 +53,15 @@ func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } + func (m *GenesisState) XXX_Merge(src proto.Message) { xxx_messageInfo_GenesisState.Merge(m, src) } + func (m *GenesisState) XXX_Size() int { return m.Size() } + func (m *GenesisState) XXX_DiscardUnknown() { xxx_messageInfo_GenesisState.DiscardUnknown(m) } @@ -137,6 +145,7 @@ func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *GenesisState) Size() (n int) { if m == nil { return 0 @@ -151,9 +160,11 @@ func (m *GenesisState) Size() (n int) { func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozGenesis(x uint64) (n int) { return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *GenesisState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -237,6 +248,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } return nil } + func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/resources/types/keys.go b/x/resources/types/keys.go index 59632aa..f4c3110 100644 --- a/x/resources/types/keys.go +++ b/x/resources/types/keys.go @@ -1,9 +1,9 @@ package types const ( - ModuleName = "resources" - RouterKey = ModuleName - QuerierRoute = ModuleName + ModuleName = "resources" + RouterKey = ModuleName + QuerierRoute = ModuleName - ResourcesName = "resources" -) \ No newline at end of file + ResourcesName = "resources" +) diff --git a/x/resources/types/msgs.go b/x/resources/types/msgs.go index da02166..d3ebc9e 100644 --- a/x/resources/types/msgs.go +++ b/x/resources/types/msgs.go @@ -3,6 +3,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + ctypes "github.com/cybercongress/go-cyber/types" ) @@ -29,7 +30,8 @@ func (msg MsgInvestmint) Route() string { return RouterKey } func (msg MsgInvestmint) Type() string { return ActionInvestmint } func (msg MsgInvestmint) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Neuron); if err != nil { + _, err := sdk.AccAddressFromBech32(msg.Neuron) + if err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid neuron address: %s", err) } @@ -60,4 +62,3 @@ func (msg MsgInvestmint) GetSigners() []sdk.AccAddress { } return []sdk.AccAddress{addr} } - diff --git a/x/resources/types/params.go b/x/resources/types/params.go index 3afbfd5..953f309 100644 --- a/x/resources/types/params.go +++ b/x/resources/types/params.go @@ -2,9 +2,11 @@ package types import ( "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + ctypes "github.com/cybercongress/go-cyber/types" ) @@ -31,8 +33,8 @@ var ( func ParamKeyTable() paramstypes.KeyTable { return paramstypes.NewKeyTable().RegisterParamSet(&Params{}) - } + func DefaultParams() Params { return Params{ MaxSlots: DefaultMaxSlots, @@ -40,8 +42,8 @@ func DefaultParams() Params { HalvingPeriodAmpereBlocks: DefaultHalvingPeriodAmpere, BaseInvestmintPeriodVolt: DefaultInvestmintPeriodVolt, BaseInvestmintPeriodAmpere: DefaultInvestmintPeriodAmpere, - BaseInvestmintAmountVolt: ctypes.NewSCybCoin(ctypes.Mega*1000), - BaseInvestmintAmountAmpere: ctypes.NewSCybCoin(ctypes.Mega*100), + BaseInvestmintAmountVolt: ctypes.NewSCybCoin(ctypes.Mega * 1000), + BaseInvestmintAmountAmpere: ctypes.NewSCybCoin(ctypes.Mega * 100), MinInvestmintPeriod: DefaultMinInvestmintPeriod, } } @@ -163,7 +165,7 @@ func validateBaseInvestmintAmountVolt(i interface{}) error { return fmt.Errorf("invalid parameter type: %T", i) } - if v.IsLT(ctypes.NewSCybCoin(ctypes.Mega*10)) { + if v.IsLT(ctypes.NewSCybCoin(ctypes.Mega * 10)) { return fmt.Errorf("base investmint amount for Volt must be more than 10000000: %d", v) } @@ -176,7 +178,7 @@ func validateBaseInvestmintAmountAmpere(i interface{}) error { return fmt.Errorf("invalid parameter type: %T", i) } - if v.IsLT(ctypes.NewSCybCoin(ctypes.Mega*10)) { + if v.IsLT(ctypes.NewSCybCoin(ctypes.Mega * 10)) { return fmt.Errorf("base investmint amount for Ampere must be more than 10000000: %d", v) } diff --git a/x/resources/types/querier.go b/x/resources/types/querier.go index e88823d..fbe4de4 100644 --- a/x/resources/types/querier.go +++ b/x/resources/types/querier.go @@ -8,11 +8,11 @@ const ( ) type QueryInvestmintParams struct { - Amount sdk.Coin + Amount sdk.Coin Resource string - Length uint64 + Length uint64 } func NewQueryInvestmintParams(amount sdk.Coin, resource string, length uint64) QueryInvestmintParams { return QueryInvestmintParams{amount, resource, length} -} \ No newline at end of file +} diff --git a/x/resources/types/query.pb.go b/x/resources/types/query.pb.go index 6684d0d..8cf40fb 100644 --- a/x/resources/types/query.pb.go +++ b/x/resources/types/query.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" @@ -14,15 +18,14 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -30,8 +33,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type QueryParamsRequest struct { -} +type QueryParamsRequest struct{} func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } @@ -39,9 +41,11 @@ func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_4135536742b8fe64, []int{0} } + func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) @@ -54,12 +58,15 @@ func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryParamsRequest.Merge(m, src) } + func (m *QueryParamsRequest) XXX_Size() int { return m.Size() } + func (m *QueryParamsRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) } @@ -76,9 +83,11 @@ func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_4135536742b8fe64, []int{1} } + func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) @@ -91,12 +100,15 @@ func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } + func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryParamsResponse.Merge(m, src) } + func (m *QueryParamsResponse) XXX_Size() int { return m.Size() } + func (m *QueryParamsResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) } @@ -115,9 +127,11 @@ func (*QueryInvestmintRequest) ProtoMessage() {} func (*QueryInvestmintRequest) Descriptor() ([]byte, []int) { return fileDescriptor_4135536742b8fe64, []int{2} } + func (m *QueryInvestmintRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryInvestmintRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryInvestmintRequest.Marshal(b, m, deterministic) @@ -130,12 +144,15 @@ func (m *QueryInvestmintRequest) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } + func (m *QueryInvestmintRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryInvestmintRequest.Merge(m, src) } + func (m *QueryInvestmintRequest) XXX_Size() int { return m.Size() } + func (m *QueryInvestmintRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryInvestmintRequest.DiscardUnknown(m) } @@ -152,9 +169,11 @@ func (*QueryInvestmintResponse) ProtoMessage() {} func (*QueryInvestmintResponse) Descriptor() ([]byte, []int) { return fileDescriptor_4135536742b8fe64, []int{3} } + func (m *QueryInvestmintResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *QueryInvestmintResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryInvestmintResponse.Marshal(b, m, deterministic) @@ -167,12 +186,15 @@ func (m *QueryInvestmintResponse) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } + func (m *QueryInvestmintResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryInvestmintResponse.Merge(m, src) } + func (m *QueryInvestmintResponse) XXX_Size() int { return m.Size() } + func (m *QueryInvestmintResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryInvestmintResponse.DiscardUnknown(m) } @@ -223,8 +245,10 @@ var fileDescriptor_4135536742b8fe64 = []byte{ } // Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn +var ( + _ context.Context + _ grpc.ClientConn +) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. @@ -271,12 +295,12 @@ type QueryServer interface { } // UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} +type UnimplementedQueryServer struct{} func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } + func (*UnimplementedQueryServer) Investmint(ctx context.Context, req *QueryInvestmintRequest) (*QueryInvestmintResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Investmint not implemented") } @@ -483,6 +507,7 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *QueryParamsRequest) Size() (n int) { if m == nil { return 0 @@ -535,9 +560,11 @@ func (m *QueryInvestmintResponse) Size() (n int) { func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -588,6 +615,7 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -671,6 +699,7 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryInvestmintRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -805,6 +834,7 @@ func (m *QueryInvestmintRequest) Unmarshal(dAtA []byte) error { } return nil } + func (m *QueryInvestmintResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -888,6 +918,7 @@ func (m *QueryInvestmintResponse) Unmarshal(dAtA []byte) error { } return nil } + func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/resources/types/query.pb.gw.go b/x/resources/types/query.pb.gw.go index 8574d3a..c9b0e2d 100644 --- a/x/resources/types/query.pb.gw.go +++ b/x/resources/types/query.pb.gw.go @@ -24,12 +24,14 @@ import ( ) // Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = runtime.String + _ = utilities.NewDoubleArray + _ = descriptor.ForMessage +) func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -37,7 +39,6 @@ func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, cl msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -46,12 +47,9 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal msg, err := server.Params(ctx, &protoReq) return msg, metadata, err - } -var ( - filter_Query_Investmint_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) +var filter_Query_Investmint_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_Query_Investmint_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryInvestmintRequest @@ -66,7 +64,6 @@ func request_Query_Investmint_0(ctx context.Context, marshaler runtime.Marshaler msg, err := client.Investmint(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_Query_Investmint_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -82,7 +79,6 @@ func local_request_Query_Investmint_0(ctx context.Context, marshaler runtime.Mar msg, err := server.Investmint(ctx, &protoReq) return msg, metadata, err - } // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". @@ -90,7 +86,6 @@ func local_request_Query_Investmint_0(ctx context.Context, marshaler runtime.Mar // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -108,7 +103,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Investmint_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -128,7 +122,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Investmint_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) return nil @@ -171,7 +164,6 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -189,7 +181,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) mux.Handle("GET", pattern_Query_Investmint_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -209,7 +200,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Investmint_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) return nil diff --git a/x/resources/types/tx.pb.go b/x/resources/types/tx.pb.go index 5e587fd..916cbab 100644 --- a/x/resources/types/tx.pb.go +++ b/x/resources/types/tx.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-sdk/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" @@ -14,15 +18,14 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -43,9 +46,11 @@ func (*MsgInvestmint) ProtoMessage() {} func (*MsgInvestmint) Descriptor() ([]byte, []int) { return fileDescriptor_94512119bd1d1c33, []int{0} } + func (m *MsgInvestmint) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgInvestmint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgInvestmint.Marshal(b, m, deterministic) @@ -58,20 +63,22 @@ func (m *MsgInvestmint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error return b[:n], nil } } + func (m *MsgInvestmint) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgInvestmint.Merge(m, src) } + func (m *MsgInvestmint) XXX_Size() int { return m.Size() } + func (m *MsgInvestmint) XXX_DiscardUnknown() { xxx_messageInfo_MsgInvestmint.DiscardUnknown(m) } var xxx_messageInfo_MsgInvestmint proto.InternalMessageInfo -type MsgInvestmintResponse struct { -} +type MsgInvestmintResponse struct{} func (m *MsgInvestmintResponse) Reset() { *m = MsgInvestmintResponse{} } func (m *MsgInvestmintResponse) String() string { return proto.CompactTextString(m) } @@ -79,9 +86,11 @@ func (*MsgInvestmintResponse) ProtoMessage() {} func (*MsgInvestmintResponse) Descriptor() ([]byte, []int) { return fileDescriptor_94512119bd1d1c33, []int{1} } + func (m *MsgInvestmintResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *MsgInvestmintResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgInvestmintResponse.Marshal(b, m, deterministic) @@ -94,12 +103,15 @@ func (m *MsgInvestmintResponse) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } + func (m *MsgInvestmintResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgInvestmintResponse.Merge(m, src) } + func (m *MsgInvestmintResponse) XXX_Size() int { return m.Size() } + func (m *MsgInvestmintResponse) XXX_DiscardUnknown() { xxx_messageInfo_MsgInvestmintResponse.DiscardUnknown(m) } @@ -140,8 +152,10 @@ var fileDescriptor_94512119bd1d1c33 = []byte{ } // Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn +var ( + _ context.Context + _ grpc.ClientConn +) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. @@ -177,8 +191,7 @@ type MsgServer interface { } // UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} +type UnimplementedMsgServer struct{} func (*UnimplementedMsgServer) Investmint(ctx context.Context, req *MsgInvestmint) (*MsgInvestmintResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Investmint not implemented") @@ -305,6 +318,7 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *MsgInvestmint) Size() (n int) { if m == nil { return 0 @@ -339,9 +353,11 @@ func (m *MsgInvestmintResponse) Size() (n int) { func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *MsgInvestmint) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -508,6 +524,7 @@ func (m *MsgInvestmint) Unmarshal(dAtA []byte) error { } return nil } + func (m *MsgInvestmintResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -558,6 +575,7 @@ func (m *MsgInvestmintResponse) Unmarshal(dAtA []byte) error { } return nil } + func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/resources/types/types.pb.go b/x/resources/types/types.pb.go index c605235..688e200 100644 --- a/x/resources/types/types.pb.go +++ b/x/resources/types/types.pb.go @@ -5,19 +5,22 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/cosmos/cosmos-sdk/types" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +var ( + _ = proto.Marshal + _ = fmt.Errorf + _ = math.Inf +) // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -42,9 +45,11 @@ func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { return fileDescriptor_3be852646b47c447, []int{0} } + func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } + func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_Params.Marshal(b, m, deterministic) @@ -57,12 +62,15 @@ func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } + func (m *Params) XXX_Merge(src proto.Message) { xxx_messageInfo_Params.Merge(m, src) } + func (m *Params) XXX_Size() int { return m.Size() } + func (m *Params) XXX_DiscardUnknown() { xxx_messageInfo_Params.DiscardUnknown(m) } @@ -210,6 +218,7 @@ func (this *Params) Equal(that interface{}) bool { } return true } + func (m *Params) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -294,6 +303,7 @@ func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } + func (m *Params) Size() (n int) { if m == nil { return 0 @@ -328,9 +338,11 @@ func (m *Params) Size() (n int) { func sovTypes(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } + func sozTypes(x uint64) (n int) { return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } + func (m *Params) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -561,6 +573,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } + func skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/resources/wasm/interface.go b/x/resources/wasm/interface.go index bb1ecb9..8ccf4d7 100644 --- a/x/resources/wasm/interface.go +++ b/x/resources/wasm/interface.go @@ -25,10 +25,12 @@ func NewWasmMsgParser() WasmMsgParser { return WasmMsgParser{} } -func (WasmMsgParser) Parse(_ sdk.AccAddress, _ wasmTypes.CosmosMsg) ([]sdk.Msg, error) { return nil, nil } +func (WasmMsgParser) Parse(_ sdk.AccAddress, _ wasmTypes.CosmosMsg) ([]sdk.Msg, error) { + return nil, nil +} type CosmosMsg struct { - Investmint *types.MsgInvestmint `json:"investmint,omitempty"` + Investmint *types.MsgInvestmint `json:"investmint,omitempty"` } func (WasmMsgParser) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessage) ([]sdk.Msg, error) { @@ -43,4 +45,4 @@ func (WasmMsgParser) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessa } return nil, sdkerrors.Wrap(wasm.ErrInvalidMsg, "Unknown Resources variant") -} \ No newline at end of file +} diff --git a/x/staking/module.go b/x/staking/module.go index 3fc1143..cdcaf81 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -1,4 +1,3 @@ - package staking import ( @@ -11,9 +10,7 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) -var ( - _ module.AppModule = AppModule{} -) +var _ module.AppModule = AppModule{} type AppModule struct { staking.AppModule @@ -29,10 +26,10 @@ func NewAppModule( bankKeeper bankkeeper.Keeper, ) AppModule { return AppModule{ - AppModule: staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper), - sk: stakingKeeper, - bk: bankKeeper, - ak: accountKeeper, + AppModule: staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper), + sk: stakingKeeper, + bk: bankKeeper, + ak: accountKeeper, } } @@ -43,4 +40,4 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { m := stakingkeeper.NewMigrator(am.sk) cfg.RegisterMigration(stakingtypes.ModuleName, 1, m.Migrate1to2) -} \ No newline at end of file +} diff --git a/x/staking/msg_server.go b/x/staking/msg_server.go index 6f991a2..94985a7 100644 --- a/x/staking/msg_server.go +++ b/x/staking/msg_server.go @@ -2,6 +2,8 @@ package staking import ( "context" + "time" + "github.com/armon/go-metrics" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/telemetry" @@ -10,10 +12,10 @@ import ( bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/cosmos/cosmos-sdk/x/staking/types" + tmstrings "github.com/tendermint/tendermint/libs/strings" + ctypes "github.com/cybercongress/go-cyber/types" resourcestypes "github.com/cybercongress/go-cyber/x/resources/types" - tmstrings "github.com/tendermint/tendermint/libs/strings" - "time" ) type msgServer struct { @@ -26,7 +28,7 @@ type msgServer struct { func NewMsgServerImpl(keeper keeper.Keeper, bk bankkeeper.Keeper) types.MsgServer { return &msgServer{ Keeper: keeper, - bk: bk, + bk: bk, } } @@ -34,7 +36,7 @@ var _ types.MsgServer = msgServer{} // CreateValidator defines a method for creating a new validator func (k msgServer) CreateValidator(goCtx context.Context, msg *types.MsgCreateValidator) (*types.MsgCreateValidatorResponse, error) { - result, err := WrapCreateValidator(goCtx, k.bk , msg) + result, err := WrapCreateValidator(goCtx, k.bk, msg) if err != nil { return nil, err } @@ -203,7 +205,7 @@ func (k msgServer) EditValidator(goCtx context.Context, msg *types.MsgEditValida // Delegate defines a method for performing a delegation of coins from a delegator to a validator func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*types.MsgDelegateResponse, error) { - result, err := WrapDelegate(goCtx, k.bk , msg) + result, err := WrapDelegate(goCtx, k.bk, msg) if err != nil { return nil, err } @@ -340,7 +342,7 @@ func (k msgServer) BeginRedelegate(goCtx context.Context, msg *types.MsgBeginRed // Undelegate defines a method for performing an undelegation from a delegate and a validator func (k msgServer) Undelegate(goCtx context.Context, msg *types.MsgUndelegate) (*types.MsgUndelegateResponse, error) { - result, err := WrapUndelegate(goCtx, k.bk , msg) + result, err := WrapUndelegate(goCtx, k.bk, msg) if err != nil { return nil, err } @@ -418,14 +420,17 @@ func WrapDelegate( ) (bool, error) { ctx := sdk.UnwrapSDKContext(goCtx) - delegator, err := sdk.AccAddressFromBech32(msg.DelegatorAddress); if err != nil { + delegator, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { return false, err } toMint := sdk.NewCoin(ctypes.SCYB, msg.Amount.Amount) - err = bk.MintCoins(ctx, resourcestypes.ResourcesName, sdk.NewCoins(toMint)); if err != nil { + err = bk.MintCoins(ctx, resourcestypes.ResourcesName, sdk.NewCoins(toMint)) + if err != nil { return false, err } - err = bk.SendCoinsFromModuleToAccount(ctx, resourcestypes.ResourcesName, delegator, sdk.NewCoins(toMint)); if err != nil { + err = bk.SendCoinsFromModuleToAccount(ctx, resourcestypes.ResourcesName, delegator, sdk.NewCoins(toMint)) + if err != nil { return false, err } @@ -439,14 +444,17 @@ func WrapUndelegate( ) (bool, error) { ctx := sdk.UnwrapSDKContext(goCtx) - delegator, err := sdk.AccAddressFromBech32(msg.DelegatorAddress); if err != nil { + delegator, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { return false, err } toBurn := sdk.NewCoin(ctypes.SCYB, msg.Amount.Amount) - err = bk.SendCoinsFromAccountToModule(ctx, delegator, resourcestypes.ResourcesName, sdk.NewCoins(toBurn)); if err != nil { + err = bk.SendCoinsFromAccountToModule(ctx, delegator, resourcestypes.ResourcesName, sdk.NewCoins(toBurn)) + if err != nil { return false, err } - err = bk.BurnCoins(ctx, resourcestypes.ResourcesName, sdk.NewCoins(toBurn)); if err != nil { + err = bk.BurnCoins(ctx, resourcestypes.ResourcesName, sdk.NewCoins(toBurn)) + if err != nil { return false, err } @@ -460,17 +468,19 @@ func WrapCreateValidator( ) (bool, error) { ctx := sdk.UnwrapSDKContext(goCtx) - delegator, err := sdk.AccAddressFromBech32(msg.DelegatorAddress); if err != nil { + delegator, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { return false, err } toMint := sdk.NewCoin(ctypes.SCYB, msg.Value.Amount) - err = bk.MintCoins(ctx, resourcestypes.ResourcesName, sdk.NewCoins(toMint)); if err != nil { + err = bk.MintCoins(ctx, resourcestypes.ResourcesName, sdk.NewCoins(toMint)) + if err != nil { return false, err } - err = bk.SendCoinsFromModuleToAccount(ctx, resourcestypes.ResourcesName, delegator, sdk.NewCoins(toMint)); if err != nil { + err = bk.SendCoinsFromModuleToAccount(ctx, resourcestypes.ResourcesName, delegator, sdk.NewCoins(toMint)) + if err != nil { return false, err } return true, nil } - From 120e8ca00e2597a06d93f4ce6a030da671115562 Mon Sep 17 00:00:00 2001 From: C H Date: Tue, 19 Sep 2023 11:02:52 +0800 Subject: [PATCH 2/7] lint --- .golangci.yml | 35 +++ Makefile | 7 +- app/ante.go | 29 ++- app/app.go | 11 +- app/export.go | 1 - app/prefix.go | 5 +- cmd/cyber/cmd/testnet.go | 2 +- cmd/iavltool/cmd/root.go | 18 +- cmd/iavltool/main.go | 5 +- merkle/proof.go | 3 +- merkle/tree.go | 2 +- .../plugin.go} | 67 +++--- plugins/msg_binding.go | 4 +- plugins/query_binding.go | 3 +- x/bandwidth/keeper/keeper.go | 2 +- x/bandwidth/types/account_bandwidth.go | 6 +- x/bandwidth/wasm/interface.go | 25 ++- x/cyberbank/keeper/proxy.go | 4 - x/cyberbank/module.go | 3 +- x/dmn/client/cli/query.go | 4 +- x/dmn/keeper/keeper.go | 13 +- x/dmn/keeper/msg_server.go | 6 +- x/dmn/module.go | 1 - x/dmn/types/codec.go | 3 +- x/dmn/types/expected_keepers.go | 1 - x/dmn/types/msgs.go | 2 - x/dmn/types/thought.go | 2 - x/dmn/wasm/interface.go | 71 +++--- x/graph/client/cli/tx.go | 8 - x/graph/keeper/genesis.go | 3 +- x/graph/keeper/graph.go | 8 +- x/graph/keeper/grpc_query.go | 9 +- x/graph/keeper/index.go | 16 +- x/graph/keeper/msg_server.go | 12 +- x/graph/keeper/neudeg.go | 2 +- x/graph/keeper/particles.go | 2 +- x/graph/keeper/querier.go | 2 +- x/graph/module.go | 6 - x/graph/types/compact_link.go | 6 +- x/graph/types/cyberlinks.go | 14 +- x/graph/wasm/interface.go | 35 +-- x/grid/client/cli/query.go | 8 +- x/grid/client/rest/query.go | 4 + x/grid/keeper/keeper.go | 3 +- x/grid/types/expected_keepers.go | 5 - x/grid/wasm/interface.go | 59 +++-- x/rank/client/cli/query.go | 4 +- x/rank/client/rest/query.go | 1 - x/rank/keeper/calculate_cpu.go | 20 +- x/rank/keeper/grpc_query.go | 95 ++++---- x/rank/keeper/keeper.go | 207 +++++++++--------- x/rank/keeper/querier.go | 24 +- x/rank/module.go | 1 - x/rank/types/context.go | 40 ++-- x/rank/types/index.go | 22 +- x/rank/types/index_types.go | 14 +- x/rank/types/rank.go | 13 +- x/rank/wasm/interface.go | 14 +- x/resources/client/rest/query.go | 2 +- x/resources/keeper/keeper.go | 41 ++-- x/resources/keeper/msg_server.go | 2 +- x/resources/module.go | 1 - x/resources/types/params.go | 4 +- x/resources/wasm/interface.go | 20 +- x/staking/module.go | 2 +- x/staking/msg_server.go | 9 +- 66 files changed, 533 insertions(+), 540 deletions(-) rename plugins/{liquidity_plugin/liquidity_plugin.go => liquidity/plugin.go} (80%) diff --git a/.golangci.yml b/.golangci.yml index e69de29..8eeca2d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -0,0 +1,35 @@ +run: + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 10m + tests: true + +linters: + disable-all: true + enable: + - bodyclose + - depguard + - dogsled + - errcheck + - goconst + - gocritic + - gofumpt + - revive + - gosec + - gosimple + - govet + - ineffassign + - misspell + - nakedret + - exportloopref + - staticcheck + - stylecheck + - typecheck + - unconvert + - unused + - unparam + - misspell + +linters-settings: + gosec: + excludes: + - G404 diff --git a/Makefile b/Makefile index 180cc1f..4537652 100644 --- a/Makefile +++ b/Makefile @@ -117,10 +117,9 @@ go.sum: go.mod go mod tidy -compat=1.17 .PHONY: go.sum -lint: - $(BINDIR)/golangci-lint run - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*.pb.go" | xargs gofmt -d -s - go mod verify +lint: format-tools + golangci-lint run --tests=false + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*_test.go" | xargs gofumpt -d .PHONY: lint statik: diff --git a/app/ante.go b/app/ante.go index 7bff12b..11dac3b 100644 --- a/app/ante.go +++ b/app/ante.go @@ -10,13 +10,11 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/ante" - "github.com/cosmos/cosmos-sdk/x/auth/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" ctypes "github.com/cybercongress/go-cyber/types" - wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" ibcante "github.com/cosmos/ibc-go/v3/modules/core/ante" "github.com/cosmos/ibc-go/v3/modules/core/keeper" @@ -33,7 +31,7 @@ type HandlerBaseOptions struct { FeegrantKeeper ante.FeegrantKeeper BandwidthMeter *bandwidthkeeper.BandwidthMeter SignModeHandler authsigning.SignModeHandler - SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error + SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params) error } // HandlerOptions extend the SDK's AnteHandler options by requiring the IBC @@ -42,7 +40,7 @@ type HandlerOptions struct { HandlerBaseOptions IBCKeeper *keeper.Keeper - WasmConfig *wasmTypes.WasmConfig + WasmConfig *wasmtypes.WasmConfig TXCounterStoreKey sdk.StoreKey } @@ -152,8 +150,8 @@ func (drd DeductFeeBandDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") } - if addr := drd.ak.GetModuleAddress(types.FeeCollectorName); addr == nil { - panic(fmt.Sprintf("%s module account has not been set", types.FeeCollectorName)) + if addr := drd.ak.GetModuleAddress(authtypes.FeeCollectorName); addr == nil { + panic(fmt.Sprintf("%s module account has not been set", authtypes.FeeCollectorName)) } fee := feeTx.GetFee() @@ -219,20 +217,19 @@ func (drd DeductFeeBandDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat currentBlockSpentBandwidth := drd.bandMeter.GetCurrentBlockSpentBandwidth(ctx) maxBlockBandwidth := drd.bandMeter.GetMaxBlockBandwidth(ctx) + //nolint:gocritic if !simulate { if !accountBandwidth.HasEnoughRemained(txCost) { return ctx, bandwidthtypes.ErrNotEnoughBandwidth } else if (txCost + currentBlockSpentBandwidth) > maxBlockBandwidth { return ctx, bandwidthtypes.ErrExceededMaxBlockBandwidth - } else { - if !ctx.IsCheckTx() && !ctx.IsReCheckTx() { - err = drd.bandMeter.ConsumeAccountBandwidth(ctx, accountBandwidth, txCost) - if err != nil { - return ctx, err - } - // TODO think to add to transient store - drd.bandMeter.AddToBlockBandwidth(txCost) + } else if !ctx.IsCheckTx() && !ctx.IsReCheckTx() { + err = drd.bandMeter.ConsumeAccountBandwidth(ctx, accountBandwidth, txCost) + if err != nil { + return ctx, err } + // TODO think to add to transient store + drd.bandMeter.AddToBlockBandwidth(txCost) } } return next(ctx, tx, simulate) @@ -248,7 +245,7 @@ func DeductFees(bankKeeper bankkeeper.Keeper, ctx sdk.Context, acc authtypes.Acc } if program2pay == nil { - err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), types.FeeCollectorName, fees) + err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), authtypes.FeeCollectorName, fees) if err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error()) } @@ -265,7 +262,7 @@ func DeductFees(bankKeeper bankkeeper.Keeper, ctx sdk.Context, acc authtypes.Acc return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error()) } - err = bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), types.FeeCollectorName, toValidatorsAmount) + err = bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), authtypes.FeeCollectorName, toValidatorsAmount) if err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error()) } diff --git a/app/app.go b/app/app.go index 6eea3d1..8fc4329 100644 --- a/app/app.go +++ b/app/app.go @@ -9,6 +9,8 @@ import ( "strings" "time" + liquidityplugin "github.com/cybercongress/go-cyber/plugins/liquidity" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/cosmos/cosmos-sdk/x/authz" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" @@ -27,9 +29,6 @@ import ( ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host" ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper" - _ "github.com/cybercongress/go-cyber/client/docs/statik" - "github.com/cybercongress/go-cyber/plugins/liquidity_plugin" - "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" "github.com/gorilla/mux" "github.com/rakyll/statik/fs" @@ -608,7 +607,7 @@ func NewApp( wasmplugins.WasmQueryRouteDmn: dmnwasm.NewWasmQuerier(*app.DmnKeeper), wasmplugins.WasmQueryRouteGrid: gridwasm.NewWasmQuerier(app.GridKeeper), wasmplugins.WasmQueryRouteBandwidth: bandwidthwasm.NewWasmQuerier(app.BandwidthMeter), - wasmplugins.WasmQueryRouteLiquidity: liquidity_plugin.NewWasmQuerier(app.LiquidityKeeper), + wasmplugins.WasmQueryRouteLiquidity: liquidityplugin.NewWasmQuerier(app.LiquidityKeeper), } querier.Queriers = queries queryPlugins := &wasm.QueryPlugins{ @@ -622,7 +621,7 @@ func NewApp( wasmplugins.WasmMsgParserRouteDmn: dmnwasm.NewWasmMsgParser(), wasmplugins.WasmMsgParserRouteGrid: gridwasm.NewWasmMsgParser(), wasmplugins.WasmMsgParserRouteResources: resourceswasm.NewWasmMsgParser(), - wasmplugins.WasmMsgParserLiquidity: liquidity_plugin.NewWasmMsgParser(), + wasmplugins.WasmMsgParserLiquidity: liquidityplugin.NewWasmMsgParser(), } parser.Parsers = parsers customEncoders := &wasm.MessageEncoders{ @@ -867,7 +866,7 @@ func NewApp( // migration wouldn't be called because bank's consensus version is 2 m := bankkeeper.NewMigrator(app.BankKeeper.(bankkeeper.BaseKeeper)) // TODO check current bank migrations - app.configurator.RegisterMigration(banktypes.ModuleName, 1, m.Migrate1to2) + app.configurator.RegisterMigration(banktypes.ModuleName, 1, m.Migrate1to2) //nolint:errcheck // initialize stores app.MountKVStores(keys) diff --git a/app/export.go b/app/export.go index 915fe48..881571d 100644 --- a/app/export.go +++ b/app/export.go @@ -11,7 +11,6 @@ import ( slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" "github.com/cosmos/cosmos-sdk/x/staking" - //"github.com/cosmos/cosmos-sdk/x/staking/exported" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) diff --git a/app/prefix.go b/app/prefix.go index c668a1b..b663238 100644 --- a/app/prefix.go +++ b/app/prefix.go @@ -1,8 +1,7 @@ package app import ( - "fmt" - + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -20,9 +19,9 @@ var ( func SetConfig() { config := sdk.GetConfig() config.SetCoinType(uint32(CoinType)) - config.SetFullFundraiserPath(fmt.Sprintf("m/44'/%d'/0'/0/0", CoinType)) config.SetBech32PrefixForAccount(AccountAddressPrefix, AccountPubKeyPrefix) config.SetBech32PrefixForValidator(ValidatorAddressPrefix, ValidatorPubKeyPrefix) config.SetBech32PrefixForConsensusNode(ConsNodeAddressPrefix, ConsNodePubKeyPrefix) + config.SetAddressVerifier(wasmtypes.VerifyAddressLen()) config.Seal() } diff --git a/cmd/cyber/cmd/testnet.go b/cmd/cyber/cmd/testnet.go index 75b737a..f45fcfe 100644 --- a/cmd/cyber/cmd/testnet.go +++ b/cmd/cyber/cmd/testnet.go @@ -381,7 +381,7 @@ func calculateIP(ip string, i int) (string, error) { } func writeFile(name string, dir string, contents []byte) error { - writePath := filepath.Join(dir) + writePath := filepath.Join(dir) //nolint:gocritic file := filepath.Join(writePath, name) err := tmos.EnsureDir(writePath, 0o755) diff --git a/cmd/iavltool/cmd/root.go b/cmd/iavltool/cmd/root.go index 9f7320a..a1d263d 100644 --- a/cmd/iavltool/cmd/root.go +++ b/cmd/iavltool/cmd/root.go @@ -71,7 +71,7 @@ var dataCmd = &cobra.Command{ Short: "Print data of given stores at given block", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { - db, err := OpenDb(home) + db, err := OpenDB(home) if err != nil { fmt.Println("ERROR DB OPEN:", err) } @@ -116,7 +116,7 @@ var shapeCmd = &cobra.Command{ Short: "Print shape of given stores at given block", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { - db, err := OpenDb(home) + db, err := OpenDB(home) if err != nil { fmt.Println("ERROR DB OPEN:", err) } @@ -145,7 +145,7 @@ var versionsCmd = &cobra.Command{ Short: "Print shape of given stores at given block", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - db, err := OpenDb(home) + db, err := OpenDB(home) if err != nil { fmt.Println("ERROR DB OPEN:", err) } @@ -164,7 +164,7 @@ var deleteCmd = &cobra.Command{ Short: "Delete versions range for given stores", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { - db, err := OpenDb(home) + db, err := OpenDB(home) if err != nil { fmt.Println("ERROR DB OPEN:", err) } @@ -206,12 +206,12 @@ var statsCmd = &cobra.Command{ Short: "Print shape of given stores at given block", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { - db, err := OpenDb(home) + db, err := OpenDB(home) if err != nil { fmt.Println("ERROR DB OPEN:", err) } - PrintDbStats(db) + PrintDBStats(db) }, } @@ -222,16 +222,16 @@ var pruneCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { db, _ := goleveldb.OpenFile(home+"/application.db", nil) defer db.Close() - _ = db.CompactRange(util.Range{nil, nil}) + _ = db.CompactRange(util.Range{Start: nil, Limit: nil}) }, } -func OpenDb(dir string) (dbm.DB, error) { +func OpenDB(dir string) (dbm.DB, error) { db, err := dbm.NewDB("application", dbm.GoLevelDBBackend, dir) return db, err } -func PrintDbStats(db dbm.DB) { +func PrintDBStats(db dbm.DB) { count := 0 prefix := map[string]int{} iter, err := db.Iterator(nil, nil) diff --git a/cmd/iavltool/main.go b/cmd/iavltool/main.go index 66e83f6..eb86a12 100644 --- a/cmd/iavltool/main.go +++ b/cmd/iavltool/main.go @@ -5,5 +5,8 @@ import ( ) func main() { - cmd.Execute() + err := cmd.Execute() + if err != nil { + return + } } diff --git a/merkle/proof.go b/merkle/proof.go index 200f568..d673608 100644 --- a/merkle/proof.go +++ b/merkle/proof.go @@ -13,7 +13,6 @@ type Proof struct { func (p *Proof) SumWith(hashF hash.Hash, hash []byte) []byte { if p.LeftSide { return sum(hashF, p.Hash, hash) - } else { - return sum(hashF, hash, p.Hash) } + return sum(hashF, hash, p.Hash) } diff --git a/merkle/tree.go b/merkle/tree.go index 1575357..2686513 100644 --- a/merkle/tree.go +++ b/merkle/tree.go @@ -94,7 +94,7 @@ func (t *Tree) BuildNew(data [][]byte) { t.subTreesCount++ - itemsLeft = itemsLeft - nextSubtreeLen + itemsLeft -= nextSubtreeLen nextSubtreeLen = int64(math.Pow(2, float64(int64(math.Log2(float64(itemsLeft)))))) startIndex = endIndex endIndex = startIndex + nextSubtreeLen diff --git a/plugins/liquidity_plugin/liquidity_plugin.go b/plugins/liquidity/plugin.go similarity index 80% rename from plugins/liquidity_plugin/liquidity_plugin.go rename to plugins/liquidity/plugin.go index 096564a..9ef4434 100644 --- a/plugins/liquidity_plugin/liquidity_plugin.go +++ b/plugins/liquidity/plugin.go @@ -1,14 +1,14 @@ -package liquidity_plugin +package liquidity import ( "encoding/json" + wasmvmtypes "github.com/CosmWasm/wasmvm/types" liquiditytypes "github.com/tendermint/liquidity/x/liquidity/types" "github.com/cybercongress/go-cyber/plugins" "github.com/CosmWasm/wasmd/x/wasm" - wasmTypes "github.com/CosmWasm/wasmvm/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -28,7 +28,7 @@ func NewWasmMsgParser() WasmMsgParser { return WasmMsgParser{} } -func (WasmMsgParser) Parse(_ sdk.AccAddress, _ wasmTypes.CosmosMsg) ([]sdk.Msg, error) { +func (WasmMsgParser) Parse(_ sdk.AccAddress, _ wasmvmtypes.CosmosMsg) ([]sdk.Msg, error) { return nil, nil } @@ -46,17 +46,18 @@ func (WasmMsgParser) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessa return nil, sdkerrors.Wrap(err, "failed to parse link custom msg") } - if sdkMsg.SwapWithinBatch != nil { + switch { + case sdkMsg.SwapWithinBatch != nil: return []sdk.Msg{sdkMsg.SwapWithinBatch}, sdkMsg.SwapWithinBatch.ValidateBasic() - } else if sdkMsg.DepositWithinBatch != nil { + case sdkMsg.DepositWithinBatch != nil: return []sdk.Msg{sdkMsg.DepositWithinBatch}, sdkMsg.DepositWithinBatch.ValidateBasic() - } else if sdkMsg.WithdrawWithinBatch != nil { + case sdkMsg.WithdrawWithinBatch != nil: return []sdk.Msg{sdkMsg.WithdrawWithinBatch}, sdkMsg.WithdrawWithinBatch.ValidateBasic() - } else if sdkMsg.CreatePool != nil { + case sdkMsg.CreatePool != nil: return []sdk.Msg{sdkMsg.CreatePool}, sdkMsg.CreatePool.ValidateBasic() + default: + return nil, sdkerrors.Wrap(wasm.ErrInvalidMsg, "Unknown variant of Liquidity") } - - return nil, sdkerrors.Wrap(wasm.ErrInvalidMsg, "Unknown variant of Liquidity") } //-------------------------------------------------- @@ -69,7 +70,7 @@ func NewWasmQuerier(keeper keeper.Keeper) WasmQuerier { return WasmQuerier{keeper} } -func (WasmQuerier) Query(_ sdk.Context, _ wasmTypes.QueryRequest) ([]byte, error) { return nil, nil } +func (WasmQuerier) Query(_ sdk.Context, _ wasmvmtypes.QueryRequest) ([]byte, error) { return nil, nil } type CosmosQuery struct { PoolParams *QueryPoolParams `json:"pool_params,omitempty"` @@ -80,22 +81,22 @@ type CosmosQuery struct { } type QueryPoolParams struct { - PoolId uint64 `json:"pool_id"` + PoolID uint64 `json:"pool_id"` } type PoolParamsResponse struct { - TypeId uint32 `json:"type_id"` + TypeID uint32 `json:"type_id"` ReserveCoinDenoms []string `json:"reserve_coin_denoms"` ReserveAccountAddress string `json:"reserve_account_address"` PoolCoinDenom string `json:"pool_coin_denom"` } type PoolLiquidityResponse struct { - Liquidity wasmTypes.Coins `json:"liquidity"` + Liquidity wasmvmtypes.Coins `json:"liquidity"` } type PoolSupplyResponse struct { - Supply wasmTypes.Coin `json:"supply"` + Supply wasmvmtypes.Coin `json:"supply"` } type PoolPriceResponse struct { @@ -115,23 +116,24 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ var bz []byte - if query.PoolParams != nil { - pool, found := querier.Keeper.GetPool(ctx, query.PoolParams.PoolId) - if found != true { + switch { + case query.PoolParams != nil: + pool, found := querier.Keeper.GetPool(ctx, query.PoolParams.PoolID) + if !found { return nil, sdkerrors.ErrInvalidRequest } bz, err = json.Marshal( PoolParamsResponse{ - TypeId: pool.TypeId, + TypeID: pool.TypeId, ReserveCoinDenoms: pool.ReserveCoinDenoms, ReserveAccountAddress: pool.ReserveAccountAddress, PoolCoinDenom: pool.PoolCoinDenom, }, ) - } else if query.PoolLiquidity != nil { - pool, found := querier.Keeper.GetPool(ctx, query.PoolLiquidity.PoolId) - if found != true { + case query.PoolLiquidity != nil: + pool, found := querier.Keeper.GetPool(ctx, query.PoolLiquidity.PoolID) + if !found { return nil, sdkerrors.ErrInvalidRequest } @@ -142,9 +144,9 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ Liquidity: plugins.ConvertSdkCoinsToWasmCoins(reserveCoins), }, ) - } else if query.PoolSupply != nil { - pool, found := querier.Keeper.GetPool(ctx, query.PoolSupply.PoolId) - if found != true { + case query.PoolSupply != nil: + pool, found := querier.Keeper.GetPool(ctx, query.PoolSupply.PoolID) + if !found { return nil, sdkerrors.ErrInvalidRequest } @@ -155,9 +157,9 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ Supply: plugins.ConvertSdkCoinToWasmCoin(poolSupply), }, ) - } else if query.PoolPrice != nil { - pool, found := querier.Keeper.GetPool(ctx, query.PoolPrice.PoolId) - if found != true { + case query.PoolPrice != nil: + pool, found := querier.Keeper.GetPool(ctx, query.PoolPrice.PoolID) + if !found { return nil, sdkerrors.ErrInvalidRequest } @@ -170,9 +172,9 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ Price: X.Quo(Y).String(), }, ) - } else if query.PoolAddress != nil { - pool, found := querier.Keeper.GetPool(ctx, query.PoolAddress.PoolId) - if found != true { + case query.PoolAddress != nil: + pool, found := querier.Keeper.GetPool(ctx, query.PoolAddress.PoolID) + if !found { return nil, sdkerrors.ErrInvalidRequest } @@ -181,9 +183,10 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ Address: pool.ReserveAccountAddress, }, ) - } else { - return nil, sdkerrors.ErrInvalidRequest + default: + return nil, wasmvmtypes.UnsupportedRequest{Kind: "unknown Liquidity variant"} } + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) } diff --git a/plugins/msg_binding.go b/plugins/msg_binding.go index 2ab2d37..45b3479 100644 --- a/plugins/msg_binding.go +++ b/plugins/msg_binding.go @@ -6,7 +6,7 @@ import ( liquiditytypes "github.com/tendermint/liquidity/x/liquidity/types" "github.com/CosmWasm/wasmd/x/wasm" - wasmTypes "github.com/CosmWasm/wasmvm/types" + wasmvmtypes "github.com/CosmWasm/wasmvm/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -18,7 +18,7 @@ import ( ) type WasmMsgParserInterface interface { - Parse(contractAddr sdk.AccAddress, msg wasmTypes.CosmosMsg) ([]sdk.Msg, error) + Parse(contractAddr sdk.AccAddress, msg wasmvmtypes.CosmosMsg) ([]sdk.Msg, error) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessage) ([]sdk.Msg, error) } diff --git a/plugins/query_binding.go b/plugins/query_binding.go index 1f79c13..9cd06db 100644 --- a/plugins/query_binding.go +++ b/plugins/query_binding.go @@ -55,9 +55,8 @@ func (q Querier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, err if querier, ok := q.Queriers[customQuery.Route]; ok { return querier.QueryCustom(ctx, customQuery.QueryData) - } else { - return nil, sdkerrors.Wrap(wasm.ErrQueryFailed, customQuery.Route) } + return nil, sdkerrors.Wrap(wasm.ErrQueryFailed, customQuery.Route) } func ConvertSdkCoinsToWasmCoins(coins []sdk.Coin) wasmvmtypes.Coins { diff --git a/x/bandwidth/keeper/keeper.go b/x/bandwidth/keeper/keeper.go index 937f4a7..6177e10 100644 --- a/x/bandwidth/keeper/keeper.go +++ b/x/bandwidth/keeper/keeper.go @@ -201,7 +201,7 @@ func (bm *BandwidthMeter) GetTotalCyberlinksCost(ctx sdk.Context, tx sdk.Tx) uin bandwidthForTx := uint64(0) for _, msg := range tx.GetMsgs() { linkMsg := msg.(*gtypes.MsgCyberlink) - bandwidthForTx = bandwidthForTx + uint64(len(linkMsg.Links))*1000 + bandwidthForTx += uint64(len(linkMsg.Links)) * 1000 } return bandwidthForTx } diff --git a/x/bandwidth/types/account_bandwidth.go b/x/bandwidth/types/account_bandwidth.go index b7aeb1e..f433e15 100644 --- a/x/bandwidth/types/account_bandwidth.go +++ b/x/bandwidth/types/account_bandwidth.go @@ -32,13 +32,13 @@ func (ab *NeuronBandwidth) Recover(currentBlock uint64, recoveryPeriod uint64) { recoverAmount = fullRecoveryAmount } - ab.RemainedValue = ab.RemainedValue + uint64(recoverAmount) + ab.RemainedValue += uint64(recoverAmount) ab.LastUpdatedBlock = currentBlock } func (ab *NeuronBandwidth) Consume(bandwidthToConsume uint64) error { - ab.RemainedValue = ab.RemainedValue - bandwidthToConsume - if ab.RemainedValue < 0 { + ab.RemainedValue -= bandwidthToConsume + if ab.RemainedValue < 0 { //nolint:staticcheck return ErrNotEnoughBandwidth } return nil diff --git a/x/bandwidth/wasm/interface.go b/x/bandwidth/wasm/interface.go index d442f75..1d21b0f 100644 --- a/x/bandwidth/wasm/interface.go +++ b/x/bandwidth/wasm/interface.go @@ -11,22 +11,22 @@ import ( "github.com/cybercongress/go-cyber/x/bandwidth/keeper" ) -var _ WasmQuerierInterface = WasmQuerier{} +var _ QuerierInterface = Querier{} -type WasmQuerierInterface interface { +type QuerierInterface interface { Query(ctx sdk.Context, request wasmvmtypes.QueryRequest) ([]byte, error) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) } -type WasmQuerier struct { +type Querier struct { *keeper.BandwidthMeter } -func NewWasmQuerier(keeper *keeper.BandwidthMeter) WasmQuerier { - return WasmQuerier{keeper} +func NewWasmQuerier(keeper *keeper.BandwidthMeter) Querier { + return Querier{keeper} } -func (WasmQuerier) Query(_ sdk.Context, _ wasmvmtypes.QueryRequest) ([]byte, error) { return nil, nil } +func (Querier) Query(_ sdk.Context, _ wasmvmtypes.QueryRequest) ([]byte, error) { return nil, nil } type CosmosQuery struct { BandwidthPrice *struct{} `json:"bandwidth_price,omitempty"` @@ -58,7 +58,7 @@ type NeuronBandwidthResponse struct { MaxValue uint64 `json:"max_value"` } -func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) { +func (querier Querier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) { var query CosmosQuery err := json.Unmarshal(data, &query) if err != nil { @@ -67,25 +67,26 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ var bz []byte - if query.BandwidthPrice != nil { + switch { + case query.BandwidthPrice != nil: price := querier.BandwidthMeter.GetCurrentCreditPrice() bz, err = json.Marshal(BandwidthPriceResponse{ Price: price.String(), }) - } else if query.BandwidthLoad != nil { + case query.BandwidthLoad != nil: load := querier.BandwidthMeter.GetCurrentNetworkLoad(ctx) bz, err = json.Marshal(BandwidthLoadResponse{ Load: load.String(), }) - } else if query.BandwidthTotal != nil { + case query.BandwidthTotal != nil: desirableBandwidth := querier.BandwidthMeter.GetDesirableBandwidth(ctx) bz, err = json.Marshal(BandwidthTotalResponse{ Total: desirableBandwidth, }) - } else if query.NeuronBandwidth != nil { + case query.NeuronBandwidth != nil: address, _ := sdk.AccAddressFromBech32(query.NeuronBandwidth.Neuron) accountBandwidth := querier.BandwidthMeter.GetCurrentAccountBandwidth(ctx, address) @@ -95,7 +96,7 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ LastUpdatedBlock: accountBandwidth.LastUpdatedBlock, MaxValue: accountBandwidth.MaxValue, }) - } else { + default: return nil, wasmvmtypes.UnsupportedRequest{Kind: "unknown Bandwidth variant"} } diff --git a/x/cyberbank/keeper/proxy.go b/x/cyberbank/keeper/proxy.go index ee0e1bb..5da73a5 100644 --- a/x/cyberbank/keeper/proxy.go +++ b/x/cyberbank/keeper/proxy.go @@ -128,10 +128,6 @@ func (p *Proxy) SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule strin func (p *Proxy) SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error { err := p.bk.SendCoinsFromModuleToModule(ctx, senderModule, recipientModule, amt) - - //if err == nil { - // p.OnCoinsTransfer(ctx, p.ak.GetModuleAddress(senderModule), p.ak.GetModuleAddress(recipientModule)) - //} return err } diff --git a/x/cyberbank/module.go b/x/cyberbank/module.go index b5ff5a3..bcd9b63 100644 --- a/x/cyberbank/module.go +++ b/x/cyberbank/module.go @@ -2,7 +2,7 @@ package cyberbank import ( "encoding/json" - //"context" + "github.com/cosmos/cosmos-sdk/client" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/gorilla/mux" @@ -11,7 +11,6 @@ import ( abci "github.com/tendermint/tendermint/abci/types" - //"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" diff --git a/x/dmn/client/cli/query.go b/x/dmn/client/cli/query.go index c46d5d7..6887368 100644 --- a/x/dmn/client/cli/query.go +++ b/x/dmn/client/cli/query.go @@ -82,7 +82,7 @@ func GetCmdQueryThought() *cobra.Command { res, err := queryClient.Thought( context.Background(), &types.QueryThoughtParamsRequest{ - program.String(), args[1], + Program: program.String(), Name: args[1], }, ) if err != nil { @@ -118,7 +118,7 @@ func GetCmdQueryThoughtStats() *cobra.Command { res, err := queryClient.ThoughtStats( context.Background(), &types.QueryThoughtParamsRequest{ - program.String(), args[1], + Program: program.String(), Name: args[1], }, ) if err != nil { diff --git a/x/dmn/keeper/keeper.go b/x/dmn/keeper/keeper.go index 801eb75..f7a71e2 100644 --- a/x/dmn/keeper/keeper.go +++ b/x/dmn/keeper/keeper.go @@ -255,8 +255,6 @@ func (k Keeper) UpdateThoughtBlock( return nil } -//______________________________________________________________________ - func (k Keeper) MaxThougths(ctx sdk.Context) (res uint32) { k.paramspace.Get(ctx, types.KeyMaxSlots, &res) return @@ -272,8 +270,6 @@ func (k Keeper) FeeTTL(ctx sdk.Context) (res uint32) { return } -//______________________________________________________________________ - func (k Keeper) SetThought(ctx sdk.Context, thought types.Thought) { store := ctx.KVStore(k.storeKey) b := k.cdc.MustMarshal(&thought) @@ -309,8 +305,6 @@ func (k Keeper) DeleteThoughtStats(ctx sdk.Context, program sdk.AccAddress, name store.Delete(types.GetThoughtStatsKey(program, name)) } -//______________________________________________________________________ - func (k Keeper) GetThought(ctx sdk.Context, program sdk.AccAddress, name string) (thought types.Thought, found bool) { store := ctx.KVStore(k.storeKey) key := types.GetThoughtKey(program, name) @@ -391,10 +385,9 @@ func (k Keeper) GetLowestFee(ctx sdk.Context) sdk.Coin { thoughts := k.GetAllThoughts(ctx) if len(thoughts) == 0 { return ctypes.NewCybCoin(0) - } else { - thoughts.Sort() - return thoughts[len(thoughts)-1].Load.GasPrice } + thoughts.Sort() + return thoughts[len(thoughts)-1].Load.GasPrice } func (k Keeper) ExecuteThoughtsQueue(ctx sdk.Context) { @@ -436,7 +429,7 @@ func (k Keeper) ExecuteThoughtsQueue(ctx sdk.Context) { price := thought.Load.GasPrice k.Logger(ctx).Info("Started thought", "number", i, "gas price", price) - thoughtsTriggered = thoughtsTriggered + 1 + thoughtsTriggered++ cacheContext, writeFn := ctx.CacheContext() cacheContext = cacheContext.WithGasMeter(sdk.NewGasMeter(sdk.Gas(maxGasPerThought))) diff --git a/x/dmn/keeper/msg_server.go b/x/dmn/keeper/msg_server.go index 90234d4..5e787a9 100644 --- a/x/dmn/keeper/msg_server.go +++ b/x/dmn/keeper/msg_server.go @@ -202,7 +202,8 @@ func (k msgServer) ChangeThoughtPeriod(goCtx context.Context, msg *types.MsgChan sdk.NewEvent( types.EventTypeChangeThoughtPeriod, sdk.NewAttribute(types.AttributeKeyThoughtProgram, msg.Program), - sdk.NewAttribute(types.AttributeKeyThoughtPeriod, string(msg.Period)), + // TODO:update later + sdk.NewAttribute(types.AttributeKeyThoughtPeriod, string(msg.Period)), //nolint:govet ), }) @@ -228,7 +229,8 @@ func (k msgServer) ChangeThoughtBlock(goCtx context.Context, msg *types.MsgChang sdk.NewEvent( types.EventTypeChangeThoughtBlock, sdk.NewAttribute(types.AttributeKeyThoughtProgram, msg.Program), - sdk.NewAttribute(types.AttributeKeyThoughtBlock, string(msg.Block)), + // TODO:update later + sdk.NewAttribute(types.AttributeKeyThoughtBlock, string(msg.Block)), //nolint:govet ), }) diff --git a/x/dmn/module.go b/x/dmn/module.go index f4b3cae..f633951 100644 --- a/x/dmn/module.go +++ b/x/dmn/module.go @@ -13,7 +13,6 @@ import ( abci "github.com/tendermint/tendermint/abci/types" - //"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" diff --git a/x/dmn/types/codec.go b/x/dmn/types/codec.go index 978b5c1..94bc1f9 100644 --- a/x/dmn/types/codec.go +++ b/x/dmn/types/codec.go @@ -3,7 +3,6 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" @@ -29,7 +28,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { var ( amino = codec.NewLegacyAmino() - ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) + ModuleCdc = codec.NewProtoCodec(types.NewInterfaceRegistry()) ) func init() { diff --git a/x/dmn/types/expected_keepers.go b/x/dmn/types/expected_keepers.go index 4b21558..b953e9f 100644 --- a/x/dmn/types/expected_keepers.go +++ b/x/dmn/types/expected_keepers.go @@ -2,7 +2,6 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - //"github.com/cosmos/cosmos-sdk/x/params" ) type BankKeeper interface { diff --git a/x/dmn/types/msgs.go b/x/dmn/types/msgs.go index 236de9b..ce77c4e 100644 --- a/x/dmn/types/msgs.go +++ b/x/dmn/types/msgs.go @@ -89,8 +89,6 @@ func (msg MsgCreateThought) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{addr} } -//______________________________________________________________________ - func NewMsgForgetThought(program sdk.AccAddress, label string) *MsgForgetThought { return &MsgForgetThought{ Program: program.String(), diff --git a/x/dmn/types/thought.go b/x/dmn/types/thought.go index 9548167..5a1c32c 100644 --- a/x/dmn/types/thought.go +++ b/x/dmn/types/thought.go @@ -39,8 +39,6 @@ func (js Thoughts) Less(i, j int) bool { func (js Thoughts) Swap(i, j int) { js[i], js[j] = js[j], js[i] } -//______________________________________________________________________ - func NewTrigger(period, block uint64) Trigger { return Trigger{ Period: period, diff --git a/x/dmn/wasm/interface.go b/x/dmn/wasm/interface.go index ecb61cc..e2ac4fa 100644 --- a/x/dmn/wasm/interface.go +++ b/x/dmn/wasm/interface.go @@ -9,8 +9,6 @@ import ( wasmplugins "github.com/cybercongress/go-cyber/plugins" - wasmTypes "github.com/CosmWasm/wasmvm/types" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" "github.com/cybercongress/go-cyber/x/dmn/keeper" @@ -18,24 +16,24 @@ import ( ) var ( - _ WasmQuerierInterface = WasmQuerier{} - _ WasmMsgParserInterface = WasmMsgParser{} + _ QuerierInterface = Querier{} + _ MsgParserInterface = MsgParser{} ) //-------------------------------------------------- -type WasmMsgParserInterface interface { - Parse(contractAddr sdk.AccAddress, msg wasmTypes.CosmosMsg) ([]sdk.Msg, error) +type MsgParserInterface interface { + Parse(contractAddr sdk.AccAddress, msg wasmvmtypes.CosmosMsg) ([]sdk.Msg, error) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessage) ([]sdk.Msg, error) } -type WasmMsgParser struct{} +type MsgParser struct{} -func NewWasmMsgParser() WasmMsgParser { - return WasmMsgParser{} +func NewWasmMsgParser() MsgParser { + return MsgParser{} } -func (WasmMsgParser) Parse(_ sdk.AccAddress, _ wasmTypes.CosmosMsg) ([]sdk.Msg, error) { +func (MsgParser) Parse(_ sdk.AccAddress, _ wasmvmtypes.CosmosMsg) ([]sdk.Msg, error) { return nil, nil } @@ -50,50 +48,51 @@ type CosmosMsg struct { ChangeThoughtName *types.MsgChangeThoughtName `json:"change_thought_name,omitempty"` } -func (WasmMsgParser) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessage) ([]sdk.Msg, error) { +func (MsgParser) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessage) ([]sdk.Msg, error) { var sdkMsg CosmosMsg err := json.Unmarshal(data, &sdkMsg) if err != nil { return nil, sdkerrors.Wrap(err, "failed to parse link custom msg") } - if sdkMsg.CreateThought != nil { + switch { + case sdkMsg.CreateThought != nil: return []sdk.Msg{sdkMsg.CreateThought}, sdkMsg.CreateThought.ValidateBasic() - } else if sdkMsg.ForgetThought != nil { + case sdkMsg.ForgetThought != nil: return []sdk.Msg{sdkMsg.ForgetThought}, sdkMsg.ForgetThought.ValidateBasic() - } else if sdkMsg.ChangeThoughtInput != nil { + case sdkMsg.ChangeThoughtInput != nil: return []sdk.Msg{sdkMsg.ChangeThoughtInput}, sdkMsg.ChangeThoughtInput.ValidateBasic() - } else if sdkMsg.ChangeThoughtPeriod != nil { + case sdkMsg.ChangeThoughtPeriod != nil: return []sdk.Msg{sdkMsg.ChangeThoughtPeriod}, sdkMsg.ChangeThoughtPeriod.ValidateBasic() - } else if sdkMsg.ChangeThoughtBlock != nil { + case sdkMsg.ChangeThoughtBlock != nil: return []sdk.Msg{sdkMsg.ChangeThoughtBlock}, sdkMsg.ChangeThoughtBlock.ValidateBasic() - } else if sdkMsg.ChangeThoughtGasPrice != nil { + case sdkMsg.ChangeThoughtGasPrice != nil: return []sdk.Msg{sdkMsg.ChangeThoughtGasPrice}, sdkMsg.ChangeThoughtGasPrice.ValidateBasic() - } else if sdkMsg.ChangeThoughtParticle != nil { + case sdkMsg.ChangeThoughtParticle != nil: return []sdk.Msg{sdkMsg.ChangeThoughtParticle}, sdkMsg.ChangeThoughtParticle.ValidateBasic() - } else if sdkMsg.ChangeThoughtName != nil { + case sdkMsg.ChangeThoughtName != nil: return []sdk.Msg{sdkMsg.ChangeThoughtName}, sdkMsg.ChangeThoughtName.ValidateBasic() + default: + return nil, sdkerrors.Wrap(wasm.ErrInvalidMsg, "Unknown variant of DMN") } - - return nil, sdkerrors.Wrap(wasm.ErrInvalidMsg, "Unknown variant of DMN") } //-------------------------------------------------- -type WasmQuerierInterface interface { - Query(ctx sdk.Context, request wasmTypes.QueryRequest) ([]byte, error) +type QuerierInterface interface { + Query(ctx sdk.Context, request wasmvmtypes.QueryRequest) ([]byte, error) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) } -type WasmQuerier struct { +type Querier struct { keeper.Keeper } -func NewWasmQuerier(keeper keeper.Keeper) WasmQuerier { - return WasmQuerier{keeper} +func NewWasmQuerier(keeper keeper.Keeper) Querier { + return Querier{keeper} } -func (WasmQuerier) Query(_ sdk.Context, _ wasmTypes.QueryRequest) ([]byte, error) { return nil, nil } +func (Querier) Query(_ sdk.Context, _ wasmvmtypes.QueryRequest) ([]byte, error) { return nil, nil } type CosmosQuery struct { Thought *QueryThoughtParams `json:"thought,omitempty"` @@ -137,7 +136,7 @@ type LowestFeeResponse struct { Fee wasmvmtypes.Coin `json:"fee"` } -func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) { +func (querier Querier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) { var query CosmosQuery err := json.Unmarshal(data, &query) if err != nil { @@ -146,11 +145,12 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ var bz []byte - if query.Thought != nil { + switch { + case query.Thought != nil: program, _ := sdk.AccAddressFromBech32(query.Thought.Program) thought, found := querier.Keeper.GetThought(ctx, program, query.Thought.Name) - if found != true { + if !found { return nil, sdkerrors.ErrInvalidRequest } @@ -162,10 +162,10 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ Name: thought.Name, Particle: thought.Particle, }) - } else if query.ThoughtStats != nil { + case query.ThoughtStats != nil: program, _ := sdk.AccAddressFromBech32(query.ThoughtStats.Program) thoughtStats, found := querier.Keeper.GetThoughtStats(ctx, program, query.ThoughtStats.Name) - if found != true { + if !found { return nil, sdkerrors.ErrInvalidRequest } @@ -178,16 +178,17 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ Gas: thoughtStats.Gas, LastBlock: thoughtStats.LastBlock, }) - } else if query.LowestFee != nil { + case query.LowestFee != nil: lowestFee := querier.Keeper.GetLowestFee(ctx) bz, err = json.Marshal( LowestFeeResponse{ Fee: wasmplugins.ConvertSdkCoinToWasmCoin(lowestFee), }, ) - } else { - return nil, sdkerrors.ErrInvalidRequest + default: + return nil, wasmvmtypes.UnsupportedRequest{Kind: "unknown DMN variant"} } + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) } diff --git a/x/graph/client/cli/tx.go b/x/graph/client/cli/tx.go index 6fec6ae..85e6693 100644 --- a/x/graph/client/cli/tx.go +++ b/x/graph/client/cli/tx.go @@ -1,22 +1,14 @@ package cli import ( - //"bufio" - //"bytes" "fmt" "strings" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - //"github.com/cosmos/cosmos-sdk/client/context" - //"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" - //"github.com/cosmos/cosmos-sdk/codec" - //sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" - //"github.com/cosmos/cosmos-sdk/x/auth" - //authclient "github.com/cosmos/cosmos-sdk/x/auth/client/utils" "github.com/ipfs/go-cid" "github.com/spf13/cobra" diff --git a/x/graph/keeper/genesis.go b/x/graph/keeper/genesis.go index 60ffee5..bc732c2 100644 --- a/x/graph/keeper/genesis.go +++ b/x/graph/keeper/genesis.go @@ -74,8 +74,7 @@ func WriteGenesis( if err != nil { return } - err = linksFile.Close() gk.Logger(ctx).Info("Particles and cyberlinks exported. File created.", "path", linksFilePath) - return + return //nolint:nakedret } diff --git a/x/graph/keeper/graph.go b/x/graph/keeper/graph.go index e18b2c5..318ee39 100644 --- a/x/graph/keeper/graph.go +++ b/x/graph/keeper/graph.go @@ -10,7 +10,7 @@ import ( "github.com/tendermint/tendermint/libs/log" - . "github.com/cybercongress/go-cyber/types" + ctypes "github.com/cybercongress/go-cyber/types" "github.com/cybercongress/go-cyber/x/graph/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -43,7 +43,7 @@ func NewKeeper( } } -func (k GraphKeeper) Logger(ctx sdk.Context) log.Logger { +func (gk GraphKeeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } @@ -66,8 +66,8 @@ func (gk GraphKeeper) GetAllLinksFiltered(ctx sdk.Context, filter types.LinkFilt gk.IterateLinks(ctx, func(link types.CompactLink) { if filter(link) { - types.Links(outLinks).Put(types.CidNumber(link.From), types.CidNumber(link.To), AccNumber(link.Account)) - types.Links(inLinks).Put(types.CidNumber(link.To), types.CidNumber(link.From), AccNumber(link.Account)) + types.Links(outLinks).Put(types.CidNumber(link.From), types.CidNumber(link.To), ctypes.AccNumber(link.Account)) + types.Links(inLinks).Put(types.CidNumber(link.To), types.CidNumber(link.From), ctypes.AccNumber(link.Account)) } }) diff --git a/x/graph/keeper/grpc_query.go b/x/graph/keeper/grpc_query.go index 025793d..c026ec7 100644 --- a/x/graph/keeper/grpc_query.go +++ b/x/graph/keeper/grpc_query.go @@ -2,13 +2,9 @@ package keeper import ( "context" - //"sort" - //"github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - //"github.com/cosmos/cosmos-sdk/types/query" - //"google.golang.org/grpc/codes" - //"google.golang.org/grpc/status" + "github.com/cybercongress/go-cyber/x/graph/types" ) @@ -19,5 +15,6 @@ func (gk GraphKeeper) GraphStats(goCtx context.Context, _ *types.QueryGraphStats links := gk.GetLinksCount(ctx) cids := gk.GetCidsCount(ctx) - return &types.QueryGraphStatsResponse{links, cids}, nil + + return &types.QueryGraphStatsResponse{Cyberlinks: links, Particles: cids}, nil } diff --git a/x/graph/keeper/index.go b/x/graph/keeper/index.go index aad8f73..d8910fe 100644 --- a/x/graph/keeper/index.go +++ b/x/graph/keeper/index.go @@ -4,9 +4,7 @@ import ( "encoding/binary" "io" - //"fmt" - - . "github.com/cybercongress/go-cyber/types" + ctypes "github.com/cybercongress/go-cyber/types" "github.com/cybercongress/go-cyber/utils" "github.com/cybercongress/go-cyber/x/graph/types" @@ -28,7 +26,7 @@ type IndexKeeper struct { // Inter-block cache for cyberlinks, reset on every block during Commit tkey sdk.StoreKey - currentBlockLinks []types.CompactLink + // currentBlockLinks []types.CompactLink } func NewIndexKeeper(gk GraphKeeper, tkey sdk.StoreKey) *IndexKeeper { @@ -48,7 +46,7 @@ func (i *IndexKeeper) LoadState(rankCtx sdk.Context, freshCtx sdk.Context) { i.currentRankOutLinks = outLinks newInLinks, newOutLinks, err := i.GraphKeeper.GetAllLinksFiltered(freshCtx, func(l types.CompactLink) bool { - return !i.currentRankOutLinks.IsLinkExist(types.CidNumber(l.From), types.CidNumber(l.To), AccNumber(l.Account)) + return !i.currentRankOutLinks.IsLinkExist(types.CidNumber(l.From), types.CidNumber(l.To), ctypes.AccNumber(l.Account)) }) if err != nil { tmos.Exit(err.Error()) @@ -73,8 +71,8 @@ func (i *IndexKeeper) MergeContextLinks(ctx sdk.Context) { defer iterator.Close() for ; iterator.Valid(); iterator.Next() { link := types.UnmarshalBinaryLink(iterator.Key()[1:]) - i.nextRankOutLinks.Put(types.CidNumber(link.From), types.CidNumber(link.To), AccNumber(link.Account)) - i.nextRankInLinks.Put(types.CidNumber(link.To), types.CidNumber(link.From), AccNumber(link.Account)) + i.nextRankOutLinks.Put(types.CidNumber(link.From), types.CidNumber(link.To), ctypes.AccNumber(link.Account)) + i.nextRankInLinks.Put(types.CidNumber(link.To), types.CidNumber(link.From), ctypes.AccNumber(link.Account)) lenLinks++ } @@ -132,8 +130,8 @@ func (i *IndexKeeper) IsAnyLinkExist(from types.CidNumber, to types.CidNumber) b } func (i *IndexKeeper) IsLinkExist(link types.CompactLink) bool { - return i.currentRankOutLinks.IsLinkExist(types.CidNumber(link.From), types.CidNumber(link.To), AccNumber(link.Account)) || - i.nextRankOutLinks.IsLinkExist(types.CidNumber(link.From), types.CidNumber(link.To), AccNumber(link.Account)) + return i.currentRankOutLinks.IsLinkExist(types.CidNumber(link.From), types.CidNumber(link.To), ctypes.AccNumber(link.Account)) || + i.nextRankOutLinks.IsLinkExist(types.CidNumber(link.From), types.CidNumber(link.To), ctypes.AccNumber(link.Account)) } func (i *IndexKeeper) IsLinkExistInCache(ctx sdk.Context, link types.CompactLink) bool { diff --git a/x/graph/keeper/msg_server.go b/x/graph/keeper/msg_server.go index 316be0c..516512f 100644 --- a/x/graph/keeper/msg_server.go +++ b/x/graph/keeper/msg_server.go @@ -81,13 +81,13 @@ func (k msgServer) Cyberlink(goCtx context.Context, msg *types.MsgCyberlink) (*t return nil, bandwidthtypes.ErrNotEnoughBandwidth } else if (cost + currentBlockSpentBandwidth) > maxBlockBandwidth { return nil, bandwidthtypes.ErrExceededMaxBlockBandwidth - } else { - err = k.ConsumeAccountBandwidth(ctx, accountBandwidth, cost) - if err != nil { - return nil, bandwidthtypes.ErrNotEnoughBandwidth - } - k.AddToBlockBandwidth(cost) } + + err = k.ConsumeAccountBandwidth(ctx, accountBandwidth, cost) + if err != nil { + return nil, bandwidthtypes.ErrNotEnoughBandwidth + } + k.AddToBlockBandwidth(cost) } for _, link := range msg.Links { diff --git a/x/graph/keeper/neudeg.go b/x/graph/keeper/neudeg.go index 35f87e4..b764bf9 100644 --- a/x/graph/keeper/neudeg.go +++ b/x/graph/keeper/neudeg.go @@ -62,7 +62,7 @@ func (gk *GraphKeeper) UpdateMemNeudegs(ctx sdk.Context) { defer iterator.Close() for ; iterator.Valid(); iterator.Next() { acc := sdk.BigEndianToUint64(iterator.Key()[1:]) - gk.neudeg[acc] = gk.neudeg[acc] + sdk.BigEndianToUint64(iterator.Value()) + gk.neudeg[acc] += sdk.BigEndianToUint64(iterator.Value()) } } diff --git a/x/graph/keeper/particles.go b/x/graph/keeper/particles.go index 580f651..34dec83 100644 --- a/x/graph/keeper/particles.go +++ b/x/graph/keeper/particles.go @@ -124,7 +124,7 @@ func (gk GraphKeeper) WriteCids(ctx sdk.Context, writer io.Writer) (err error) { return } }) - return + return //nolint:nakedret } func (gk GraphKeeper) LoadFromReader(ctx sdk.Context, reader io.Reader) (err error) { diff --git a/x/graph/keeper/querier.go b/x/graph/keeper/querier.go index af595d6..bda6ec7 100644 --- a/x/graph/keeper/querier.go +++ b/x/graph/keeper/querier.go @@ -25,7 +25,7 @@ func queryGraphStats(ctx sdk.Context, _ abci.RequestQuery, gk GraphKeeper, legac links := gk.GetLinksCount(ctx) cids := gk.GetCidsCount(ctx) - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, types.QueryGraphStatsResponse{links, cids}) + res, err := codec.MarshalJSONIndent(legacyQuerierCdc, types.QueryGraphStatsResponse{Cyberlinks: links, Particles: cids}) if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) } diff --git a/x/graph/module.go b/x/graph/module.go index c701ff6..1a53be9 100644 --- a/x/graph/module.go +++ b/x/graph/module.go @@ -4,8 +4,6 @@ import ( "context" "encoding/json" - //"fmt" - "github.com/cosmos/cosmos-sdk/client" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -15,15 +13,11 @@ import ( bandwidthkeeper "github.com/cybercongress/go-cyber/x/bandwidth/keeper" - //"github.com/gogo/protobuf/codec" "github.com/cosmos/cosmos-sdk/codec" - //"github.com/cosmos/cosmos-sdk/types/module" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/gorilla/mux" "github.com/spf13/cobra" - //"github.com/tendermint/tendermint/abci/types" - cyberbankkeeper "github.com/cybercongress/go-cyber/x/cyberbank/keeper" "github.com/cybercongress/go-cyber/x/graph/client/cli" "github.com/cybercongress/go-cyber/x/graph/client/rest" diff --git a/x/graph/types/compact_link.go b/x/graph/types/compact_link.go index d5e9278..d31a7c0 100644 --- a/x/graph/types/compact_link.go +++ b/x/graph/types/compact_link.go @@ -3,7 +3,7 @@ package types import ( "encoding/binary" - . "github.com/cybercongress/go-cyber/types" + "github.com/cybercongress/go-cyber/types" ) type CompactLink struct { @@ -14,7 +14,7 @@ type CompactLink struct { type LinkFilter func(CompactLink) bool -func NewLink(from CidNumber, to CidNumber, acc AccNumber) CompactLink { +func NewLink(from CidNumber, to CidNumber, acc types.AccNumber) CompactLink { return CompactLink{ From: uint64(from), To: uint64(to), @@ -26,7 +26,7 @@ func UnmarshalBinaryLink(b []byte) CompactLink { return NewLink( CidNumber(binary.LittleEndian.Uint64(b[0:8])), CidNumber(binary.LittleEndian.Uint64(b[8:16])), - AccNumber(binary.LittleEndian.Uint64(b[16:24])), + types.AccNumber(binary.LittleEndian.Uint64(b[16:24])), ) } diff --git a/x/graph/types/cyberlinks.go b/x/graph/types/cyberlinks.go index 3d15ad8..683eb47 100644 --- a/x/graph/types/cyberlinks.go +++ b/x/graph/types/cyberlinks.go @@ -1,14 +1,12 @@ package types -import ( - . "github.com/cybercongress/go-cyber/types" -) +import "github.com/cybercongress/go-cyber/types" // map of map, where first key is cid, second key is account.String() // second map is used as set for fast contains check type ( Links map[CidNumber]CidLinks - CidLinks map[CidNumber]map[AccNumber]struct{} + CidLinks map[CidNumber]map[types.AccNumber]struct{} ) type ( @@ -16,14 +14,14 @@ type ( CidNumber uint64 ) -func (links Links) Put(from CidNumber, to CidNumber, acc AccNumber) { +func (links Links) Put(from CidNumber, to CidNumber, acc types.AccNumber) { cidLinks := links[from] if cidLinks == nil { cidLinks = make(CidLinks) } users := cidLinks[to] if users == nil { - users = make(map[AccNumber]struct{}) + users = make(map[types.AccNumber]struct{}) } users[acc] = struct{}{} cidLinks[to] = users @@ -46,7 +44,7 @@ func (links Links) Copy() Links { for from := range links { fromLinks := make(CidLinks, len(links[from])) for to := range links[from] { - users := make(map[AccNumber]struct{}, len(links[from][to])) + users := make(map[types.AccNumber]struct{}, len(links[from][to])) for u := range links[from][to] { users[u] = struct{}{} } @@ -69,7 +67,7 @@ func (links Links) IsAnyLinkExist(from CidNumber, to CidNumber) bool { return false } -func (links Links) IsLinkExist(from CidNumber, to CidNumber, acc AccNumber) bool { +func (links Links) IsLinkExist(from CidNumber, to CidNumber, acc types.AccNumber) bool { toLinks, fromExists := links[from] if fromExists { linkAccs, toExists := toLinks[to] diff --git a/x/graph/wasm/interface.go b/x/graph/wasm/interface.go index e18afd1..bf85f2f 100644 --- a/x/graph/wasm/interface.go +++ b/x/graph/wasm/interface.go @@ -14,24 +14,24 @@ import ( ) var ( - _ WasmQuerierInterface = WasmQuerier{} - _ WasmMsgParserInterface = WasmMsgParser{} + _ QuerierInterface = Querier{} + _ MsgParserInterface = MsgParser{} ) //-------------------------------------------------- -type WasmMsgParserInterface interface { +type MsgParserInterface interface { Parse(contractAddr sdk.AccAddress, msg wasmvmtypes.CosmosMsg) ([]sdk.Msg, error) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessage) ([]sdk.Msg, error) } -type WasmMsgParser struct{} +type MsgParser struct{} -func NewWasmMsgParser() WasmMsgParser { - return WasmMsgParser{} +func NewWasmMsgParser() MsgParser { + return MsgParser{} } -func (WasmMsgParser) Parse(_ sdk.AccAddress, _ wasmvmtypes.CosmosMsg) ([]sdk.Msg, error) { +func (MsgParser) Parse(_ sdk.AccAddress, _ wasmvmtypes.CosmosMsg) ([]sdk.Msg, error) { return nil, nil } @@ -39,7 +39,7 @@ type CosmosMsg struct { Cyberlink *types.MsgCyberlink `json:"cyberlink,omitempty"` } -func (WasmMsgParser) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessage) ([]sdk.Msg, error) { +func (MsgParser) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessage) ([]sdk.Msg, error) { var sdkMsg CosmosMsg err := json.Unmarshal(data, &sdkMsg) if err != nil { @@ -55,20 +55,20 @@ func (WasmMsgParser) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessa //-------------------------------------------------- -type WasmQuerierInterface interface { +type QuerierInterface interface { Query(ctx sdk.Context, request wasmvmtypes.QueryRequest) ([]byte, error) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) } -type WasmQuerier struct { +type Querier struct { keeper.GraphKeeper } -func NewWasmQuerier(keeper keeper.GraphKeeper) WasmQuerier { - return WasmQuerier{keeper} +func NewWasmQuerier(keeper keeper.GraphKeeper) Querier { + return Querier{keeper} } -func (WasmQuerier) Query(_ sdk.Context, _ wasmvmtypes.QueryRequest) ([]byte, error) { return nil, nil } +func (Querier) Query(_ sdk.Context, _ wasmvmtypes.QueryRequest) ([]byte, error) { return nil, nil } type CosmosQuery struct { ParticlesAmount *struct{} `json:"particles_amount,omitempty"` @@ -83,7 +83,7 @@ type CyberlinksAmountQueryResponse struct { CyberlinksAmount uint64 `json:"cyberlinks_amount"` } -func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) { +func (querier Querier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) { var query CosmosQuery err := json.Unmarshal(data, &query) if err != nil { @@ -92,13 +92,14 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ var bz []byte - if query.ParticlesAmount != nil { + switch { + case query.ParticlesAmount != nil: amount := querier.GraphKeeper.GetCidsCount(ctx) bz, err = json.Marshal(ParticlesAmountQueryResponse{ParticlesAmount: amount}) - } else if query.CyberlinksAmount != nil { + case query.CyberlinksAmount != nil: amount := querier.GraphKeeper.GetLinksCount(ctx) bz, err = json.Marshal(CyberlinksAmountQueryResponse{CyberlinksAmount: amount}) - } else { + default: return nil, wasmvmtypes.UnsupportedRequest{Kind: "unknown Graph variant"} } diff --git a/x/grid/client/cli/query.go b/x/grid/client/cli/query.go index ebe5667..cc943ce 100644 --- a/x/grid/client/cli/query.go +++ b/x/grid/client/cli/query.go @@ -1,19 +1,15 @@ package cli import ( - "fmt" - //"strings" "context" - //"github.com/cosmos/cosmos-sdk/client/context" + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" - //"github.com/cosmos/cosmos-sdk/version" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - //"github.com/cosmos/cosmos-sdk/codec" - "github.com/cybercongress/go-cyber/x/grid/types" ) diff --git a/x/grid/client/rest/query.go b/x/grid/client/rest/query.go index 6112bc5..549bb77 100644 --- a/x/grid/client/rest/query.go +++ b/x/grid/client/rest/query.go @@ -199,6 +199,10 @@ func queryRouteHandlerFn(cliCtx client.Context) http.HandlerFunc { vars := mux.Vars(r) src, err := sdk.AccAddressFromBech32(vars[Source]) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } dst, err := sdk.AccAddressFromBech32(vars[Destination]) if err != nil { rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) diff --git a/x/grid/keeper/keeper.go b/x/grid/keeper/keeper.go index daaab6f..6767ce6 100644 --- a/x/grid/keeper/keeper.go +++ b/x/grid/keeper/keeper.go @@ -131,7 +131,8 @@ func (k Keeper) EditEnergyRoute(ctx sdk.Context, src, dst sdk.AccAddress, value ampers := route.Value.AmountOf(ctypes.AMPERE) volts := route.Value.AmountOf(ctypes.VOLT) - newValues := sdk.Coins{} + + var newValues sdk.Coins if value.Denom == ctypes.VOLT { newValues = sdk.NewCoins(value, sdk.NewCoin(ctypes.AMPERE, ampers)) } else { diff --git a/x/grid/types/expected_keepers.go b/x/grid/types/expected_keepers.go index 49fc25d..950255c 100644 --- a/x/grid/types/expected_keepers.go +++ b/x/grid/types/expected_keepers.go @@ -3,11 +3,6 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - //"github.com/cosmos/cosmos-sdk/x/auth/exported" - //"github.com/cosmos/cosmos-sdk/x/params" - //bankexported "github.com/cosmos/cosmos-sdk/x/bank/exported" - //authexported "github.com/cosmos/cosmos-sdk/x/auth/exported" - //"github.com/cybercongress/go-cyber/x/bank/exported" ) type CyberbankKeeper interface { diff --git a/x/grid/wasm/interface.go b/x/grid/wasm/interface.go index 94fb63e..1e45938 100644 --- a/x/grid/wasm/interface.go +++ b/x/grid/wasm/interface.go @@ -14,22 +14,22 @@ import ( "github.com/cybercongress/go-cyber/x/grid/types" ) -var _ WasmMsgParserInterface = WasmMsgParser{} +var _ MsgParserInterface = MsgParser{} //-------------------------------------------------- -type WasmMsgParserInterface interface { +type MsgParserInterface interface { Parse(contractAddr sdk.AccAddress, msg wasmvmtypes.CosmosMsg) ([]sdk.Msg, error) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessage) ([]sdk.Msg, error) } -type WasmMsgParser struct{} +type MsgParser struct{} -func NewWasmMsgParser() WasmMsgParser { - return WasmMsgParser{} +func NewWasmMsgParser() MsgParser { + return MsgParser{} } -func (WasmMsgParser) Parse(_ sdk.AccAddress, _ wasmvmtypes.CosmosMsg) ([]sdk.Msg, error) { +func (MsgParser) Parse(_ sdk.AccAddress, _ wasmvmtypes.CosmosMsg) ([]sdk.Msg, error) { return nil, nil } @@ -40,46 +40,43 @@ type CosmosMsg struct { DeleteEnergyRoute *types.MsgDeleteRoute `json:"delete_energy_route,omitempty"` } -func (WasmMsgParser) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessage) ([]sdk.Msg, error) { +func (MsgParser) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessage) ([]sdk.Msg, error) { var sdkMsg CosmosMsg err := json.Unmarshal(data, &sdkMsg) if err != nil { return nil, sdkerrors.Wrap(err, "failed to parse link custom msg") } - if sdkMsg.CreateEnergyRoute != nil { + switch { + case sdkMsg.CreateEnergyRoute != nil: return []sdk.Msg{sdkMsg.CreateEnergyRoute}, sdkMsg.CreateEnergyRoute.ValidateBasic() - } else if sdkMsg.EditEnergyRoute != nil { + case sdkMsg.EditEnergyRoute != nil: return []sdk.Msg{sdkMsg.EditEnergyRoute}, sdkMsg.EditEnergyRoute.ValidateBasic() - } else if sdkMsg.EditEnergyRouteName != nil { + case sdkMsg.EditEnergyRouteName != nil: return []sdk.Msg{sdkMsg.EditEnergyRouteName}, sdkMsg.EditEnergyRouteName.ValidateBasic() - } else if sdkMsg.EditEnergyRoute != nil { - return []sdk.Msg{sdkMsg.EditEnergyRoute}, sdkMsg.EditEnergyRoute.ValidateBasic() - } else if sdkMsg.EditEnergyRouteName != nil { - return []sdk.Msg{sdkMsg.EditEnergyRouteName}, sdkMsg.EditEnergyRouteName.ValidateBasic() - } else if sdkMsg.DeleteEnergyRoute != nil { + case sdkMsg.DeleteEnergyRoute != nil: return []sdk.Msg{sdkMsg.DeleteEnergyRoute}, sdkMsg.DeleteEnergyRoute.ValidateBasic() + default: + return nil, sdkerrors.Wrap(wasm.ErrInvalidMsg, "Unknown variant of Energy") } - - return nil, sdkerrors.Wrap(wasm.ErrInvalidMsg, "Unknown variant of Energy") } //-------------------------------------------------- -type WasmQuerierInterface interface { +type QuerierInterface interface { Query(ctx sdk.Context, request wasmvmtypes.QueryRequest) ([]byte, error) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) } -type WasmQuerier struct { +type Querier struct { keeper.Keeper } -func NewWasmQuerier(keeper keeper.Keeper) WasmQuerier { - return WasmQuerier{keeper} +func NewWasmQuerier(keeper keeper.Keeper) Querier { + return Querier{keeper} } -func (WasmQuerier) Query(_ sdk.Context, _ wasmvmtypes.QueryRequest) ([]byte, error) { return nil, nil } +func (Querier) Query(_ sdk.Context, _ wasmvmtypes.QueryRequest) ([]byte, error) { return nil, nil } type CosmosQuery struct { SourceRoutes *QuerySourceParams `json:"source_routes,omitempty"` @@ -122,7 +119,7 @@ type RouteResponse struct { Route Route `json:"route"` } -func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) { +func (querier Querier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) { var query CosmosQuery err := json.Unmarshal(data, &query) if err != nil { @@ -131,41 +128,43 @@ func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([ var bz []byte - if query.SourceRoutes != nil { + switch { + case query.SourceRoutes != nil: source, _ := sdk.AccAddressFromBech32(query.SourceRoutes.Source) routes := querier.Keeper.GetSourceRoutes(ctx, source, 16) bz, err = json.Marshal(RoutesResponse{ Routes: convertCyberRoutesToWasmRoutes(routes), }) - } else if query.SourceRoutedEnergy != nil { + case query.SourceRoutedEnergy != nil: source, _ := sdk.AccAddressFromBech32(query.SourceRoutedEnergy.Source) value := querier.Keeper.GetRoutedFromEnergy(ctx, source) bz, err = json.Marshal(RoutedEnergyResponse{ Value: wasmplugins.ConvertSdkCoinsToWasmCoins(value), }) - } else if query.DestinationRoutedEnergy != nil { + case query.DestinationRoutedEnergy != nil: destination, _ := sdk.AccAddressFromBech32(query.DestinationRoutedEnergy.Destination) value := querier.Keeper.GetRoutedToEnergy(ctx, destination) bz, err = json.Marshal(RoutedEnergyResponse{ Value: wasmplugins.ConvertSdkCoinsToWasmCoins(value), }) - } else if query.Route != nil { + case query.Route != nil: source, _ := sdk.AccAddressFromBech32(query.Route.Source) destination, _ := sdk.AccAddressFromBech32(query.Route.Destination) route, found := querier.Keeper.GetRoute(ctx, source, destination) - if found != true { + if !found { return nil, sdkerrors.ErrInvalidRequest } bz, err = json.Marshal(RouteResponse{ Route: convertCyberRouteToWasmRoute(route), }) - } else { - return nil, sdkerrors.ErrInvalidRequest + default: + return nil, wasmvmtypes.UnsupportedRequest{Kind: "unknown Liquidity variant"} } + if err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) } diff --git a/x/rank/client/cli/query.go b/x/rank/client/cli/query.go index 3757b64..d6edbca 100644 --- a/x/rank/client/cli/query.go +++ b/x/rank/client/cli/query.go @@ -276,7 +276,7 @@ func GetCmdQueryIsLinkExist() *cobra.Command { res, err := queryClient.IsLinkExist( context.Background(), - &types.QueryIsLinkExistRequest{args[0], args[1], address.String()}, + &types.QueryIsLinkExistRequest{From: args[0], To: args[1], Address: address.String()}, ) if err != nil { return err @@ -313,7 +313,7 @@ func GetCmdQueryIsAnyLinkExist() *cobra.Command { res, err := queryClient.IsAnyLinkExist( context.Background(), - &types.QueryIsAnyLinkExistRequest{args[0], args[1]}, + &types.QueryIsAnyLinkExistRequest{From: args[0], To: args[1]}, ) if err != nil { return err diff --git a/x/rank/client/rest/query.go b/x/rank/client/rest/query.go index b59b41a..7606d07 100644 --- a/x/rank/client/rest/query.go +++ b/x/rank/client/rest/query.go @@ -10,7 +10,6 @@ import ( "github.com/gorilla/mux" "github.com/ipfs/go-cid" - //"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/types/rest" "github.com/cybercongress/go-cyber/x/rank/types" diff --git a/x/rank/keeper/calculate_cpu.go b/x/rank/keeper/calculate_cpu.go index a0b7bde..49567bf 100755 --- a/x/rank/keeper/calculate_cpu.go +++ b/x/rank/keeper/calculate_cpu.go @@ -1,10 +1,8 @@ package keeper import ( - //"fmt" - //"encoding/binary" "math" - //"math/big" + graphtypes "github.com/cybercongress/go-cyber/x/graph/types" "github.com/cybercongress/go-cyber/x/rank/types" ) @@ -17,9 +15,9 @@ func calculateRankCPU(ctx *types.CalculationContext) types.EMState { size := ctx.GetCidsCount() if size == 0 || len(ctx.GetStakes()) == 0 { return types.EMState{ - []float64{}, - []float64{}, - []float64{}, + RankValues: []float64{}, + EntropyValues: []float64{}, + KarmaValues: []float64{}, } } @@ -37,7 +35,7 @@ func calculateRankCPU(ctx *types.CalculationContext) types.EMState { } innerProductOverSize := defaultRank * (float64(danglingNodesSize) / float64(size)) - defaultRankWithCorrection := float64(dampingFactor*innerProductOverSize) + defaultRank + defaultRankWithCorrection := dampingFactor*innerProductOverSize + defaultRank change := tolerance + 1 @@ -56,9 +54,9 @@ func calculateRankCPU(ctx *types.CalculationContext) types.EMState { karmaCalc(ctx, rank, entropy, karma) return types.EMState{ - rank, - entropy, - karma, + RankValues: rank, + EntropyValues: entropy, + KarmaValues: karma, } } @@ -192,7 +190,7 @@ func karmaCalc(ctx *types.CalculationContext, rank []float64, entropy []float64, w = float64(0) } luminosity := rank[from] * entropy[from] - karma[user] += w * float64(luminosity) + karma[user] += w * luminosity } } } diff --git a/x/rank/keeper/grpc_query.go b/x/rank/keeper/grpc_query.go index 0ae966c..c054296 100644 --- a/x/rank/keeper/grpc_query.go +++ b/x/rank/keeper/grpc_query.go @@ -15,34 +15,34 @@ import ( var _ types.QueryServer = &StateKeeper{} -func (bk StateKeeper) Params(goCtx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { +func (sk StateKeeper) Params(goCtx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - params := bk.GetParams(ctx) + params := sk.GetParams(ctx) return &types.QueryParamsResponse{Params: params}, nil } -func (bk StateKeeper) Rank(goCtx context.Context, req *types.QueryRankRequest) (*types.QueryRankResponse, error) { +func (sk StateKeeper) Rank(goCtx context.Context, req *types.QueryRankRequest) (*types.QueryRankResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - cidNum, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.Particle)) - if exist != true { + cidNum, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.Particle)) + if !exist { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, req.Particle) } - rankValue := bk.index.GetRankValue(cidNum) + rankValue := sk.index.GetRankValue(cidNum) return &types.QueryRankResponse{Rank: rankValue}, nil } -func (bk *StateKeeper) Search(goCtx context.Context, req *types.QuerySearchRequest) (*types.QuerySearchResponse, error) { +func (sk *StateKeeper) Search(goCtx context.Context, req *types.QuerySearchRequest) (*types.QuerySearchResponse, error) { if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") } ctx := sdk.UnwrapSDKContext(goCtx) - cidNum, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.Particle)) - if exist != true { + cidNum, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.Particle)) + if !exist { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, "") } @@ -50,28 +50,28 @@ func (bk *StateKeeper) Search(goCtx context.Context, req *types.QuerySearchReque if req.Pagination != nil { page, limit = req.Pagination.Page, req.Pagination.PerPage } - rankedCidNumbers, totalSize, err := bk.index.Search(cidNum, page, limit) + rankedCidNumbers, totalSize, err := sk.index.Search(cidNum, page, limit) if err != nil { panic(err) } result := make([]types.RankedParticle, 0, len(rankedCidNumbers)) for _, c := range rankedCidNumbers { - result = append(result, types.RankedParticle{Particle: string(bk.graphKeeper.GetCid(ctx, c.GetNumber())), Rank: c.GetRank()}) + result = append(result, types.RankedParticle{Particle: string(sk.graphKeeper.GetCid(ctx, c.GetNumber())), Rank: c.GetRank()}) } return &types.QuerySearchResponse{Result: result, Pagination: &querytypes.PageResponse{Total: totalSize}}, nil } -func (bk *StateKeeper) Backlinks(goCtx context.Context, req *types.QuerySearchRequest) (*types.QuerySearchResponse, error) { +func (sk *StateKeeper) Backlinks(goCtx context.Context, req *types.QuerySearchRequest) (*types.QuerySearchResponse, error) { if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") } ctx := sdk.UnwrapSDKContext(goCtx) - cidNum, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.Particle)) - if exist != true { + cidNum, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.Particle)) + if !exist { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, req.Particle) } @@ -79,43 +79,44 @@ func (bk *StateKeeper) Backlinks(goCtx context.Context, req *types.QuerySearchRe if req.Pagination != nil { page, limit = req.Pagination.Page, req.Pagination.PerPage } - rankedCidNumbers, totalSize, err := bk.index.Backlinks(cidNum, page, limit) + rankedCidNumbers, totalSize, err := sk.index.Backlinks(cidNum, page, limit) if err != nil { panic(err) } result := make([]types.RankedParticle, 0, len(rankedCidNumbers)) for _, c := range rankedCidNumbers { - result = append(result, types.RankedParticle{Particle: string(bk.graphKeeper.GetCid(ctx, c.GetNumber())), Rank: c.GetRank()}) + result = append(result, types.RankedParticle{Particle: string(sk.graphKeeper.GetCid(ctx, c.GetNumber())), Rank: c.GetRank()}) } return &types.QuerySearchResponse{Result: result, Pagination: &querytypes.PageResponse{Total: totalSize}}, nil } -func (bk *StateKeeper) Top(goCtx context.Context, req *querytypes.PageRequest) (*types.QuerySearchResponse, error) { +func (sk *StateKeeper) Top(goCtx context.Context, req *querytypes.PageRequest) (*types.QuerySearchResponse, error) { if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") } ctx := sdk.UnwrapSDKContext(goCtx) - // TODO check pagination - page, limit := uint32(0), uint32(100) - page, limit = req.Page, req.PerPage - topRankedCidNumbers, totalSize, err := bk.index.Top(page, limit) + if req.PerPage > uint32(1000) { + return nil, sdkerrors.ErrInvalidRequest + } + page, limit := req.Page, req.PerPage + topRankedCidNumbers, totalSize, err := sk.index.Top(page, limit) if err != nil { panic(err) } result := make([]types.RankedParticle, 0, len(topRankedCidNumbers)) for _, c := range topRankedCidNumbers { - result = append(result, types.RankedParticle{Particle: string(bk.graphKeeper.GetCid(ctx, c.GetNumber())), Rank: c.GetRank()}) + result = append(result, types.RankedParticle{Particle: string(sk.graphKeeper.GetCid(ctx, c.GetNumber())), Rank: c.GetRank()}) } return &types.QuerySearchResponse{Result: result, Pagination: &querytypes.PageResponse{Total: totalSize}}, nil } -func (bk StateKeeper) IsLinkExist(goCtx context.Context, req *types.QueryIsLinkExistRequest) (*types.QueryLinkExistResponse, error) { +func (sk StateKeeper) IsLinkExist(goCtx context.Context, req *types.QueryIsLinkExistRequest) (*types.QueryLinkExistResponse, error) { if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") } @@ -127,77 +128,77 @@ func (bk StateKeeper) IsLinkExist(goCtx context.Context, req *types.QueryIsLinkE ctx := sdk.UnwrapSDKContext(goCtx) - cidNumFrom, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.From)) - if exist != true { + cidNumFrom, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.From)) + if !exist { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, req.From) } - cidNumTo, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.To)) - if exist != true { + cidNumTo, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.To)) + if !exist { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, req.To) } var accountNum uint64 - account := bk.accountKeeper.GetAccount(ctx, addr) + account := sk.accountKeeper.GetAccount(ctx, addr) if account != nil { accountNum = account.GetAccountNumber() } else { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "Invalid neuron address") } - exists := bk.graphIndexedKeeper.IsLinkExist(graphtypes.CompactLink{ - uint64(cidNumFrom), - uint64(cidNumTo), - accountNum, + exists := sk.graphIndexedKeeper.IsLinkExist(graphtypes.CompactLink{ + From: uint64(cidNumFrom), + To: uint64(cidNumTo), + Account: accountNum, }) return &types.QueryLinkExistResponse{Exist: exists}, nil } -func (bk StateKeeper) IsAnyLinkExist(goCtx context.Context, req *types.QueryIsAnyLinkExistRequest) (*types.QueryLinkExistResponse, error) { +func (sk StateKeeper) IsAnyLinkExist(goCtx context.Context, req *types.QueryIsAnyLinkExistRequest) (*types.QueryLinkExistResponse, error) { if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") } ctx := sdk.UnwrapSDKContext(goCtx) - cidNumFrom, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.From)) - if exist != true { + cidNumFrom, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.From)) + if !exist { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, req.From) } - cidNumTo, exist := bk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.To)) - if exist != true { + cidNumTo, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(req.To)) + if !exist { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, req.To) } - exists := bk.graphIndexedKeeper.IsAnyLinkExist(cidNumFrom, cidNumTo) + exists := sk.graphIndexedKeeper.IsAnyLinkExist(cidNumFrom, cidNumTo) return &types.QueryLinkExistResponse{Exist: exists}, nil } -func (s *StateKeeper) ParticleNegentropy(goCtx context.Context, request *types.QueryNegentropyPartilceRequest) (*types.QueryNegentropyParticleResponse, error) { +func (sk *StateKeeper) ParticleNegentropy(goCtx context.Context, request *types.QueryNegentropyPartilceRequest) (*types.QueryNegentropyParticleResponse, error) { if request == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") } ctx := sdk.UnwrapSDKContext(goCtx) - cidNum, exist := s.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(request.Particle)) - if exist != true { + cidNum, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(request.Particle)) + if !exist { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, request.Particle) } - entropyValue := s.GetEntropy(cidNum) + entropyValue := sk.GetEntropy(cidNum) return &types.QueryNegentropyParticleResponse{Entropy: entropyValue}, nil } -func (s *StateKeeper) Negentropy(_ context.Context, _ *types.QueryNegentropyRequest) (*types.QueryNegentropyResponse, error) { - negentropy := s.GetNegEntropy() +func (sk *StateKeeper) Negentropy(_ context.Context, _ *types.QueryNegentropyRequest) (*types.QueryNegentropyResponse, error) { + negentropy := sk.GetNegEntropy() return &types.QueryNegentropyResponse{Negentropy: negentropy}, nil } -func (s *StateKeeper) Karma(goCtx context.Context, request *types.QueryKarmaRequest) (*types.QueryKarmaResponse, error) { +func (sk *StateKeeper) Karma(goCtx context.Context, request *types.QueryKarmaRequest) (*types.QueryKarmaResponse, error) { if request == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") } @@ -210,14 +211,14 @@ func (s *StateKeeper) Karma(goCtx context.Context, request *types.QueryKarmaRequ ctx := sdk.UnwrapSDKContext(goCtx) var accountNum uint64 - account := s.accountKeeper.GetAccount(ctx, addr) + account := sk.accountKeeper.GetAccount(ctx, addr) if account != nil { accountNum = account.GetAccountNumber() } else { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "Invalid neuron address") } - karma := s.GetKarma(accountNum) + karma := sk.GetKarma(accountNum) return &types.QueryKarmaResponse{Karma: karma}, nil } diff --git a/x/rank/keeper/keeper.go b/x/rank/keeper/keeper.go index 517bbe4..b8f05bd 100644 --- a/x/rank/keeper/keeper.go +++ b/x/rank/keeper/keeper.go @@ -78,18 +78,18 @@ func NewKeeper( } } -func (s *StateKeeper) LoadState(ctx sdk.Context) { - s.networkCidRank = types.NewFromMerkle(s.graphKeeper.GetCidsCount(ctx), s.GetLatestMerkleTree(ctx)) - s.nextCidRank = types.NewFromMerkle(s.GetNextRankCidCount(ctx), s.GetNextMerkleTree(ctx)) - s.cidCount = int64(s.graphKeeper.GetCidsCount(ctx)) +func (sk *StateKeeper) LoadState(ctx sdk.Context) { + sk.networkCidRank = types.NewFromMerkle(sk.graphKeeper.GetCidsCount(ctx), sk.GetLatestMerkleTree(ctx)) + sk.nextCidRank = types.NewFromMerkle(sk.GetNextRankCidCount(ctx), sk.GetNextMerkleTree(ctx)) + sk.cidCount = int64(sk.graphKeeper.GetCidsCount(ctx)) - s.index = s.BuildSearchIndex(s.Logger(ctx)) - s.index.Load(s.graphIndexedKeeper.GetOutLinks()) - s.getIndexError = s.index.Run() + sk.index = sk.BuildSearchIndex(sk.Logger(ctx)) + sk.index.Load(sk.graphIndexedKeeper.GetOutLinks()) + sk.getIndexError = sk.index.Run() } -func (s *StateKeeper) StartRankCalculation(ctx sdk.Context) { - params := s.GetParams(ctx) +func (sk *StateKeeper) StartRankCalculation(ctx sdk.Context) { + params := sk.GetParams(ctx) dampingFactor, err := strconv.ParseFloat(params.DampingFactor.String(), 64) if err != nil { @@ -101,31 +101,30 @@ func (s *StateKeeper) StartRankCalculation(ctx sdk.Context) { panic(err) } - s.startRankCalculation(ctx, dampingFactor, tolerance) - s.rankCalculationFinished = false + sk.startRankCalculation(ctx, dampingFactor, tolerance) + sk.rankCalculationFinished = false } -func (s *StateKeeper) BuildSearchIndex(logger log.Logger) types.SearchIndex { - if s.allowSearch { +func (sk *StateKeeper) BuildSearchIndex(logger log.Logger) types.SearchIndex { + if sk.allowSearch { return types.NewBaseSearchIndex(logger) - } else { - return types.NoopSearchIndex{} } + return types.NoopSearchIndex{} } -func (s *StateKeeper) EndBlocker(ctx sdk.Context) { - s.StoreLatestBlockNumber(ctx, uint64(ctx.BlockHeight())) - currentCidsCount := s.graphKeeper.GetCidsCount(ctx) +func (sk *StateKeeper) EndBlocker(ctx sdk.Context) { + sk.StoreLatestBlockNumber(ctx, uint64(ctx.BlockHeight())) + currentCidsCount := sk.graphKeeper.GetCidsCount(ctx) - s.index.PutNewLinks(s.graphIndexedKeeper.GetCurrentBlockNewLinks(ctx)) - // TODO MergeContextLinks need to be in graph's end blocker + sk.index.PutNewLinks(sk.graphIndexedKeeper.GetCurrentBlockNewLinks(ctx)) + // TODO MergeContextLinks need to be in graph'sk end blocker // but need to get new links here before nextRankLinks will be updated - s.graphIndexedKeeper.MergeContextLinks(ctx) + sk.graphIndexedKeeper.MergeContextLinks(ctx) - blockHasNewLinks := s.graphIndexedKeeper.HasNewLinks(ctx) - s.hasNewLinksForPeriod = s.hasNewLinksForPeriod || blockHasNewLinks + blockHasNewLinks := sk.graphIndexedKeeper.HasNewLinks(ctx) + sk.hasNewLinksForPeriod = sk.hasNewLinksForPeriod || blockHasNewLinks - params := s.GetParams(ctx) + params := sk.GetParams(ctx) if ctx.BlockHeight()%params.CalculationPeriod == 0 || ctx.BlockHeight() == 1 { @@ -139,149 +138,149 @@ func (s *StateKeeper) EndBlocker(ctx sdk.Context) { panic(err) } - s.checkRankCalcFinished(ctx, true) - s.applyNextRank(ctx) + sk.checkRankCalcFinished(ctx, true) + sk.applyNextRank() - s.cidCount = int64(currentCidsCount) - stakeChanged := s.stakeKeeper.DetectUsersStakeAmpereChange(ctx) + sk.cidCount = int64(currentCidsCount) + stakeChanged := sk.stakeKeeper.DetectUsersStakeAmpereChange(ctx) // start new calculation - if s.hasNewLinksForPeriod || stakeChanged { - s.graphIndexedKeeper.UpdateRankLinks() - s.graphKeeper.UpdateRankNeudegs() - s.rankCalculationFinished = false - s.hasNewLinksForPeriod = false - s.prepareContext(ctx) - s.startRankCalculation(ctx, dampingFactor, tolerance) + if sk.hasNewLinksForPeriod || stakeChanged { + sk.graphIndexedKeeper.UpdateRankLinks() + sk.graphKeeper.UpdateRankNeudegs() + sk.rankCalculationFinished = false + sk.hasNewLinksForPeriod = false + sk.prepareContext(ctx) + sk.startRankCalculation(ctx, dampingFactor, tolerance) } } - s.networkCidRank.AddNewCids(currentCidsCount) - networkMerkleTreeAsBytes := s.getNetworkMerkleTreeAsBytes() - s.Logger(ctx).Info( + sk.networkCidRank.AddNewCids(currentCidsCount) + networkMerkleTreeAsBytes := sk.getNetworkMerkleTreeAsBytes() + sk.Logger(ctx).Info( "Latest Rank", "hash", fmt.Sprintf("%X", networkMerkleTreeAsBytes), ) - s.StoreLatestMerkleTree(ctx, networkMerkleTreeAsBytes) + sk.StoreLatestMerkleTree(ctx, networkMerkleTreeAsBytes) } -func (s *StateKeeper) startRankCalculation(ctx sdk.Context, dampingFactor float64, tolerance float64) { +func (sk *StateKeeper) startRankCalculation(ctx sdk.Context, dampingFactor float64, tolerance float64) { calcCtx := types.NewCalcContext( - s.graphIndexedKeeper, s.graphKeeper, s.stakeKeeper, - s.allowSearch, dampingFactor, tolerance, - s.GetContextCidCount(ctx), - s.GetContextLinkCount(ctx), - s.GetAccountCount(ctx), + sk.graphIndexedKeeper, sk.graphKeeper, sk.stakeKeeper, + sk.allowSearch, dampingFactor, tolerance, + sk.GetContextCidCount(ctx), + sk.GetContextLinkCount(ctx), + sk.GetAccountCount(ctx), ) - go CalculateRankInParallel(calcCtx, s.rankCalcChan, s.rankErrChan, s.computeUnit, s.Logger(ctx)) + go CalculateRankInParallel(calcCtx, sk.rankCalcChan, sk.rankErrChan, sk.computeUnit, sk.Logger(ctx)) } -func (s *StateKeeper) checkRankCalcFinished(ctx sdk.Context, block bool) { - if !s.rankCalculationFinished { +func (sk *StateKeeper) checkRankCalcFinished(ctx sdk.Context, block bool) { + if !sk.rankCalculationFinished { for { select { - case newRank := <-s.rankCalcChan: - s.handleNextRank(ctx, newRank) + case newRank := <-sk.rankCalcChan: + sk.handleNextRank(ctx, newRank) return - case err := <-s.rankErrChan: - s.Logger(ctx).Error("Error during cyber~Rank calculation, call cyber_devs! " + err.Error()) + case err := <-sk.rankErrChan: + sk.Logger(ctx).Error("Error during cyber~Rank calculation, call cyber_devs! " + err.Error()) panic(err.Error()) default: if !block { return } } - s.Logger(ctx).Info("Waiting for cyber~Rank calculation to finish") + sk.Logger(ctx).Info("Waiting for cyber~Rank calculation to finish") time.Sleep(2000 * time.Millisecond) } } } -func (s *StateKeeper) handleNextRank(ctx sdk.Context, newRank types.Rank) { - s.nextCidRank = newRank - nextMerkleTreeAsBytes := s.getNextMerkleTreeAsBytes() - s.Logger(ctx).Info( +func (sk *StateKeeper) handleNextRank(ctx sdk.Context, newRank types.Rank) { + sk.nextCidRank = newRank + nextMerkleTreeAsBytes := sk.getNextMerkleTreeAsBytes() + sk.Logger(ctx).Info( "Next Rank", "hash", fmt.Sprintf("%X", nextMerkleTreeAsBytes), ) - s.StoreNextMerkleTree(ctx, nextMerkleTreeAsBytes) - s.StoreNextRankCidCount(ctx, newRank.CidCount) - s.rankCalculationFinished = true + sk.StoreNextMerkleTree(ctx, nextMerkleTreeAsBytes) + sk.StoreNextRankCidCount(ctx, newRank.CidCount) + sk.rankCalculationFinished = true } -func (s *StateKeeper) applyNextRank(ctx sdk.Context) { - if !s.nextCidRank.IsEmpty() { - s.networkCidRank = s.nextCidRank - s.index.PutNewRank(s.networkCidRank) +func (sk *StateKeeper) applyNextRank() { + if !sk.nextCidRank.IsEmpty() { + sk.networkCidRank = sk.nextCidRank + sk.index.PutNewRank(sk.networkCidRank) } - s.nextCidRank.Clear() + sk.nextCidRank.Clear() } -func (s *StateKeeper) GetRankValueByNumber(number uint64) uint64 { - if number >= uint64(len(s.networkCidRank.RankValues)) { +func (sk *StateKeeper) GetRankValueByNumber(number uint64) uint64 { + if number >= uint64(len(sk.networkCidRank.RankValues)) { return 0 } - return s.networkCidRank.RankValues[number] + return sk.networkCidRank.RankValues[number] } -func (s *StateKeeper) GetRankValueByParticle(ctx sdk.Context, particle string) (uint64, error) { - number, exist := s.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(particle)) - if exist != true { +func (sk *StateKeeper) GetRankValueByParticle(ctx sdk.Context, particle string) (uint64, error) { + number, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(particle)) + if !exist { return 0, sdkerrors.ErrInvalidRequest } - return s.networkCidRank.RankValues[number], nil + return sk.networkCidRank.RankValues[number], nil } -func (s *StateKeeper) GetNextNetworkRankHash() []byte { - return s.nextCidRank.MerkleTree.RootHash() +func (sk *StateKeeper) GetNextNetworkRankHash() []byte { + return sk.nextCidRank.MerkleTree.RootHash() } -func (s *StateKeeper) GetNetworkRankHash() []byte { - return s.networkCidRank.MerkleTree.RootHash() +func (sk *StateKeeper) GetNetworkRankHash() []byte { + return sk.networkCidRank.MerkleTree.RootHash() } -func (s *StateKeeper) getNetworkMerkleTreeAsBytes() []byte { - return s.networkCidRank.MerkleTree.ExportSubtreesRoots() +func (sk *StateKeeper) getNetworkMerkleTreeAsBytes() []byte { + return sk.networkCidRank.MerkleTree.ExportSubtreesRoots() } -func (s *StateKeeper) getNextMerkleTreeAsBytes() []byte { - return s.nextCidRank.MerkleTree.ExportSubtreesRoots() +func (sk *StateKeeper) getNextMerkleTreeAsBytes() []byte { + return sk.nextCidRank.MerkleTree.ExportSubtreesRoots() } -func (s *StateKeeper) GetLastCidNum() graphtypes.CidNumber { - return graphtypes.CidNumber(len(s.networkCidRank.RankValues) - 1) +func (sk *StateKeeper) GetLastCidNum() graphtypes.CidNumber { + return graphtypes.CidNumber(len(sk.networkCidRank.RankValues) - 1) } -func (s *StateKeeper) GetMerkleTree() *merkle.Tree { - return s.networkCidRank.MerkleTree +func (sk *StateKeeper) GetMerkleTree() *merkle.Tree { + return sk.networkCidRank.MerkleTree } -func (s *StateKeeper) GetKarma(accountNumber uint64) (karma uint64) { - return s.networkCidRank.KarmaValues[accountNumber] +func (sk *StateKeeper) GetKarma(accountNumber uint64) (karma uint64) { + return sk.networkCidRank.KarmaValues[accountNumber] } -func (s *StateKeeper) GetEntropy(cidNum graphtypes.CidNumber) uint64 { - return s.networkCidRank.EntropyValues[cidNum] +func (sk *StateKeeper) GetEntropy(cidNum graphtypes.CidNumber) uint64 { + return sk.networkCidRank.EntropyValues[cidNum] } -func (s *StateKeeper) GetNegEntropy() uint64 { - return s.networkCidRank.NegEntropy +func (sk *StateKeeper) GetNegEntropy() uint64 { + return sk.networkCidRank.NegEntropy } -func (s *StateKeeper) GetIndexError() error { - return s.getIndexError() +func (sk *StateKeeper) GetIndexError() error { + return sk.getIndexError() } -func (s *StateKeeper) GetParams(ctx sdk.Context) (params types.Params) { - s.paramSpace.GetParamSet(ctx, ¶ms) +func (sk *StateKeeper) GetParams(ctx sdk.Context) (params types.Params) { + sk.paramSpace.GetParamSet(ctx, ¶ms) return params } -func (s *StateKeeper) SetParams(ctx sdk.Context, params types.Params) { - s.paramSpace.SetParamSet(ctx, ¶ms) +func (sk *StateKeeper) SetParams(ctx sdk.Context, params types.Params) { + sk.paramSpace.SetParamSet(ctx, ¶ms) } -func (k *StateKeeper) Logger(ctx sdk.Context) log.Logger { +func (sk *StateKeeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+types.ModuleName) } @@ -308,7 +307,7 @@ func (sk StateKeeper) GetLatestMerkleTree(ctx sdk.Context) []byte { func (sk StateKeeper) StoreLatestMerkleTree(ctx sdk.Context, treeAsBytes []byte) { store := ctx.KVStore(sk.storeKey) - if bytes.Compare(sk.GetLatestMerkleTree(ctx), treeAsBytes) != 0 { + if bytes.Compare(sk.GetLatestMerkleTree(ctx), treeAsBytes) != 0 { //nolint:gosimple store.Set(types.LatestMerkleTree, treeAsBytes) } } @@ -320,7 +319,7 @@ func (sk StateKeeper) GetNextMerkleTree(ctx sdk.Context) []byte { func (sk StateKeeper) StoreNextMerkleTree(ctx sdk.Context, treeAsBytes []byte) { store := ctx.KVStore(sk.storeKey) - if bytes.Compare(sk.GetNextMerkleTree(ctx), treeAsBytes) != 0 { + if bytes.Compare(sk.GetNextMerkleTree(ctx), treeAsBytes) != 0 { //nolint:gosimple store.Set(types.NextMerkleTree, treeAsBytes) } } @@ -379,11 +378,11 @@ func (sk StateKeeper) StoreContextLinkCount(ctx sdk.Context, number uint64) { } } -func (s *StateKeeper) prepareContext(ctx sdk.Context) { - s.StoreContextCidCount(ctx, s.graphKeeper.GetCidsCount(ctx)) - s.StoreContextLinkCount(ctx, s.graphIndexedKeeper.GetLinksCount(ctx)) +func (sk *StateKeeper) prepareContext(ctx sdk.Context) { + sk.StoreContextCidCount(ctx, sk.graphKeeper.GetCidsCount(ctx)) + sk.StoreContextLinkCount(ctx, sk.graphIndexedKeeper.GetLinksCount(ctx)) } -func (s *StateKeeper) GetAccountCount(ctx sdk.Context) uint64 { - return s.stakeKeeper.GetNextAccountNumber(ctx) +func (sk *StateKeeper) GetAccountCount(ctx sdk.Context) uint64 { + return sk.stakeKeeper.GetNextAccountNumber(ctx) } diff --git a/x/rank/keeper/querier.go b/x/rank/keeper/querier.go index 73a0337..7d27f7a 100644 --- a/x/rank/keeper/querier.go +++ b/x/rank/keeper/querier.go @@ -61,7 +61,7 @@ func queryRank(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacyQu } cidNum, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.Cid)) - if exist != true { + if !exist { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, params.Cid) } @@ -84,7 +84,7 @@ func querySearch(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legacy } cidNum, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.Cid)) - if exist != true { + if !exist { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, "") } @@ -115,7 +115,7 @@ func queryBacklinks(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, leg } cidNum, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.Cid)) - if exist != true { + if !exist { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, params.Cid) } @@ -172,12 +172,12 @@ func queryIsLinkExist(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, l } cidNumFrom, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.From)) - if exist != true { + if !exist { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, params.From) } cidNumTo, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.To)) - if exist != true { + if !exist { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, params.To) } @@ -190,9 +190,9 @@ func queryIsLinkExist(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, l } exists := sk.graphIndexedKeeper.IsLinkExist(graphtypes.CompactLink{ - uint64(cidNumFrom), - uint64(cidNumTo), - accountNum, + From: uint64(cidNumFrom), + To: uint64(cidNumTo), + Account: accountNum, }) res, err := codec.MarshalJSONIndent(legacyQuerierCdc, &types.QueryLinkExistResponse{Exist: exists}) @@ -212,12 +212,12 @@ func queryIsAnyLinkExist(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper } cidNumFrom, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.From)) - if exist != true { + if !exist { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, params.From) } cidNumTo, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.To)) - if exist != true { + if !exist { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, params.To) } @@ -240,7 +240,7 @@ func queryEntropy(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legac } cidNum, exist := sk.graphKeeper.GetCidNumber(ctx, graphtypes.Cid(params.Cid)) - if exist != true { + if !exist { return nil, sdkerrors.Wrap(graphtypes.ErrCidNotFound, params.Cid) } @@ -254,7 +254,7 @@ func queryEntropy(ctx sdk.Context, req abci.RequestQuery, sk *StateKeeper, legac return res, nil } -func queryNegentropy(ctx sdk.Context, _ abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { +func queryNegentropy(_ sdk.Context, _ abci.RequestQuery, sk *StateKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { negentropy := sk.GetNegEntropy() res, err := codec.MarshalJSONIndent(legacyQuerierCdc, &types.QueryNegentropyResponse{Negentropy: negentropy}) diff --git a/x/rank/module.go b/x/rank/module.go index 5ec8491..4bf02a5 100644 --- a/x/rank/module.go +++ b/x/rank/module.go @@ -9,7 +9,6 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/grpc-ecosystem/grpc-gateway/runtime" - //"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" diff --git a/x/rank/types/context.go b/x/rank/types/context.go index ca03759..e2d2488 100644 --- a/x/rank/types/context.go +++ b/x/rank/types/context.go @@ -46,40 +46,40 @@ func NewCalcContext( } } -func (c *CalculationContext) GetInLinks() map[graphtypes.CidNumber]graphtypes.CidLinks { - return c.inLinks +func (calctx *CalculationContext) GetInLinks() map[graphtypes.CidNumber]graphtypes.CidLinks { + return calctx.inLinks } -func (c *CalculationContext) GetOutLinks() map[graphtypes.CidNumber]graphtypes.CidLinks { - return c.outLinks +func (calctx *CalculationContext) GetOutLinks() map[graphtypes.CidNumber]graphtypes.CidLinks { + return calctx.outLinks } -func (c *CalculationContext) GetCidsCount() int64 { - return c.CidsCount +func (calctx *CalculationContext) GetCidsCount() int64 { + return calctx.CidsCount } -func (c *CalculationContext) GetNeuronsCount() int64 { - return c.NeuronsCount +func (calctx *CalculationContext) GetNeuronsCount() int64 { + return calctx.NeuronsCount } -func (c *CalculationContext) GetStakes() map[uint64]uint64 { - return c.stakes +func (calctx *CalculationContext) GetStakes() map[uint64]uint64 { + return calctx.stakes } -func (c *CalculationContext) GetNeudegs() map[uint64]uint64 { - return c.neudegs +func (calctx *CalculationContext) GetNeudegs() map[uint64]uint64 { + return calctx.neudegs } -func (c *CalculationContext) GetTolerance() float64 { - return c.Tolerance +func (calctx *CalculationContext) GetTolerance() float64 { + return calctx.Tolerance } -func (c *CalculationContext) GetDampingFactor() float64 { - return c.DampingFactor +func (calctx *CalculationContext) GetDampingFactor() float64 { + return calctx.DampingFactor } -func (с *CalculationContext) GetSortedInLinks(cid graphtypes.CidNumber) (graphtypes.CidLinks, []graphtypes.CidNumber, bool) { - links := с.inLinks[cid] +func (calctx *CalculationContext) GetSortedInLinks(cid graphtypes.CidNumber) (graphtypes.CidLinks, []graphtypes.CidNumber, bool) { + links := calctx.inLinks[cid] if len(links) == 0 { return nil, nil, false @@ -95,8 +95,8 @@ func (с *CalculationContext) GetSortedInLinks(cid graphtypes.CidNumber) (grapht return links, numbers, true } -func (с *CalculationContext) GetSortedOutLinks(cid graphtypes.CidNumber) (graphtypes.CidLinks, []graphtypes.CidNumber, bool) { - links := с.outLinks[cid] +func (calctx *CalculationContext) GetSortedOutLinks(cid graphtypes.CidNumber) (graphtypes.CidLinks, []graphtypes.CidNumber, bool) { + links := calctx.outLinks[cid] if len(links) == 0 { return nil, nil, false diff --git a/x/rank/types/index.go b/x/rank/types/index.go index 7081ddb..930ec3a 100644 --- a/x/rank/types/index.go +++ b/x/rank/types/index.go @@ -5,16 +5,14 @@ import ( "sort" "time" - //"time" - "github.com/tendermint/tendermint/libs/log" graphtypes "github.com/cybercongress/go-cyber/x/graph/types" ) type BaseSearchIndex struct { - links []cidLinks - backlinks []cidLinks + links []CidLinks + backlinks []CidLinks rank Rank linksChan chan graphtypes.CompactLink @@ -48,8 +46,8 @@ func (i *BaseSearchIndex) Load(links graphtypes.Links) { startTime := time.Now() i.lock() // lock index for read - i.links = make([]cidLinks, 0, 1000000) - i.backlinks = make([]cidLinks, 0, 1000000) + i.links = make([]CidLinks, 0, 1000000) + i.backlinks = make([]CidLinks, 0, 1000000) for from, toCids := range links { i.extendIndex(uint64(from)) @@ -111,7 +109,7 @@ func (i *BaseSearchIndex) Backlinks(cidNumber graphtypes.CidNumber, page, perPag i.logger.Info("Backlinks query", "cid", cidNumber, "page", page, "perPage", perPage) if i.locked { - return nil, 0, errors.New("The search index is currently unavailable after node restart") + return nil, 0, errors.New("the search index is currently unavailable after node restart") } if uint64(cidNumber) >= uint64(len(i.backlinks)) { @@ -141,7 +139,7 @@ func (i *BaseSearchIndex) Backlinks(cidNumber graphtypes.CidNumber, page, perPag func (i *BaseSearchIndex) Top(page, perPage uint32) ([]RankedCidNumber, uint32, error) { if i.locked { - return nil, 0, errors.New("The search index is currently unavailable after node restart") + return nil, 0, errors.New("the search index is currently unavailable after node restart") } totalSize := uint32(len(i.rank.TopCIDs)) @@ -162,12 +160,12 @@ func (i *BaseSearchIndex) Top(page, perPage uint32) ([]RankedCidNumber, uint32, // make sure that this link (from-to) is new func (i *BaseSearchIndex) handleLink(link graphtypes.CompactLink) { - i.extendIndex(uint64(link.From)) + i.extendIndex(link.From) fromIndex := i.links[link.From] // in case unlock signal received we could operate on this index otherwise put link in the end of queue and finish select { - case _ = <-fromIndex.unlockSignal: + case <-fromIndex.unlockSignal: i.putLinkIntoIndex(graphtypes.CidNumber(link.From), graphtypes.CidNumber(link.To)) fromIndex.Unlock() break @@ -177,12 +175,12 @@ func (i *BaseSearchIndex) handleLink(link graphtypes.CompactLink) { } func (i *BaseSearchIndex) handleBacklink(link graphtypes.CompactLink) { - i.extendReverseIndex(uint64(link.To)) + i.extendReverseIndex(link.To) toIndex := i.backlinks[link.To] // in case unlock signal received we could operate on this index otherwise put link in the end of queue and finish select { - case _ = <-toIndex.unlockSignal: + case <-toIndex.unlockSignal: i.putBacklinkIntoIndex(graphtypes.CidNumber(link.From), graphtypes.CidNumber(link.To)) toIndex.Unlock() break diff --git a/x/rank/types/index_types.go b/x/rank/types/index_types.go index 4f28e59..d878254 100644 --- a/x/rank/types/index_types.go +++ b/x/rank/types/index_types.go @@ -15,14 +15,14 @@ func (c RankedCidNumber) GetNumber() graphtypes.CidNumber { return c.number } func (c RankedCidNumber) GetRank() uint64 { return c.rank } // Local type for sorting -type cidLinks struct { +type CidLinks struct { sortedLinks sortableCidNumbers unlockSignal chan struct{} } -func NewCidLinks() cidLinks { - return cidLinks{ +func NewCidLinks() CidLinks { + return CidLinks{ sortedLinks: make(sortableCidNumbers, 0), unlockSignal: make(chan struct{}, 1), } @@ -38,7 +38,7 @@ func (links sortableCidNumbers) Less(i, j int) bool { return links[i].rank < lin func (links sortableCidNumbers) Swap(i, j int) { links[i], links[j] = links[j], links[i] } // Send unlock signal so others could operate on this index -func (links cidLinks) Unlock() { +func (links CidLinks) Unlock() { links.unlockSignal <- struct{}{} } @@ -65,15 +65,15 @@ func (i NoopSearchIndex) Run() GetError { func (i NoopSearchIndex) Load(links graphtypes.Links) {} func (i NoopSearchIndex) Search(cidNumber graphtypes.CidNumber, page, perPage uint32) ([]RankedCidNumber, uint32, error) { - return nil, 0, errors.New("The search API is not enabled on this node") + return nil, 0, errors.New("the search API is not enabled on this node") } func (i NoopSearchIndex) Backlinks(cidNumber graphtypes.CidNumber, page, perPage uint32) ([]RankedCidNumber, uint32, error) { - return nil, 0, errors.New("The search API is not enabled on this node") + return nil, 0, errors.New("the search API is not enabled on this node") } func (i NoopSearchIndex) Top(page, perPage uint32) ([]RankedCidNumber, uint32, error) { - return nil, 0, errors.New("The search API is not enabled on this node") + return nil, 0, errors.New("the search API is not enabled on this node") } func (i NoopSearchIndex) PutNewLinks(links []graphtypes.CompactLink) {} func (i NoopSearchIndex) PutNewRank(rank Rank) {} diff --git a/x/rank/types/rank.go b/x/rank/types/rank.go index 7e16e99..6e24fab 100644 --- a/x/rank/types/rank.go +++ b/x/rank/types/rank.go @@ -3,8 +3,6 @@ package types import ( "crypto/sha256" "encoding/binary" - - //"fmt" "sort" "time" @@ -71,7 +69,7 @@ func NewRank(state EMState, logger log.Logger, fullTree bool) Rank { // NOTE fulltree true if search index enabled start = time.Now() var newSortedCIDs []RankedCidNumber - if fullTree == true { + if fullTree { newSortedCIDs = BuildTop(rankValues, 1000) logger.Info("Build top", "duration", time.Since(start).String()) } @@ -140,12 +138,21 @@ func (r *Rank) CopyWithoutTree() Rank { copiedEntropyValues := make([]uint64, r.CidCount) n = copy(copiedEntropyValues, r.EntropyValues) + if n != len(r.EntropyValues) { + panic("Not all entropy values have been copied") + } copiedKarmaValues := make([]uint64, len(r.KarmaValues)) n = copy(copiedKarmaValues, r.KarmaValues) + if n != len(r.KarmaValues) { + panic("Not all karma values have been copied") + } copiedTopCIDs := make([]RankedCidNumber, len(r.TopCIDs)) n = copy(copiedTopCIDs, r.TopCIDs) + if n != len(r.TopCIDs) { + panic("Not all sorted particles have been copied") + } return Rank{ RankValues: copiedRankValues, diff --git a/x/rank/wasm/interface.go b/x/rank/wasm/interface.go index ea74f7c..e55774b 100644 --- a/x/rank/wasm/interface.go +++ b/x/rank/wasm/interface.go @@ -15,22 +15,22 @@ import ( "github.com/cybercongress/go-cyber/x/rank/keeper" ) -type WasmQuerierInterface interface { +type QuerierInterface interface { Query(ctx sdk.Context, request wasmvmtypes.QueryRequest) ([]byte, error) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) } -var _ WasmQuerierInterface = WasmQuerier{} +var _ QuerierInterface = Querier{} -type WasmQuerier struct { +type Querier struct { keeper *keeper.StateKeeper } -func NewWasmQuerier(keeper *keeper.StateKeeper) WasmQuerier { - return WasmQuerier{keeper} +func NewWasmQuerier(keeper *keeper.StateKeeper) Querier { + return Querier{keeper} } -func (WasmQuerier) Query(_ sdk.Context, _ wasmvmtypes.QueryRequest) ([]byte, error) { return nil, nil } +func (Querier) Query(_ sdk.Context, _ wasmvmtypes.QueryRequest) ([]byte, error) { return nil, nil } type CosmosQuery struct { ParticleRank *QueryParticleRankParams `json:"particle_rank,omitempty"` @@ -44,7 +44,7 @@ type ParticleRankResponse struct { Rank uint64 `json:"rank"` } -func (querier WasmQuerier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) { +func (querier Querier) QueryCustom(ctx sdk.Context, data json.RawMessage) ([]byte, error) { var query CosmosQuery err := json.Unmarshal(data, &query) if err != nil { diff --git a/x/resources/client/rest/query.go b/x/resources/client/rest/query.go index eb3ef85..b39d692 100644 --- a/x/resources/client/rest/query.go +++ b/x/resources/client/rest/query.go @@ -23,7 +23,7 @@ func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { queryParamsHandlerFn(cliCtx)).Methods("GET") r.HandleFunc( - fmt.Sprintf("/resources/investmint"), + "/resources/investmint", queryInvestmintHandlerFn(cliCtx)).Methods("GET") } diff --git a/x/resources/keeper/keeper.go b/x/resources/keeper/keeper.go index 2f550a5..69c9627 100644 --- a/x/resources/keeper/keeper.go +++ b/x/resources/keeper/keeper.go @@ -70,30 +70,31 @@ func (k Keeper) ConvertResource( amount sdk.Coin, resource string, length uint64, -) (error, sdk.Coin) { - periodAvailableFlag := k.CheckAvailablePeriod(ctx, length, resource) - if periodAvailableFlag == false { - return types.ErrNotAvailablePeriod, sdk.Coin{} +) (sdk.Coin, error) { + periodAvailable := k.CheckAvailablePeriod(ctx, length, resource) + if !periodAvailable { + return sdk.Coin{}, types.ErrNotAvailablePeriod } if k.bankKeeper.SpendableCoins(ctx, neuron).AmountOf(ctypes.SCYB).LT(amount.Amount) { - return sdkerrors.ErrInsufficientFunds, sdk.Coin{} + return sdk.Coin{}, sdkerrors.ErrInsufficientFunds } // comment this for local dev if uint32(length) < k.MinInvestmintPeriodSec(ctx) { - return types.ErrNotAvailablePeriod, sdk.Coin{} + return sdk.Coin{}, types.ErrNotAvailablePeriod } err := k.AddTimeLockedCoinsToAccount(ctx, neuron, sdk.NewCoins(amount), int64(length)) if err != nil { - return sdkerrors.Wrapf(types.ErrTimeLockCoins, err.Error()), sdk.Coin{} + return sdk.Coin{}, sdkerrors.Wrapf(types.ErrTimeLockCoins, err.Error()) } - err, minted := k.Mint(ctx, neuron, amount, resource, length) + minted, err := k.Mint(ctx, neuron, amount, resource, length) if err != nil { - return sdkerrors.Wrapf(types.ErrIssueCoins, err.Error()), sdk.Coin{} + return sdk.Coin{}, sdkerrors.Wrapf(types.ErrIssueCoins, err.Error()) } - return err, minted + + return minted, err } func (k Keeper) AddTimeLockedCoinsToAccount(ctx sdk.Context, recipientAddr sdk.AccAddress, amt sdk.Coins, length int64) error { @@ -185,7 +186,7 @@ func (k Keeper) addCoinsToVestingSchedule(ctx sdk.Context, addr sdk.AccAddress, // case when there are already filled slots and no one already passed if vacc.StartTime+vacc.VestingPeriods[0].Length > ctx.BlockTime().Unix() { return types.ErrFullSlots - } else { + } else { //nolint:revive // TODO refactor next code blocks // case when there are passed slots and we are clean them to free space to new ones activePeriods := vestingtypes.Periods{} @@ -208,7 +209,7 @@ func (k Keeper) addCoinsToVestingSchedule(ctx sdk.Context, addr sdk.AccAddress, } vacc.OriginalVesting = updatedOriginalVesting.Add(amt...) vacc.VestingPeriods = updatedPeriods - vacc.StartTime = vacc.StartTime + shiftStartTime + vacc.StartTime += shiftStartTime } } @@ -253,7 +254,7 @@ func (k Keeper) addCoinsToVestingSchedule(ctx sdk.Context, addr sdk.AccAddress, continue } lengthCounter += period.Length - if lengthCounter < elapsedTime+length { // 1 + if lengthCounter < elapsedTime+length { //nolint:gocritic newPeriods = append(newPeriods, period) } else if lengthCounter == elapsedTime+length { newPeriod := types.NewPeriod(period.Amount.Add(amt...), period.Length) @@ -272,30 +273,30 @@ func (k Keeper) addCoinsToVestingSchedule(ctx sdk.Context, addr sdk.AccAddress, return nil } -func (k Keeper) Mint(ctx sdk.Context, recipientAddr sdk.AccAddress, amt sdk.Coin, resource string, length uint64) (error, sdk.Coin) { +func (k Keeper) Mint(ctx sdk.Context, recipientAddr sdk.AccAddress, amt sdk.Coin, resource string, length uint64) (sdk.Coin, error) { acc := k.accountKeeper.GetAccount(ctx, recipientAddr) if acc == nil { - return sdkerrors.Wrapf(types.ErrAccountNotFound, recipientAddr.String()), sdk.Coin{} + return sdk.Coin{}, sdkerrors.Wrapf(types.ErrAccountNotFound, recipientAddr.String()) } toMint := k.CalculateInvestmint(ctx, amt, resource, length) if toMint.Amount.LT(sdk.NewInt(1000)) { - return sdkerrors.Wrapf(types.ErrSmallReturn, recipientAddr.String()), sdk.Coin{} + return sdk.Coin{}, sdkerrors.Wrapf(types.ErrSmallReturn, recipientAddr.String()) } err := k.bankKeeper.MintCoins(ctx, types.ResourcesName, sdk.NewCoins(toMint)) if err != nil { - return sdkerrors.Wrapf(types.ErrMintCoins, recipientAddr.String()), sdk.Coin{} + return sdk.Coin{}, sdkerrors.Wrapf(types.ErrMintCoins, recipientAddr.String()) } err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ResourcesName, recipientAddr, sdk.NewCoins(toMint)) if err != nil { - return sdkerrors.Wrapf(types.ErrSendMintedCoins, recipientAddr.String()), sdk.Coin{} + return sdk.Coin{}, sdkerrors.Wrapf(types.ErrSendMintedCoins, recipientAddr.String()) } // adding converted resources to vesting schedule err = k.AddTimeLockedCoinsToPeriodicVestingAccount(ctx, recipientAddr, sdk.NewCoins(toMint), int64(length), true) if err != nil { - return sdkerrors.Wrapf(types.ErrTimeLockCoins, err.Error()), sdk.Coin{} + return sdk.Coin{}, sdkerrors.Wrapf(types.ErrTimeLockCoins, err.Error()) } if resource == ctypes.VOLT { @@ -304,7 +305,7 @@ func (k Keeper) Mint(ctx sdk.Context, recipientAddr sdk.AccAddress, amt sdk.Coin k.bandwidthMeter.ChargeAccountBandwidth(ctx, neuronBandwidth, 1000) } - return nil, toMint + return toMint, nil } func (k Keeper) CalculateInvestmint(ctx sdk.Context, amt sdk.Coin, resource string, length uint64) sdk.Coin { diff --git a/x/resources/keeper/msg_server.go b/x/resources/keeper/msg_server.go index fcb5087..7abf9e3 100644 --- a/x/resources/keeper/msg_server.go +++ b/x/resources/keeper/msg_server.go @@ -42,7 +42,7 @@ func (k msgServer) Investmint(goCtx context.Context, msg *types.MsgInvestmint) ( } } - err, minted := k.ConvertResource(ctx, neuron, msg.Amount, msg.Resource, msg.Length) + minted, err := k.ConvertResource(ctx, neuron, msg.Amount, msg.Resource, msg.Length) if err != nil { return nil, err } diff --git a/x/resources/module.go b/x/resources/module.go index 840dbc6..58cec71 100644 --- a/x/resources/module.go +++ b/x/resources/module.go @@ -9,7 +9,6 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/grpc-ecosystem/grpc-gateway/runtime" - //"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" diff --git a/x/resources/types/params.go b/x/resources/types/params.go index 953f309..f52315a 100644 --- a/x/resources/types/params.go +++ b/x/resources/types/params.go @@ -166,7 +166,7 @@ func validateBaseInvestmintAmountVolt(i interface{}) error { } if v.IsLT(ctypes.NewSCybCoin(ctypes.Mega * 10)) { - return fmt.Errorf("base investmint amount for Volt must be more than 10000000: %d", v) + return fmt.Errorf("base investmint amount for Volt must be more than 10000000: %d", v.Amount.Int64()) } return nil @@ -179,7 +179,7 @@ func validateBaseInvestmintAmountAmpere(i interface{}) error { } if v.IsLT(ctypes.NewSCybCoin(ctypes.Mega * 10)) { - return fmt.Errorf("base investmint amount for Ampere must be more than 10000000: %d", v) + return fmt.Errorf("base investmint amount for Ampere must be more than 10000000: %d", v.Amount.Int64()) } return nil diff --git a/x/resources/wasm/interface.go b/x/resources/wasm/interface.go index 8ccf4d7..7089d47 100644 --- a/x/resources/wasm/interface.go +++ b/x/resources/wasm/interface.go @@ -7,25 +7,25 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - wasmTypes "github.com/CosmWasm/wasmvm/types" + wasmvmtypes "github.com/CosmWasm/wasmvm/types" "github.com/cybercongress/go-cyber/x/resources/types" ) -var _ WasmMsgParserInterface = WasmMsgParser{} +var _ MsgParserInterface = MsgParser{} -type WasmMsgParserInterface interface { - Parse(contractAddr sdk.AccAddress, msg wasmTypes.CosmosMsg) ([]sdk.Msg, error) +type MsgParserInterface interface { + Parse(contractAddr sdk.AccAddress, msg wasmvmtypes.CosmosMsg) ([]sdk.Msg, error) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessage) ([]sdk.Msg, error) } -type WasmMsgParser struct{} +type MsgParser struct{} -func NewWasmMsgParser() WasmMsgParser { - return WasmMsgParser{} +func NewWasmMsgParser() MsgParser { + return MsgParser{} } -func (WasmMsgParser) Parse(_ sdk.AccAddress, _ wasmTypes.CosmosMsg) ([]sdk.Msg, error) { +func (MsgParser) Parse(_ sdk.AccAddress, _ wasmvmtypes.CosmosMsg) ([]sdk.Msg, error) { return nil, nil } @@ -33,7 +33,7 @@ type CosmosMsg struct { Investmint *types.MsgInvestmint `json:"investmint,omitempty"` } -func (WasmMsgParser) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessage) ([]sdk.Msg, error) { +func (MsgParser) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessage) ([]sdk.Msg, error) { var sdkMsg CosmosMsg err := json.Unmarshal(data, &sdkMsg) if err != nil { @@ -44,5 +44,5 @@ func (WasmMsgParser) ParseCustom(contractAddr sdk.AccAddress, data json.RawMessa return []sdk.Msg{sdkMsg.Investmint}, sdkMsg.Investmint.ValidateBasic() } - return nil, sdkerrors.Wrap(wasm.ErrInvalidMsg, "Unknown Resources variant") + return nil, sdkerrors.Wrap(wasm.ErrInvalidMsg, "Unknown variant of Resources") } diff --git a/x/staking/module.go b/x/staking/module.go index cdcaf81..48bfdc9 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -39,5 +39,5 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { stakingtypes.RegisterQueryServer(cfg.QueryServer(), querier) m := stakingkeeper.NewMigrator(am.sk) - cfg.RegisterMigration(stakingtypes.ModuleName, 1, m.Migrate1to2) + cfg.RegisterMigration(stakingtypes.ModuleName, 1, m.Migrate1to2) //nolint:errcheck } diff --git a/x/staking/msg_server.go b/x/staking/msg_server.go index 94985a7..f520fe1 100644 --- a/x/staking/msg_server.go +++ b/x/staking/msg_server.go @@ -40,7 +40,7 @@ func (k msgServer) CreateValidator(goCtx context.Context, msg *types.MsgCreateVa if err != nil { return nil, err } - if result == false { + if !result { return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "unauthorized message: %T", msg) } @@ -110,7 +110,7 @@ func (k msgServer) CreateValidator(goCtx context.Context, msg *types.MsgCreateVa validator.MinSelfDelegation = msg.MinSelfDelegation k.SetValidator(ctx, validator) - k.SetValidatorByConsAddr(ctx, validator) + _ = k.SetValidatorByConsAddr(ctx, validator) k.SetNewValidatorByPowerIndex(ctx, validator) // call the after-creation hook @@ -209,7 +209,8 @@ func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*typ if err != nil { return nil, err } - if result == false { + + if !result { return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "unauthorized message: %T", msg) } @@ -346,7 +347,7 @@ func (k msgServer) Undelegate(goCtx context.Context, msg *types.MsgUndelegate) ( if err != nil { return nil, err } - if result == false { + if !result { return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "unauthorized message: %T", msg) } From 45b2cde8f15a53761c1670132bb311bc598e5ea6 Mon Sep 17 00:00:00 2001 From: C H Date: Tue, 16 Jan 2024 16:27:18 +0300 Subject: [PATCH 3/7] Configuration of codebase, docker setup for deepchain --- Dockerfile | 33 +++++++++++-------------------- Makefile | 14 ++++++------- app/app.go | 46 +++---------------------------------------- cmd/cyber/cmd/root.go | 6 +++--- entrypoint.sh | 34 ++++++++++++++++---------------- start_script.sh | 4 ++-- types/coins.go | 2 +- 7 files changed, 44 insertions(+), 95 deletions(-) diff --git a/Dockerfile b/Dockerfile index 89799de..1d155a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ ########################################################################################### -# Build cyber +# Build deepchain ########################################################################################### FROM ubuntu:20.04 @@ -7,14 +7,14 @@ ENV GO_VERSION '1.17.8' ENV GO_ARCH 'linux-amd64' ENV GO_BIN_SHA '980e65a863377e69fd9b67df9d8395fd8e93858e7a24c9f55803421e453f4f99' ENV DEBIAN_FRONTEND=noninteractive -ENV DAEMON_HOME /root/.cyber +ENV DAEMON_HOME /root/.deepchain ENV DAEMON_RESTART_AFTER_UPGRADE=true ENV DAEMON_ALLOW_DOWNLOAD_BINARIES=false ENV DAEMON_LOG_BUFFER_SIZE=1048 ENV UNSAFE_SKIP_BACKUP=true -ENV DAEMON_NAME cyber +ENV DAEMON_NAME deepchain ENV BUILD_DIR /build -ENV PATH /usr/local/go/bin:/root/.cargo/bin:/root/cargo/env:/root/.cyber/scripts:$PATH +ENV PATH /usr/local/go/bin:/root/.cargo/bin:/root/cargo/env:/root/.deepchain/scripts:$PATH ENV CUDA_VER '11.4.4-1' ENV PATH="/usr/local/go/bin:/usr/local/cuda/bin:$PATH" @@ -32,7 +32,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends wget ca-certifi COPY . /sources WORKDIR /sources -# Install CUDA, build tools and compile cyber +# Install CUDA, build tools and compile deepchain ########################################################################################### RUN apt-get -y install --no-install-recommends \ make gcc g++ \ @@ -48,26 +48,15 @@ RUN apt-get -y install --no-install-recommends \ && add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /" \ && apt-get update \ && apt-get install cuda=${CUDA_VER} -y --no-install-recommends \ -&& mkdir -p /cyber/cosmovisor/genesis/bin \ -&& mkdir -p /cyber/cosmovisor/upgrades/cyberfrey/bin \ -# Compile cyber for genesis version +&& mkdir -p /deepchain/cosmovisor/genesis/bin \ +# Compile deepchain for genesis version ########################################################################################### -&& git checkout v0.2.0 \ && cd /sources/x/rank/cuda \ && make build \ && cd /sources \ -&& make build CUDA_ENABLED=true \ -&& cp ./build/cyber /cyber/cosmovisor/genesis/bin/ \ -&& cp ./build/cyber /usr/local/bin \ -&& rm -rf ./build \ - # Compile cyber for genesis version -########################################################################################### -&& git checkout v0.3.0 \ -&& cd /sources/x/rank/cuda \ -&& make build \ -&& cd /sources \ -&& make build CUDA_ENABLED=true \ -&& cp ./build/cyber /cyber/cosmovisor/upgrades/cyberfrey/bin/ \ +&& make build CUDA_ENABLED=false \ +&& cp ./build/deepchain /deepchain/cosmovisor/genesis/bin/ \ +&& cp ./build/deepchain /usr/local/bin \ && rm -rf ./build \ # Cleanup ########################################################################################### @@ -99,7 +88,7 @@ COPY entrypoint.sh /entrypoint.sh RUN wget -O /genesis.json https://gateway.ipfs.cybernode.ai/ipfs/QmYubyVNfghD4xCrTFj26zBwrF9s5GJhi1TmxvrwmJCipr \ && chmod +x start_script.sh \ && chmod +x /entrypoint.sh \ -&& cyber version +&& deepchain version # Start diff --git a/Makefile b/Makefile index 4537652..a429a65 100644 --- a/Makefile +++ b/Makefile @@ -60,8 +60,8 @@ whitespace += $(whitespace) comma := , build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags)) -ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=cyber \ - -X github.com/cosmos/cosmos-sdk/version.AppName=cyber \ +ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=deepchain \ + -X github.com/cosmos/cosmos-sdk/version.AppName=deepchain \ -X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \ -X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \ -X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \ @@ -80,7 +80,7 @@ all: build format lint test ############################################################################### build: go.sum - go build $(BUILD_FLAGS) -o $(BUILDDIR) ./cmd/cyber + go build $(BUILD_FLAGS) -o $(BUILDDIR) ./cmd/deepchain build-linux: go.sum @@ -92,10 +92,10 @@ build-linux: go.sum # docker rm temp install: go.sum - go install $(BUILD_FLAGS) ./cmd/cyber + go install $(BUILD_FLAGS) ./cmd/deepchain run: - $(BUILDDIR)/cyber --home $(BUILDDIR)/bostrom-dev start + $(BUILDDIR)/cyber --home $(BUILDDIR)/deepchain-dev start ############################################################################### ### Tools / Dependencies ### @@ -130,7 +130,7 @@ statik: format: format-tools find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" | xargs gofumpt -w find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" | xargs misspell -w - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" | xargs goimports -w -local github.com/cybercongress/go-cyber + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" | xargs goimports -w -local github.com/deep-foundation/deep-chain .PHONY: format ############################################################################### @@ -154,7 +154,7 @@ localnet-stop: ### Protobuf ### ############################################################################### -HTTPS_GIT := https://github.com/cybercongress/go-cyber.git +HTTPS_GIT := https://github.com/deep-foundation/deep-chain.git DOCKER := $(shell which docker) DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf diff --git a/app/app.go b/app/app.go index 8fc4329..82eca4b 100644 --- a/app/app.go +++ b/app/app.go @@ -148,27 +148,16 @@ import ( tmjson "github.com/tendermint/tendermint/libs/json" "github.com/cybercongress/go-cyber/app/params" - - store "github.com/cosmos/cosmos-sdk/store/types" ) const ( - appName = "BostromHub" - upgradeName = "cyberfrey" + appName = "deepchain" ) // We pull these out so we can set them with LDFLAGS in the Makefile var ( - NodeDir = ".cyber" - Bech32Prefix = "bostrom" - - // TODO clean - // DefaultBondDenom is the denomination of coin to use for bond/staking - DefaultBondDenom = "boot" - // DefaultFeeDenom is the denomination of coin to use for fees - DefaultFeeDenom = "boot" - // DefaultReDnmString is the allowed denom regex expression - DefaultReDnmString = `[a-zA-Z][a-zA-Z0-9/\-\.]{2,127}` + NodeDir = ".deepchain" + Bech32Prefix = "deep" // If EnabledSpecificProposals is "", and this is "true", then enable all x/wasm proposals. ProposalsEnabled = "true" @@ -269,12 +258,6 @@ var ( _ servertypes.Application = (*App)(nil) ) -// TODO clean -// SdkCoinDenomRegex returns a new sdk base denom regex string -func SdkCoinDenomRegex() string { - return DefaultReDnmString -} - // App extended ABCI application // TODO rename to CyberApp type App struct { @@ -897,29 +880,6 @@ func NewApp( app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) - // UPGRADES HANDLER SECTION - app.UpgradeKeeper.SetUpgradeHandler( - upgradeName, - func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - // ctx.Logger().Info("start to init module...") - // ctx.Logger().Info("start to run module migrations...") - - return app.mm.RunMigrations(ctx, app.configurator, fromVM) - }, - ) - - upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() - if err != nil { - panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) - } - - if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { - storeUpgrades := store.StoreUpgrades{} - - // configure store loader that checks if version == upgradeHeight and applies store upgrades - app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) - } - app.ScopedIBCKeeper = scopedIBCKeeper app.ScopedTransferKeeper = scopedTransferKeeper app.ScopedWasmKeeper = scopedWasmKeeper diff --git a/cmd/cyber/cmd/root.go b/cmd/cyber/cmd/root.go index eb5de41..070bd08 100644 --- a/cmd/cyber/cmd/root.go +++ b/cmd/cyber/cmd/root.go @@ -60,11 +60,11 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { WithAccountRetriever(types.AccountRetriever{}). WithBroadcastMode(flags.BroadcastBlock). WithHomeDir(app.DefaultNodeHome). - WithViper("BOOT") + WithViper("DEEP") rootCmd := &cobra.Command{ - Use: "cyber", - Short: "Bostrom Bootloader Hub", + Use: "deepchain", + Short: "Deep Chain", PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { initClientCtx, err := client.ReadPersistentCommandFlags(initClientCtx, cmd.Flags()) if err != nil { diff --git a/entrypoint.sh b/entrypoint.sh index e00a7e3..c28c843 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,38 +1,38 @@ #!/bin/sh -if [ ! -d "/root/.cyber/" ] +if [ ! -d "/root/.deepchain/" ] then - mkdir /root/.cyber/ - mkdir /root/.cyber/config/ - /cyber/cosmovisor/genesis/bin/cyber init ${NODE_MONIKER} - cp -r /cyber/cosmovisor/ /root/.cyber + mkdir /root/.deepchain/ + mkdir /root/.deepchain/config/ + /deepchain/cosmovisor/genesis/bin/deepchain init ${NODE_MONIKER} + cp -r /deepchain/cosmovisor/ /root/.deepchain fi -if [ ! -f "/root/.cyber/config/node_key.json" ] +if [ ! -f "/root/.deepchain/config/node_key.json" ] then - /cyber/cosmovisor/genesis/bin/cyber init ${NODE_MONIKER} - cp /genesis.json /root/.cyber/config/ - cp -r /cyber/cosmovisor/ /root/.cyber + /deepchain/cosmovisor/genesis/bin/deepchain init ${NODE_MONIKER} + cp /genesis.json /root/.deepchain/config/ + cp -r /deepchain/cosmovisor/ /root/.deepchain fi -if [ ! -d "/root/.cyber/cosmovisor" ] +if [ ! -d "/root/.deepchain/cosmovisor" ] then - cp -r /cyber/cosmovisor/ /root/.cyber/ + cp -r /deepchain/cosmovisor/ /root/.deepchain/ fi -if [ ! -d "/root/.cyber/cosmovisor/updgrades" ] +if [ ! -d "/root/.deepchain/cosmovisor/updgrades" ] then - cp -r /cyber/cosmovisor/upgrades /root/.cyber/cosmovisor/ + cp -r /deepchain/cosmovisor/upgrades /root/.deepchain/cosmovisor/ fi -if [ -f "/root/.cyber/cosmovisor/genesis/bin/cyber" ] +if [ -f "/root/.deepchain/cosmovisor/genesis/bin/deepchain" ] then - cp /cyber/cosmovisor/genesis/bin/cyber /root/.cyber/cosmovisor/genesis/bin/cyber + cp /deepchain/cosmovisor/genesis/bin/deepchain /root/.deepchain/cosmovisor/genesis/bin/deepchain fi -if [ ! -f "/root/.cyber/config/genesis.json" ] +if [ ! -f "/root/.deepchain/config/genesis.json" ] then - cp /genesis.json /root/.cyber/config/ + cp /genesis.json /root/.deepchain/config/ fi if [ "$2" = 'init' ] diff --git a/start_script.sh b/start_script.sh index c840b19..056b1fe 100644 --- a/start_script.sh +++ b/start_script.sh @@ -4,6 +4,6 @@ ulimit -n 4096 & export DAEMON_LOG_BUFFER_SIZE=700 -# Start cyber process +# Start deepchain process #// TODO with Cosmovisor v1.x add run command (cosmovisor run) -/usr/bin/cosmovisor run start --compute-gpu true --search-api $ALLOW_SEARCH --home /root/.cyber \ No newline at end of file +/usr/bin/cosmovisor run start --compute-gpu=$COMPUTE_GPU --search-api $ALLOW_SEARCH --home /root/.deepchain \ No newline at end of file diff --git a/types/coins.go b/types/coins.go index 810a609..fd5fba3 100644 --- a/types/coins.go +++ b/types/coins.go @@ -3,7 +3,7 @@ package types import sdk "github.com/cosmos/cosmos-sdk/types" const ( - CYB = "boot" + CYB = "energy" VOLT = "millivolt" AMPERE = "milliampere" SCYB = "hydrogen" From f7b5ea9888e61816515b2bf4760b353a77cde941 Mon Sep 17 00:00:00 2001 From: C H Date: Tue, 16 Jan 2024 16:29:41 +0300 Subject: [PATCH 4/7] Changed module name to deep-foundation/deep-chain --- app/ante.go | 8 ++-- app/app.go | 68 +++++++++++++++--------------- app/encoding.go | 2 +- cmd/cyber/cmd/root.go | 6 +-- cmd/cyber/main.go | 4 +- cmd/iavltool/main.go | 2 +- go.mod | 2 +- plugins/liquidity/plugin.go | 2 +- plugins/msg_binding.go | 8 ++-- plugins/query_binding.go | 10 ++--- x/bandwidth/abci.go | 4 +- x/bandwidth/client/cli/query.go | 2 +- x/bandwidth/client/rest/query.go | 2 +- x/bandwidth/keeper/accounts.go | 2 +- x/bandwidth/keeper/blocks.go | 2 +- x/bandwidth/keeper/genesis.go | 2 +- x/bandwidth/keeper/grpc_query.go | 2 +- x/bandwidth/keeper/keeper.go | 4 +- x/bandwidth/keeper/querier.go | 2 +- x/bandwidth/module.go | 8 ++-- x/bandwidth/wasm/interface.go | 2 +- x/cyberbank/abci.go | 4 +- x/cyberbank/keeper/keeper.go | 2 +- x/cyberbank/keeper/proxy.go | 4 +- x/cyberbank/module.go | 4 +- x/dmn/abci.go | 4 +- x/dmn/client/cli/query.go | 2 +- x/dmn/client/rest/query.go | 2 +- x/dmn/keeper/genesis.go | 2 +- x/dmn/keeper/grpc_query.go | 2 +- x/dmn/keeper/keeper.go | 6 +-- x/dmn/keeper/msg_server.go | 4 +- x/dmn/keeper/querier.go | 2 +- x/dmn/module.go | 8 ++-- x/dmn/types/msgs.go | 4 +- x/dmn/wasm/interface.go | 6 +-- x/graph/abci.go | 4 +- x/graph/client/cli/query.go | 2 +- x/graph/client/cli/tx.go | 2 +- x/graph/client/rest/query.go | 2 +- x/graph/keeper/genesis.go | 2 +- x/graph/keeper/graph.go | 4 +- x/graph/keeper/grpc_query.go | 2 +- x/graph/keeper/index.go | 6 +-- x/graph/keeper/msg_server.go | 10 ++--- x/graph/keeper/neudeg.go | 2 +- x/graph/keeper/particles.go | 4 +- x/graph/keeper/querier.go | 2 +- x/graph/module.go | 12 +++--- x/graph/types/compact_link.go | 2 +- x/graph/types/cyberlinks.go | 2 +- x/graph/wasm/interface.go | 4 +- x/grid/client/cli/query.go | 2 +- x/grid/client/cli/tx.go | 2 +- x/grid/client/rest/query.go | 2 +- x/grid/keeper/genesis.go | 2 +- x/grid/keeper/grpc_query.go | 2 +- x/grid/keeper/keeper.go | 6 +-- x/grid/keeper/msg_server.go | 2 +- x/grid/keeper/querier.go | 2 +- x/grid/module.go | 8 ++-- x/grid/types/msgs.go | 2 +- x/grid/wasm/interface.go | 6 +-- x/rank/abci.go | 2 +- x/rank/client/cli/query.go | 6 +-- x/rank/client/rest/query.go | 2 +- x/rank/keeper/calculate.go | 2 +- x/rank/keeper/calculate_cpu.go | 4 +- x/rank/keeper/calculate_gpu.go | 4 +- x/rank/keeper/calculate_gpu_nop.go | 2 +- x/rank/keeper/genesis.go | 2 +- x/rank/keeper/grpc_query.go | 6 +-- x/rank/keeper/keeper.go | 8 ++-- x/rank/keeper/querier.go | 6 +-- x/rank/module.go | 8 ++-- x/rank/types/context.go | 2 +- x/rank/types/expected_keepers.go | 2 +- x/rank/types/index.go | 2 +- x/rank/types/index_types.go | 2 +- x/rank/types/query.pb.go | 2 +- x/rank/types/query.pb.gw.go | 2 +- x/rank/types/rank.go | 4 +- x/rank/wasm/interface.go | 4 +- x/resources/client/cli/query.go | 4 +- x/resources/client/cli/tx.go | 4 +- x/resources/client/rest/query.go | 4 +- x/resources/keeper/genesis.go | 2 +- x/resources/keeper/grpc_query.go | 4 +- x/resources/keeper/keeper.go | 6 +-- x/resources/keeper/msg_server.go | 4 +- x/resources/keeper/querier.go | 4 +- x/resources/module.go | 8 ++-- x/resources/types/msgs.go | 2 +- x/resources/types/params.go | 2 +- x/resources/wasm/interface.go | 2 +- x/staking/msg_server.go | 4 +- 96 files changed, 210 insertions(+), 210 deletions(-) diff --git a/app/ante.go b/app/ante.go index 11dac3b..64dd88f 100644 --- a/app/ante.go +++ b/app/ante.go @@ -13,15 +13,15 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - ctypes "github.com/cybercongress/go-cyber/types" + ctypes "github.com/deep-foundation/deep-chain/types" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" ibcante "github.com/cosmos/ibc-go/v3/modules/core/ante" "github.com/cosmos/ibc-go/v3/modules/core/keeper" - bandwidthkeeper "github.com/cybercongress/go-cyber/x/bandwidth/keeper" - bandwidthtypes "github.com/cybercongress/go-cyber/x/bandwidth/types" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" + bandwidthkeeper "github.com/deep-foundation/deep-chain/x/bandwidth/keeper" + bandwidthtypes "github.com/deep-foundation/deep-chain/x/bandwidth/types" + graphtypes "github.com/deep-foundation/deep-chain/x/graph/types" ) // HandlerOptions are the options required for constructing a default SDK AnteHandler. diff --git a/app/app.go b/app/app.go index 82eca4b..4c1bcb0 100644 --- a/app/app.go +++ b/app/app.go @@ -9,7 +9,7 @@ import ( "strings" "time" - liquidityplugin "github.com/cybercongress/go-cyber/plugins/liquidity" + liquidityplugin "github.com/deep-foundation/deep-chain/plugins/liquidity" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/cosmos/cosmos-sdk/x/authz" @@ -36,11 +36,11 @@ import ( liquiditykeeper "github.com/tendermint/liquidity/x/liquidity/keeper" liquiditytypes "github.com/tendermint/liquidity/x/liquidity/types" - ctypes "github.com/cybercongress/go-cyber/types" + ctypes "github.com/deep-foundation/deep-chain/types" - wasmplugins "github.com/cybercongress/go-cyber/plugins" - "github.com/cybercongress/go-cyber/x/dmn" - "github.com/cybercongress/go-cyber/x/resources" + wasmplugins "github.com/deep-foundation/deep-chain/plugins" + "github.com/deep-foundation/deep-chain/x/dmn" + "github.com/deep-foundation/deep-chain/x/resources" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec/types" @@ -108,46 +108,46 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/cybercongress/go-cyber/utils" - "github.com/cybercongress/go-cyber/x/bandwidth" - "github.com/cybercongress/go-cyber/x/cyberbank" - cyberbankkeeper "github.com/cybercongress/go-cyber/x/cyberbank/keeper" - cyberbanktypes "github.com/cybercongress/go-cyber/x/cyberbank/types" - "github.com/cybercongress/go-cyber/x/graph" - - bandwidthkeeper "github.com/cybercongress/go-cyber/x/bandwidth/keeper" - bandwidthtypes "github.com/cybercongress/go-cyber/x/bandwidth/types" - graphkeeper "github.com/cybercongress/go-cyber/x/graph/keeper" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" - "github.com/cybercongress/go-cyber/x/rank" - rankkeeper "github.com/cybercongress/go-cyber/x/rank/keeper" - ranktypes "github.com/cybercongress/go-cyber/x/rank/types" + "github.com/deep-foundation/deep-chain/utils" + "github.com/deep-foundation/deep-chain/x/bandwidth" + "github.com/deep-foundation/deep-chain/x/cyberbank" + cyberbankkeeper "github.com/deep-foundation/deep-chain/x/cyberbank/keeper" + cyberbanktypes "github.com/deep-foundation/deep-chain/x/cyberbank/types" + "github.com/deep-foundation/deep-chain/x/graph" + + bandwidthkeeper "github.com/deep-foundation/deep-chain/x/bandwidth/keeper" + bandwidthtypes "github.com/deep-foundation/deep-chain/x/bandwidth/types" + graphkeeper "github.com/deep-foundation/deep-chain/x/graph/keeper" + graphtypes "github.com/deep-foundation/deep-chain/x/graph/types" + "github.com/deep-foundation/deep-chain/x/rank" + rankkeeper "github.com/deep-foundation/deep-chain/x/rank/keeper" + ranktypes "github.com/deep-foundation/deep-chain/x/rank/types" "github.com/CosmWasm/wasmd/x/wasm" wasmclient "github.com/CosmWasm/wasmd/x/wasm/client" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - bandwidthwasm "github.com/cybercongress/go-cyber/x/bandwidth/wasm" - dmnwasm "github.com/cybercongress/go-cyber/x/dmn/wasm" - graphwasm "github.com/cybercongress/go-cyber/x/graph/wasm" - gridwasm "github.com/cybercongress/go-cyber/x/grid/wasm" - rankwasm "github.com/cybercongress/go-cyber/x/rank/wasm" - resourceswasm "github.com/cybercongress/go-cyber/x/resources/wasm" + bandwidthwasm "github.com/deep-foundation/deep-chain/x/bandwidth/wasm" + dmnwasm "github.com/deep-foundation/deep-chain/x/dmn/wasm" + graphwasm "github.com/deep-foundation/deep-chain/x/graph/wasm" + gridwasm "github.com/deep-foundation/deep-chain/x/grid/wasm" + rankwasm "github.com/deep-foundation/deep-chain/x/rank/wasm" + resourceswasm "github.com/deep-foundation/deep-chain/x/resources/wasm" - grid "github.com/cybercongress/go-cyber/x/grid" - gridkeeper "github.com/cybercongress/go-cyber/x/grid/keeper" - gridtypes "github.com/cybercongress/go-cyber/x/grid/types" + grid "github.com/deep-foundation/deep-chain/x/grid" + gridkeeper "github.com/deep-foundation/deep-chain/x/grid/keeper" + gridtypes "github.com/deep-foundation/deep-chain/x/grid/types" - dmnkeeper "github.com/cybercongress/go-cyber/x/dmn/keeper" - dmntypes "github.com/cybercongress/go-cyber/x/dmn/types" + dmnkeeper "github.com/deep-foundation/deep-chain/x/dmn/keeper" + dmntypes "github.com/deep-foundation/deep-chain/x/dmn/types" - resourceskeeper "github.com/cybercongress/go-cyber/x/resources/keeper" - resourcestypes "github.com/cybercongress/go-cyber/x/resources/types" - stakingwrap "github.com/cybercongress/go-cyber/x/staking" + resourceskeeper "github.com/deep-foundation/deep-chain/x/resources/keeper" + resourcestypes "github.com/deep-foundation/deep-chain/x/resources/types" + stakingwrap "github.com/deep-foundation/deep-chain/x/staking" tmjson "github.com/tendermint/tendermint/libs/json" - "github.com/cybercongress/go-cyber/app/params" + "github.com/deep-foundation/deep-chain/app/params" ) const ( diff --git a/app/encoding.go b/app/encoding.go index 999ef7f..99d27f3 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -4,7 +4,7 @@ import ( simappparams "github.com/cosmos/cosmos-sdk/simapp/params" "github.com/cosmos/cosmos-sdk/std" - "github.com/cybercongress/go-cyber/app/params" + "github.com/deep-foundation/deep-chain/app/params" ) func MakeEncodingConfig() params.EncodingConfig { diff --git a/cmd/cyber/cmd/root.go b/cmd/cyber/cmd/root.go index 070bd08..b548177 100644 --- a/cmd/cyber/cmd/root.go +++ b/cmd/cyber/cmd/root.go @@ -10,13 +10,13 @@ import ( "github.com/cosmos/cosmos-sdk/client/config" "github.com/prometheus/client_golang/prometheus" - "github.com/cybercongress/go-cyber/app" + "github.com/deep-foundation/deep-chain/app" "github.com/CosmWasm/wasmd/x/wasm" "github.com/cosmos/cosmos-sdk/snapshots" "github.com/cosmos/cosmos-sdk/x/crisis" - "github.com/cybercongress/go-cyber/x/rank" + "github.com/deep-foundation/deep-chain/x/rank" "github.com/spf13/cast" "github.com/spf13/cobra" @@ -41,7 +41,7 @@ import ( serverconfig "github.com/cosmos/cosmos-sdk/server/config" - "github.com/cybercongress/go-cyber/app/params" + "github.com/deep-foundation/deep-chain/app/params" ) // NewRootCmd creates a new root command for simd. It is called once in the diff --git a/cmd/cyber/main.go b/cmd/cyber/main.go index d77ea62..1306560 100644 --- a/cmd/cyber/main.go +++ b/cmd/cyber/main.go @@ -6,8 +6,8 @@ import ( "github.com/cosmos/cosmos-sdk/server" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" - "github.com/cybercongress/go-cyber/app" - "github.com/cybercongress/go-cyber/cmd/cyber/cmd" + "github.com/deep-foundation/deep-chain/app" + "github.com/deep-foundation/deep-chain/cmd/cyber/cmd" ) func main() { diff --git a/cmd/iavltool/main.go b/cmd/iavltool/main.go index eb86a12..3a4ee07 100644 --- a/cmd/iavltool/main.go +++ b/cmd/iavltool/main.go @@ -1,7 +1,7 @@ package main import ( - "github.com/cybercongress/go-cyber/cmd/iavltool/cmd" + "github.com/deep-foundation/deep-chain/cmd/iavltool/cmd" ) func main() { diff --git a/go.mod b/go.mod index 892a1ae..43bdb60 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/cybercongress/go-cyber +module github.com/deep-foundation/deep-chain go 1.17 diff --git a/plugins/liquidity/plugin.go b/plugins/liquidity/plugin.go index 9ef4434..89b3478 100644 --- a/plugins/liquidity/plugin.go +++ b/plugins/liquidity/plugin.go @@ -6,7 +6,7 @@ import ( wasmvmtypes "github.com/CosmWasm/wasmvm/types" liquiditytypes "github.com/tendermint/liquidity/x/liquidity/types" - "github.com/cybercongress/go-cyber/plugins" + "github.com/deep-foundation/deep-chain/plugins" "github.com/CosmWasm/wasmd/x/wasm" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/plugins/msg_binding.go b/plugins/msg_binding.go index 45b3479..1b93961 100644 --- a/plugins/msg_binding.go +++ b/plugins/msg_binding.go @@ -11,10 +11,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - dmntypes "github.com/cybercongress/go-cyber/x/dmn/types" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" - gridtypes "github.com/cybercongress/go-cyber/x/grid/types" - resourcestypes "github.com/cybercongress/go-cyber/x/resources/types" + dmntypes "github.com/deep-foundation/deep-chain/x/dmn/types" + graphtypes "github.com/deep-foundation/deep-chain/x/graph/types" + gridtypes "github.com/deep-foundation/deep-chain/x/grid/types" + resourcestypes "github.com/deep-foundation/deep-chain/x/resources/types" ) type WasmMsgParserInterface interface { diff --git a/plugins/query_binding.go b/plugins/query_binding.go index 9cd06db..5cfe53a 100644 --- a/plugins/query_binding.go +++ b/plugins/query_binding.go @@ -10,11 +10,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - bandwidthtypes "github.com/cybercongress/go-cyber/x/bandwidth/types" - dmntypes "github.com/cybercongress/go-cyber/x/dmn/types" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" - gridtypes "github.com/cybercongress/go-cyber/x/grid/types" - ranktypes "github.com/cybercongress/go-cyber/x/rank/types" + bandwidthtypes "github.com/deep-foundation/deep-chain/x/bandwidth/types" + dmntypes "github.com/deep-foundation/deep-chain/x/dmn/types" + graphtypes "github.com/deep-foundation/deep-chain/x/graph/types" + gridtypes "github.com/deep-foundation/deep-chain/x/grid/types" + ranktypes "github.com/deep-foundation/deep-chain/x/rank/types" ) type WasmQuerierInterface interface { diff --git a/x/bandwidth/abci.go b/x/bandwidth/abci.go index 2b3095d..c0eb619 100644 --- a/x/bandwidth/abci.go +++ b/x/bandwidth/abci.go @@ -6,8 +6,8 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/x/bandwidth/keeper" - "github.com/cybercongress/go-cyber/x/bandwidth/types" + "github.com/deep-foundation/deep-chain/x/bandwidth/keeper" + "github.com/deep-foundation/deep-chain/x/bandwidth/types" ) var accountsToUpdate = make([]sdk.AccAddress, 0) diff --git a/x/bandwidth/client/cli/query.go b/x/bandwidth/client/cli/query.go index c685b22..0c8b425 100644 --- a/x/bandwidth/client/cli/query.go +++ b/x/bandwidth/client/cli/query.go @@ -10,7 +10,7 @@ import ( // sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/cobra" - "github.com/cybercongress/go-cyber/x/bandwidth/types" + "github.com/deep-foundation/deep-chain/x/bandwidth/types" ) func GetQueryCmd() *cobra.Command { diff --git a/x/bandwidth/client/rest/query.go b/x/bandwidth/client/rest/query.go index 26efa60..6dbb067 100644 --- a/x/bandwidth/client/rest/query.go +++ b/x/bandwidth/client/rest/query.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/rest" - "github.com/cybercongress/go-cyber/x/bandwidth/types" + "github.com/deep-foundation/deep-chain/x/bandwidth/types" ) func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { diff --git a/x/bandwidth/keeper/accounts.go b/x/bandwidth/keeper/accounts.go index a3f6870..fd49fd6 100644 --- a/x/bandwidth/keeper/accounts.go +++ b/x/bandwidth/keeper/accounts.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/x/bandwidth/types" + "github.com/deep-foundation/deep-chain/x/bandwidth/types" ) func (bm BandwidthMeter) SetAccountBandwidth(ctx sdk.Context, ab types.NeuronBandwidth) { diff --git a/x/bandwidth/keeper/blocks.go b/x/bandwidth/keeper/blocks.go index d225fe3..184b0b2 100644 --- a/x/bandwidth/keeper/blocks.go +++ b/x/bandwidth/keeper/blocks.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/x/bandwidth/types" + "github.com/deep-foundation/deep-chain/x/bandwidth/types" ) func (bm BandwidthMeter) SetBlockBandwidth(ctx sdk.Context, blockNumber uint64, value uint64) { diff --git a/x/bandwidth/keeper/genesis.go b/x/bandwidth/keeper/genesis.go index 8d0b457..4e3c0ee 100644 --- a/x/bandwidth/keeper/genesis.go +++ b/x/bandwidth/keeper/genesis.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - "github.com/cybercongress/go-cyber/x/bandwidth/types" + "github.com/deep-foundation/deep-chain/x/bandwidth/types" ) func InitGenesis(ctx sdk.Context, bm *BandwidthMeter, ak authkeeper.AccountKeeper, data types.GenesisState) { diff --git a/x/bandwidth/keeper/grpc_query.go b/x/bandwidth/keeper/grpc_query.go index 47c9445..b3bd9d4 100644 --- a/x/bandwidth/keeper/grpc_query.go +++ b/x/bandwidth/keeper/grpc_query.go @@ -7,7 +7,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/cybercongress/go-cyber/x/bandwidth/types" + "github.com/deep-foundation/deep-chain/x/bandwidth/types" ) var _ types.QueryServer = &BandwidthMeter{} diff --git a/x/bandwidth/keeper/keeper.go b/x/bandwidth/keeper/keeper.go index 6177e10..4a595a8 100644 --- a/x/bandwidth/keeper/keeper.go +++ b/x/bandwidth/keeper/keeper.go @@ -9,8 +9,8 @@ import ( paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/tendermint/tendermint/libs/log" - "github.com/cybercongress/go-cyber/x/bandwidth/types" - gtypes "github.com/cybercongress/go-cyber/x/graph/types" + "github.com/deep-foundation/deep-chain/x/bandwidth/types" + gtypes "github.com/deep-foundation/deep-chain/x/graph/types" ) type BandwidthMeter struct { diff --git a/x/bandwidth/keeper/querier.go b/x/bandwidth/keeper/querier.go index 01ba077..4c4a574 100644 --- a/x/bandwidth/keeper/querier.go +++ b/x/bandwidth/keeper/querier.go @@ -6,7 +6,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" abci "github.com/tendermint/tendermint/abci/types" - "github.com/cybercongress/go-cyber/x/bandwidth/types" + "github.com/deep-foundation/deep-chain/x/bandwidth/types" ) func NewQuerier(bm *BandwidthMeter, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { diff --git a/x/bandwidth/module.go b/x/bandwidth/module.go index d6da2fb..5b509e6 100644 --- a/x/bandwidth/module.go +++ b/x/bandwidth/module.go @@ -14,10 +14,10 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - "github.com/cybercongress/go-cyber/x/bandwidth/client/cli" - "github.com/cybercongress/go-cyber/x/bandwidth/client/rest" - "github.com/cybercongress/go-cyber/x/bandwidth/keeper" - "github.com/cybercongress/go-cyber/x/bandwidth/types" + "github.com/deep-foundation/deep-chain/x/bandwidth/client/cli" + "github.com/deep-foundation/deep-chain/x/bandwidth/client/rest" + "github.com/deep-foundation/deep-chain/x/bandwidth/keeper" + "github.com/deep-foundation/deep-chain/x/bandwidth/types" sdk "github.com/cosmos/cosmos-sdk/types" abci "github.com/tendermint/tendermint/abci/types" diff --git a/x/bandwidth/wasm/interface.go b/x/bandwidth/wasm/interface.go index 1d21b0f..0a6fa48 100644 --- a/x/bandwidth/wasm/interface.go +++ b/x/bandwidth/wasm/interface.go @@ -8,7 +8,7 @@ import ( wasmvmtypes "github.com/CosmWasm/wasmvm/types" - "github.com/cybercongress/go-cyber/x/bandwidth/keeper" + "github.com/deep-foundation/deep-chain/x/bandwidth/keeper" ) var _ QuerierInterface = Querier{} diff --git a/x/cyberbank/abci.go b/x/cyberbank/abci.go index 91bb013..52f86f4 100644 --- a/x/cyberbank/abci.go +++ b/x/cyberbank/abci.go @@ -6,8 +6,8 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/x/cyberbank/keeper" - "github.com/cybercongress/go-cyber/x/cyberbank/types" + "github.com/deep-foundation/deep-chain/x/cyberbank/keeper" + "github.com/deep-foundation/deep-chain/x/cyberbank/types" ) func EndBlocker(ctx sdk.Context, k *keeper.IndexedKeeper) { diff --git a/x/cyberbank/keeper/keeper.go b/x/cyberbank/keeper/keeper.go index dca16cc..a84781d 100644 --- a/x/cyberbank/keeper/keeper.go +++ b/x/cyberbank/keeper/keeper.go @@ -11,7 +11,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/tendermint/tendermint/libs/log" - "github.com/cybercongress/go-cyber/x/cyberbank/types" + "github.com/deep-foundation/deep-chain/x/cyberbank/types" ) type IndexedKeeper struct { diff --git a/x/cyberbank/keeper/proxy.go b/x/cyberbank/keeper/proxy.go index 5da73a5..597d73e 100644 --- a/x/cyberbank/keeper/proxy.go +++ b/x/cyberbank/keeper/proxy.go @@ -10,8 +10,8 @@ import ( bank "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - ctypes "github.com/cybercongress/go-cyber/types" - "github.com/cybercongress/go-cyber/x/cyberbank/types" + ctypes "github.com/deep-foundation/deep-chain/types" + "github.com/deep-foundation/deep-chain/x/cyberbank/types" ) var _ bank.Keeper = (*Proxy)(nil) diff --git a/x/cyberbank/module.go b/x/cyberbank/module.go index bcd9b63..0315cf4 100644 --- a/x/cyberbank/module.go +++ b/x/cyberbank/module.go @@ -15,8 +15,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cybercongress/go-cyber/x/cyberbank/keeper" - "github.com/cybercongress/go-cyber/x/cyberbank/types" + "github.com/deep-foundation/deep-chain/x/cyberbank/keeper" + "github.com/deep-foundation/deep-chain/x/cyberbank/types" ) var ( diff --git a/x/dmn/abci.go b/x/dmn/abci.go index bfdb0ba..197faca 100644 --- a/x/dmn/abci.go +++ b/x/dmn/abci.go @@ -6,8 +6,8 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/x/dmn/keeper" - "github.com/cybercongress/go-cyber/x/dmn/types" + "github.com/deep-foundation/deep-chain/x/dmn/keeper" + "github.com/deep-foundation/deep-chain/x/dmn/types" ) func BeginBlock(ctx sdk.Context, k keeper.Keeper) { diff --git a/x/dmn/client/cli/query.go b/x/dmn/client/cli/query.go index 6887368..6a99238 100644 --- a/x/dmn/client/cli/query.go +++ b/x/dmn/client/cli/query.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" - "github.com/cybercongress/go-cyber/x/dmn/types" + "github.com/deep-foundation/deep-chain/x/dmn/types" ) func GetQueryCmd() *cobra.Command { diff --git a/x/dmn/client/rest/query.go b/x/dmn/client/rest/query.go index 43a9bda..292d7b8 100644 --- a/x/dmn/client/rest/query.go +++ b/x/dmn/client/rest/query.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/rest" - "github.com/cybercongress/go-cyber/x/dmn/types" + "github.com/deep-foundation/deep-chain/x/dmn/types" ) func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { diff --git a/x/dmn/keeper/genesis.go b/x/dmn/keeper/genesis.go index 86e0ed2..635d9e9 100644 --- a/x/dmn/keeper/genesis.go +++ b/x/dmn/keeper/genesis.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/x/dmn/types" + "github.com/deep-foundation/deep-chain/x/dmn/types" ) func InitGenesis(ctx sdk.Context, k Keeper, data types.GenesisState) { diff --git a/x/dmn/keeper/grpc_query.go b/x/dmn/keeper/grpc_query.go index 1c5d0ac..9a4d784 100644 --- a/x/dmn/keeper/grpc_query.go +++ b/x/dmn/keeper/grpc_query.go @@ -7,7 +7,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/cybercongress/go-cyber/x/dmn/types" + "github.com/deep-foundation/deep-chain/x/dmn/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/dmn/keeper/keeper.go b/x/dmn/keeper/keeper.go index f7a71e2..5a66422 100644 --- a/x/dmn/keeper/keeper.go +++ b/x/dmn/keeper/keeper.go @@ -15,10 +15,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - ctypes "github.com/cybercongress/go-cyber/types" + ctypes "github.com/deep-foundation/deep-chain/types" - "github.com/cybercongress/go-cyber/x/dmn/types" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" + "github.com/deep-foundation/deep-chain/x/dmn/types" + graphtypes "github.com/deep-foundation/deep-chain/x/graph/types" ) // Keeper of the power store diff --git a/x/dmn/keeper/msg_server.go b/x/dmn/keeper/msg_server.go index 5e787a9..c4d6fa1 100644 --- a/x/dmn/keeper/msg_server.go +++ b/x/dmn/keeper/msg_server.go @@ -5,8 +5,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/x/dmn/types" - graph "github.com/cybercongress/go-cyber/x/graph/types" + "github.com/deep-foundation/deep-chain/x/dmn/types" + graph "github.com/deep-foundation/deep-chain/x/graph/types" ) type msgServer struct { diff --git a/x/dmn/keeper/querier.go b/x/dmn/keeper/querier.go index f08c7f7..1c04f98 100644 --- a/x/dmn/keeper/querier.go +++ b/x/dmn/keeper/querier.go @@ -6,7 +6,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" abci "github.com/tendermint/tendermint/abci/types" - "github.com/cybercongress/go-cyber/x/dmn/types" + "github.com/deep-foundation/deep-chain/x/dmn/types" ) func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { diff --git a/x/dmn/module.go b/x/dmn/module.go index f633951..4d48e07 100644 --- a/x/dmn/module.go +++ b/x/dmn/module.go @@ -17,10 +17,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cybercongress/go-cyber/x/dmn/client/cli" - "github.com/cybercongress/go-cyber/x/dmn/client/rest" - "github.com/cybercongress/go-cyber/x/dmn/keeper" - "github.com/cybercongress/go-cyber/x/dmn/types" + "github.com/deep-foundation/deep-chain/x/dmn/client/cli" + "github.com/deep-foundation/deep-chain/x/dmn/client/rest" + "github.com/deep-foundation/deep-chain/x/dmn/keeper" + "github.com/deep-foundation/deep-chain/x/dmn/types" ) var ( diff --git a/x/dmn/types/msgs.go b/x/dmn/types/msgs.go index ce77c4e..14e1be0 100644 --- a/x/dmn/types/msgs.go +++ b/x/dmn/types/msgs.go @@ -7,8 +7,8 @@ import ( // sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cybercongress/go-cyber/types" - graph "github.com/cybercongress/go-cyber/x/graph/types" + "github.com/deep-foundation/deep-chain/types" + graph "github.com/deep-foundation/deep-chain/x/graph/types" ) const ( diff --git a/x/dmn/wasm/interface.go b/x/dmn/wasm/interface.go index e2ac4fa..51fa919 100644 --- a/x/dmn/wasm/interface.go +++ b/x/dmn/wasm/interface.go @@ -7,12 +7,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - wasmplugins "github.com/cybercongress/go-cyber/plugins" + wasmplugins "github.com/deep-foundation/deep-chain/plugins" wasmvmtypes "github.com/CosmWasm/wasmvm/types" - "github.com/cybercongress/go-cyber/x/dmn/keeper" - "github.com/cybercongress/go-cyber/x/dmn/types" + "github.com/deep-foundation/deep-chain/x/dmn/keeper" + "github.com/deep-foundation/deep-chain/x/dmn/types" ) var ( diff --git a/x/graph/abci.go b/x/graph/abci.go index 6b6fc73..f1f58a4 100644 --- a/x/graph/abci.go +++ b/x/graph/abci.go @@ -6,8 +6,8 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/x/graph/keeper" - "github.com/cybercongress/go-cyber/x/graph/types" + "github.com/deep-foundation/deep-chain/x/graph/keeper" + "github.com/deep-foundation/deep-chain/x/graph/types" ) func EndBlocker(ctx sdk.Context, gk *keeper.GraphKeeper, ik *keeper.IndexKeeper) { diff --git a/x/graph/client/cli/query.go b/x/graph/client/cli/query.go index c82aad5..477d9d8 100644 --- a/x/graph/client/cli/query.go +++ b/x/graph/client/cli/query.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/cobra" - "github.com/cybercongress/go-cyber/x/graph/types" + "github.com/deep-foundation/deep-chain/x/graph/types" ) // GetQueryCmd returns diff --git a/x/graph/client/cli/tx.go b/x/graph/client/cli/tx.go index 85e6693..c8c8e32 100644 --- a/x/graph/client/cli/tx.go +++ b/x/graph/client/cli/tx.go @@ -12,7 +12,7 @@ import ( "github.com/ipfs/go-cid" "github.com/spf13/cobra" - "github.com/cybercongress/go-cyber/x/graph/types" + "github.com/deep-foundation/deep-chain/x/graph/types" ) func NewTxCmd() *cobra.Command { diff --git a/x/graph/client/rest/query.go b/x/graph/client/rest/query.go index 67d8d97..61a538a 100644 --- a/x/graph/client/rest/query.go +++ b/x/graph/client/rest/query.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/rest" "github.com/gorilla/mux" - "github.com/cybercongress/go-cyber/x/graph/types" + "github.com/deep-foundation/deep-chain/x/graph/types" ) func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { diff --git a/x/graph/keeper/genesis.go b/x/graph/keeper/genesis.go index bc732c2..07c7cd8 100644 --- a/x/graph/keeper/genesis.go +++ b/x/graph/keeper/genesis.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/utils" + "github.com/deep-foundation/deep-chain/utils" ) const ( diff --git a/x/graph/keeper/graph.go b/x/graph/keeper/graph.go index 318ee39..7860555 100644 --- a/x/graph/keeper/graph.go +++ b/x/graph/keeper/graph.go @@ -10,8 +10,8 @@ import ( "github.com/tendermint/tendermint/libs/log" - ctypes "github.com/cybercongress/go-cyber/types" - "github.com/cybercongress/go-cyber/x/graph/types" + ctypes "github.com/deep-foundation/deep-chain/types" + "github.com/deep-foundation/deep-chain/x/graph/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/graph/keeper/grpc_query.go b/x/graph/keeper/grpc_query.go index c026ec7..e4dcb5c 100644 --- a/x/graph/keeper/grpc_query.go +++ b/x/graph/keeper/grpc_query.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/x/graph/types" + "github.com/deep-foundation/deep-chain/x/graph/types" ) var _ types.QueryServer = GraphKeeper{} diff --git a/x/graph/keeper/index.go b/x/graph/keeper/index.go index d8910fe..9cdad1a 100644 --- a/x/graph/keeper/index.go +++ b/x/graph/keeper/index.go @@ -4,9 +4,9 @@ import ( "encoding/binary" "io" - ctypes "github.com/cybercongress/go-cyber/types" - "github.com/cybercongress/go-cyber/utils" - "github.com/cybercongress/go-cyber/x/graph/types" + ctypes "github.com/deep-foundation/deep-chain/types" + "github.com/deep-foundation/deep-chain/utils" + "github.com/deep-foundation/deep-chain/x/graph/types" sdk "github.com/cosmos/cosmos-sdk/types" tmos "github.com/tendermint/tendermint/libs/os" diff --git a/x/graph/keeper/msg_server.go b/x/graph/keeper/msg_server.go index 516512f..c920137 100644 --- a/x/graph/keeper/msg_server.go +++ b/x/graph/keeper/msg_server.go @@ -8,13 +8,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - ctypes "github.com/cybercongress/go-cyber/types" - bandwidthkeeper "github.com/cybercongress/go-cyber/x/bandwidth/keeper" - bandwidthtypes "github.com/cybercongress/go-cyber/x/bandwidth/types" - cyberbankkeeper "github.com/cybercongress/go-cyber/x/cyberbank/keeper" + ctypes "github.com/deep-foundation/deep-chain/types" + bandwidthkeeper "github.com/deep-foundation/deep-chain/x/bandwidth/keeper" + bandwidthtypes "github.com/deep-foundation/deep-chain/x/bandwidth/types" + cyberbankkeeper "github.com/deep-foundation/deep-chain/x/cyberbank/keeper" // sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cybercongress/go-cyber/x/graph/types" + "github.com/deep-foundation/deep-chain/x/graph/types" ) type msgServer struct { diff --git a/x/graph/keeper/neudeg.go b/x/graph/keeper/neudeg.go index b764bf9..48c645a 100644 --- a/x/graph/keeper/neudeg.go +++ b/x/graph/keeper/neudeg.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/x/graph/types" + "github.com/deep-foundation/deep-chain/x/graph/types" ) // In order to calculate the flow of amperes through cyberlinks created by given agents than need to compute neurons out-degree diff --git a/x/graph/keeper/particles.go b/x/graph/keeper/particles.go index 34dec83..2d55248 100644 --- a/x/graph/keeper/particles.go +++ b/x/graph/keeper/particles.go @@ -6,8 +6,8 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" - "github.com/cybercongress/go-cyber/utils" - "github.com/cybercongress/go-cyber/x/graph/types" + "github.com/deep-foundation/deep-chain/utils" + "github.com/deep-foundation/deep-chain/x/graph/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/graph/keeper/querier.go b/x/graph/keeper/querier.go index bda6ec7..bd1f315 100644 --- a/x/graph/keeper/querier.go +++ b/x/graph/keeper/querier.go @@ -6,7 +6,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" abci "github.com/tendermint/tendermint/abci/types" - "github.com/cybercongress/go-cyber/x/graph/types" + "github.com/deep-foundation/deep-chain/x/graph/types" ) func NewQuerier(gk GraphKeeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { diff --git a/x/graph/module.go b/x/graph/module.go index 1a53be9..985191a 100644 --- a/x/graph/module.go +++ b/x/graph/module.go @@ -11,18 +11,18 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/runtime" abci "github.com/tendermint/tendermint/abci/types" - bandwidthkeeper "github.com/cybercongress/go-cyber/x/bandwidth/keeper" + bandwidthkeeper "github.com/deep-foundation/deep-chain/x/bandwidth/keeper" "github.com/cosmos/cosmos-sdk/codec" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/gorilla/mux" "github.com/spf13/cobra" - cyberbankkeeper "github.com/cybercongress/go-cyber/x/cyberbank/keeper" - "github.com/cybercongress/go-cyber/x/graph/client/cli" - "github.com/cybercongress/go-cyber/x/graph/client/rest" - "github.com/cybercongress/go-cyber/x/graph/keeper" - "github.com/cybercongress/go-cyber/x/graph/types" + cyberbankkeeper "github.com/deep-foundation/deep-chain/x/cyberbank/keeper" + "github.com/deep-foundation/deep-chain/x/graph/client/cli" + "github.com/deep-foundation/deep-chain/x/graph/client/rest" + "github.com/deep-foundation/deep-chain/x/graph/keeper" + "github.com/deep-foundation/deep-chain/x/graph/types" ) var ( diff --git a/x/graph/types/compact_link.go b/x/graph/types/compact_link.go index d31a7c0..8a5c101 100644 --- a/x/graph/types/compact_link.go +++ b/x/graph/types/compact_link.go @@ -3,7 +3,7 @@ package types import ( "encoding/binary" - "github.com/cybercongress/go-cyber/types" + "github.com/deep-foundation/deep-chain/types" ) type CompactLink struct { diff --git a/x/graph/types/cyberlinks.go b/x/graph/types/cyberlinks.go index 683eb47..31ebe9f 100644 --- a/x/graph/types/cyberlinks.go +++ b/x/graph/types/cyberlinks.go @@ -1,6 +1,6 @@ package types -import "github.com/cybercongress/go-cyber/types" +import "github.com/deep-foundation/deep-chain/types" // map of map, where first key is cid, second key is account.String() // second map is used as set for fast contains check diff --git a/x/graph/wasm/interface.go b/x/graph/wasm/interface.go index bf85f2f..61940d2 100644 --- a/x/graph/wasm/interface.go +++ b/x/graph/wasm/interface.go @@ -9,8 +9,8 @@ import ( wasmvmtypes "github.com/CosmWasm/wasmvm/types" - "github.com/cybercongress/go-cyber/x/graph/keeper" - "github.com/cybercongress/go-cyber/x/graph/types" + "github.com/deep-foundation/deep-chain/x/graph/keeper" + "github.com/deep-foundation/deep-chain/x/graph/types" ) var ( diff --git a/x/grid/client/cli/query.go b/x/grid/client/cli/query.go index cc943ce..42b7404 100644 --- a/x/grid/client/cli/query.go +++ b/x/grid/client/cli/query.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cybercongress/go-cyber/x/grid/types" + "github.com/deep-foundation/deep-chain/x/grid/types" ) func GetQueryCmd() *cobra.Command { diff --git a/x/grid/client/cli/tx.go b/x/grid/client/cli/tx.go index 5b5ef25..b7ca69d 100644 --- a/x/grid/client/cli/tx.go +++ b/x/grid/client/cli/tx.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cybercongress/go-cyber/x/grid/types" + "github.com/deep-foundation/deep-chain/x/grid/types" ) // GetTxCmd returns the transaction commands for this module diff --git a/x/grid/client/rest/query.go b/x/grid/client/rest/query.go index 549bb77..51aa4a8 100644 --- a/x/grid/client/rest/query.go +++ b/x/grid/client/rest/query.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/types/rest" - "github.com/cybercongress/go-cyber/x/grid/types" + "github.com/deep-foundation/deep-chain/x/grid/types" ) // RegisterRoutes defines routes that get registered by the main application. diff --git a/x/grid/keeper/genesis.go b/x/grid/keeper/genesis.go index 76c5f67..d976195 100644 --- a/x/grid/keeper/genesis.go +++ b/x/grid/keeper/genesis.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/x/grid/types" + "github.com/deep-foundation/deep-chain/x/grid/types" ) func InitGenesis(ctx sdk.Context, k Keeper, data types.GenesisState) { diff --git a/x/grid/keeper/grpc_query.go b/x/grid/keeper/grpc_query.go index 4e24c39..43fd391 100644 --- a/x/grid/keeper/grpc_query.go +++ b/x/grid/keeper/grpc_query.go @@ -9,7 +9,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/cybercongress/go-cyber/x/grid/types" + "github.com/deep-foundation/deep-chain/x/grid/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/grid/keeper/keeper.go b/x/grid/keeper/keeper.go index 6767ce6..da18ae9 100644 --- a/x/grid/keeper/keeper.go +++ b/x/grid/keeper/keeper.go @@ -7,13 +7,13 @@ import ( paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/tendermint/tendermint/libs/log" - ctypes "github.com/cybercongress/go-cyber/types" + ctypes "github.com/deep-foundation/deep-chain/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/x/grid/exported" - "github.com/cybercongress/go-cyber/x/grid/types" + "github.com/deep-foundation/deep-chain/x/grid/exported" + "github.com/deep-foundation/deep-chain/x/grid/types" ) var _ = exported.EnergyKeeper(nil) diff --git a/x/grid/keeper/msg_server.go b/x/grid/keeper/msg_server.go index bf24820..76ac112 100644 --- a/x/grid/keeper/msg_server.go +++ b/x/grid/keeper/msg_server.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/x/grid/types" + "github.com/deep-foundation/deep-chain/x/grid/types" ) type msgServer struct { diff --git a/x/grid/keeper/querier.go b/x/grid/keeper/querier.go index 45946ec..0ca25ea 100644 --- a/x/grid/keeper/querier.go +++ b/x/grid/keeper/querier.go @@ -7,7 +7,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" abci "github.com/tendermint/tendermint/abci/types" - "github.com/cybercongress/go-cyber/x/grid/types" + "github.com/deep-foundation/deep-chain/x/grid/types" ) func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { diff --git a/x/grid/module.go b/x/grid/module.go index ff8f828..98a1346 100644 --- a/x/grid/module.go +++ b/x/grid/module.go @@ -17,10 +17,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cybercongress/go-cyber/x/grid/client/cli" - "github.com/cybercongress/go-cyber/x/grid/client/rest" - "github.com/cybercongress/go-cyber/x/grid/keeper" - "github.com/cybercongress/go-cyber/x/grid/types" + "github.com/deep-foundation/deep-chain/x/grid/client/cli" + "github.com/deep-foundation/deep-chain/x/grid/client/rest" + "github.com/deep-foundation/deep-chain/x/grid/keeper" + "github.com/deep-foundation/deep-chain/x/grid/types" ) var ( diff --git a/x/grid/types/msgs.go b/x/grid/types/msgs.go index a78584f..ed6f352 100644 --- a/x/grid/types/msgs.go +++ b/x/grid/types/msgs.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - ctypes "github.com/cybercongress/go-cyber/types" + ctypes "github.com/deep-foundation/deep-chain/types" ) const ( diff --git a/x/grid/wasm/interface.go b/x/grid/wasm/interface.go index 1e45938..16312fe 100644 --- a/x/grid/wasm/interface.go +++ b/x/grid/wasm/interface.go @@ -9,9 +9,9 @@ import ( wasmvmtypes "github.com/CosmWasm/wasmvm/types" - wasmplugins "github.com/cybercongress/go-cyber/plugins" - "github.com/cybercongress/go-cyber/x/grid/keeper" - "github.com/cybercongress/go-cyber/x/grid/types" + wasmplugins "github.com/deep-foundation/deep-chain/plugins" + "github.com/deep-foundation/deep-chain/x/grid/keeper" + "github.com/deep-foundation/deep-chain/x/grid/types" ) var _ MsgParserInterface = MsgParser{} diff --git a/x/rank/abci.go b/x/rank/abci.go index 03c426f..c55e4ed 100644 --- a/x/rank/abci.go +++ b/x/rank/abci.go @@ -3,7 +3,7 @@ package rank import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/x/rank/keeper" + "github.com/deep-foundation/deep-chain/x/rank/keeper" ) func EndBlocker(ctx sdk.Context, k *keeper.StateKeeper) { diff --git a/x/rank/client/cli/query.go b/x/rank/client/cli/query.go index d6edbca..c56e393 100644 --- a/x/rank/client/cli/query.go +++ b/x/rank/client/cli/query.go @@ -10,10 +10,10 @@ import ( "github.com/ipfs/go-cid" "github.com/spf13/cobra" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" + graphtypes "github.com/deep-foundation/deep-chain/x/graph/types" - "github.com/cybercongress/go-cyber/types/query" - "github.com/cybercongress/go-cyber/x/rank/types" + "github.com/deep-foundation/deep-chain/types/query" + "github.com/deep-foundation/deep-chain/x/rank/types" ) func GetQueryCmd() *cobra.Command { diff --git a/x/rank/client/rest/query.go b/x/rank/client/rest/query.go index 7606d07..13b1cec 100644 --- a/x/rank/client/rest/query.go +++ b/x/rank/client/rest/query.go @@ -12,7 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/rest" - "github.com/cybercongress/go-cyber/x/rank/types" + "github.com/deep-foundation/deep-chain/x/rank/types" ) func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { diff --git a/x/rank/keeper/calculate.go b/x/rank/keeper/calculate.go index d269b96..e427467 100644 --- a/x/rank/keeper/calculate.go +++ b/x/rank/keeper/calculate.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" - "github.com/cybercongress/go-cyber/x/rank/types" + "github.com/deep-foundation/deep-chain/x/rank/types" "github.com/tendermint/tendermint/libs/log" ) diff --git a/x/rank/keeper/calculate_cpu.go b/x/rank/keeper/calculate_cpu.go index 49567bf..953d61e 100755 --- a/x/rank/keeper/calculate_cpu.go +++ b/x/rank/keeper/calculate_cpu.go @@ -3,8 +3,8 @@ package keeper import ( "math" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" - "github.com/cybercongress/go-cyber/x/rank/types" + graphtypes "github.com/deep-foundation/deep-chain/x/graph/types" + "github.com/deep-foundation/deep-chain/x/rank/types" ) func calculateRankCPU(ctx *types.CalculationContext) types.EMState { diff --git a/x/rank/keeper/calculate_gpu.go b/x/rank/keeper/calculate_gpu.go index d0a7c8d..00408cb 100755 --- a/x/rank/keeper/calculate_gpu.go +++ b/x/rank/keeper/calculate_gpu.go @@ -8,8 +8,8 @@ import ( "github.com/tendermint/tendermint/libs/log" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" - "github.com/cybercongress/go-cyber/x/rank/types" + graphtypes "github.com/deep-foundation/deep-chain/x/graph/types" + "github.com/deep-foundation/deep-chain/x/rank/types" ) /* diff --git a/x/rank/keeper/calculate_gpu_nop.go b/x/rank/keeper/calculate_gpu_nop.go index 203965d..4025988 100644 --- a/x/rank/keeper/calculate_gpu_nop.go +++ b/x/rank/keeper/calculate_gpu_nop.go @@ -4,7 +4,7 @@ package keeper import ( - "github.com/cybercongress/go-cyber/x/rank/types" + "github.com/deep-foundation/deep-chain/x/rank/types" "github.com/tendermint/tendermint/libs/log" ) diff --git a/x/rank/keeper/genesis.go b/x/rank/keeper/genesis.go index e446441..bba557a 100644 --- a/x/rank/keeper/genesis.go +++ b/x/rank/keeper/genesis.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/x/rank/types" + "github.com/deep-foundation/deep-chain/x/rank/types" ) func InitGenesis(ctx sdk.Context, keeper StateKeeper, data types.GenesisState) { diff --git a/x/rank/keeper/grpc_query.go b/x/rank/keeper/grpc_query.go index c054296..36bd53f 100644 --- a/x/rank/keeper/grpc_query.go +++ b/x/rank/keeper/grpc_query.go @@ -8,9 +8,9 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - querytypes "github.com/cybercongress/go-cyber/types/query" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" - "github.com/cybercongress/go-cyber/x/rank/types" + querytypes "github.com/deep-foundation/deep-chain/types/query" + graphtypes "github.com/deep-foundation/deep-chain/x/graph/types" + "github.com/deep-foundation/deep-chain/x/rank/types" ) var _ types.QueryServer = &StateKeeper{} diff --git a/x/rank/keeper/keeper.go b/x/rank/keeper/keeper.go index b8f05bd..61a129e 100644 --- a/x/rank/keeper/keeper.go +++ b/x/rank/keeper/keeper.go @@ -12,10 +12,10 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/keeper" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/cybercongress/go-cyber/merkle" - graphkeeper "github.com/cybercongress/go-cyber/x/graph/keeper" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" - "github.com/cybercongress/go-cyber/x/rank/types" + "github.com/deep-foundation/deep-chain/merkle" + graphkeeper "github.com/deep-foundation/deep-chain/x/graph/keeper" + graphtypes "github.com/deep-foundation/deep-chain/x/graph/types" + "github.com/deep-foundation/deep-chain/x/rank/types" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/rank/keeper/querier.go b/x/rank/keeper/querier.go index 7d27f7a..61eb8e4 100644 --- a/x/rank/keeper/querier.go +++ b/x/rank/keeper/querier.go @@ -4,9 +4,9 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" abci "github.com/tendermint/tendermint/abci/types" - querytypes "github.com/cybercongress/go-cyber/types/query" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" - "github.com/cybercongress/go-cyber/x/rank/types" + querytypes "github.com/deep-foundation/deep-chain/types/query" + graphtypes "github.com/deep-foundation/deep-chain/x/graph/types" + "github.com/deep-foundation/deep-chain/x/rank/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/rank/module.go b/x/rank/module.go index 4bf02a5..f94d5d8 100644 --- a/x/rank/module.go +++ b/x/rank/module.go @@ -16,11 +16,11 @@ import ( "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" - "github.com/cybercongress/go-cyber/x/rank/client/cli" - "github.com/cybercongress/go-cyber/x/rank/client/rest" + "github.com/deep-foundation/deep-chain/x/rank/client/cli" + "github.com/deep-foundation/deep-chain/x/rank/client/rest" - "github.com/cybercongress/go-cyber/x/rank/keeper" - "github.com/cybercongress/go-cyber/x/rank/types" + "github.com/deep-foundation/deep-chain/x/rank/keeper" + "github.com/deep-foundation/deep-chain/x/rank/types" ) var ( diff --git a/x/rank/types/context.go b/x/rank/types/context.go index e2d2488..01757a2 100644 --- a/x/rank/types/context.go +++ b/x/rank/types/context.go @@ -3,7 +3,7 @@ package types import ( "sort" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" + graphtypes "github.com/deep-foundation/deep-chain/x/graph/types" ) type CalculationContext struct { diff --git a/x/rank/types/expected_keepers.go b/x/rank/types/expected_keepers.go index c8b9fe4..64eb76b 100644 --- a/x/rank/types/expected_keepers.go +++ b/x/rank/types/expected_keepers.go @@ -3,7 +3,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" + graphtypes "github.com/deep-foundation/deep-chain/x/graph/types" ) type StakeKeeper interface { diff --git a/x/rank/types/index.go b/x/rank/types/index.go index 930ec3a..190f479 100644 --- a/x/rank/types/index.go +++ b/x/rank/types/index.go @@ -7,7 +7,7 @@ import ( "github.com/tendermint/tendermint/libs/log" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" + graphtypes "github.com/deep-foundation/deep-chain/x/graph/types" ) type BaseSearchIndex struct { diff --git a/x/rank/types/index_types.go b/x/rank/types/index_types.go index d878254..4b4b273 100644 --- a/x/rank/types/index_types.go +++ b/x/rank/types/index_types.go @@ -3,7 +3,7 @@ package types import ( "errors" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" + graphtypes "github.com/deep-foundation/deep-chain/x/graph/types" ) type RankedCidNumber struct { diff --git a/x/rank/types/query.pb.go b/x/rank/types/query.pb.go index 2cf5164..55eac56 100644 --- a/x/rank/types/query.pb.go +++ b/x/rank/types/query.pb.go @@ -18,7 +18,7 @@ import ( codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - query "github.com/cybercongress/go-cyber/types/query" + query "github.com/deep-foundation/deep-chain/types/query" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/rank/types/query.pb.gw.go b/x/rank/types/query.pb.gw.go index 56b9580..8e1ce54 100644 --- a/x/rank/types/query.pb.gw.go +++ b/x/rank/types/query.pb.gw.go @@ -22,7 +22,7 @@ import ( "google.golang.org/grpc/grpclog" "google.golang.org/grpc/status" - "github.com/cybercongress/go-cyber/types/query" + "github.com/deep-foundation/deep-chain/types/query" ) // Suppress "imported and not used" errors diff --git a/x/rank/types/rank.go b/x/rank/types/rank.go index 6e24fab..2cae00b 100644 --- a/x/rank/types/rank.go +++ b/x/rank/types/rank.go @@ -6,8 +6,8 @@ import ( "sort" "time" - "github.com/cybercongress/go-cyber/merkle" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" + "github.com/deep-foundation/deep-chain/merkle" + graphtypes "github.com/deep-foundation/deep-chain/x/graph/types" "github.com/tendermint/tendermint/libs/log" ) diff --git a/x/rank/wasm/interface.go b/x/rank/wasm/interface.go index e55774b..0d9ef20 100644 --- a/x/rank/wasm/interface.go +++ b/x/rank/wasm/interface.go @@ -10,9 +10,9 @@ import ( wasmvmtypes "github.com/CosmWasm/wasmvm/types" - graphtypes "github.com/cybercongress/go-cyber/x/graph/types" + graphtypes "github.com/deep-foundation/deep-chain/x/graph/types" - "github.com/cybercongress/go-cyber/x/rank/keeper" + "github.com/deep-foundation/deep-chain/x/rank/keeper" ) type QuerierInterface interface { diff --git a/x/resources/client/cli/query.go b/x/resources/client/cli/query.go index edf6eca..52fd518 100644 --- a/x/resources/client/cli/query.go +++ b/x/resources/client/cli/query.go @@ -10,8 +10,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/cobra" - ctypes "github.com/cybercongress/go-cyber/types" - "github.com/cybercongress/go-cyber/x/resources/types" + ctypes "github.com/deep-foundation/deep-chain/types" + "github.com/deep-foundation/deep-chain/x/resources/types" ) func GetQueryCmd() *cobra.Command { diff --git a/x/resources/client/cli/tx.go b/x/resources/client/cli/tx.go index 8330316..6a1f541 100644 --- a/x/resources/client/cli/tx.go +++ b/x/resources/client/cli/tx.go @@ -13,8 +13,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" - ctypes "github.com/cybercongress/go-cyber/types" - "github.com/cybercongress/go-cyber/x/resources/types" + ctypes "github.com/deep-foundation/deep-chain/types" + "github.com/deep-foundation/deep-chain/x/resources/types" ) func NewTxCmd() *cobra.Command { diff --git a/x/resources/client/rest/query.go b/x/resources/client/rest/query.go index b39d692..02c7f55 100644 --- a/x/resources/client/rest/query.go +++ b/x/resources/client/rest/query.go @@ -9,12 +9,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/gorilla/mux" - ctypes "github.com/cybercongress/go-cyber/types" + ctypes "github.com/deep-foundation/deep-chain/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/types/rest" - "github.com/cybercongress/go-cyber/x/resources/types" + "github.com/deep-foundation/deep-chain/x/resources/types" ) func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { diff --git a/x/resources/keeper/genesis.go b/x/resources/keeper/genesis.go index 72c8c47..5e83023 100644 --- a/x/resources/keeper/genesis.go +++ b/x/resources/keeper/genesis.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/x/resources/types" + "github.com/deep-foundation/deep-chain/x/resources/types" ) func InitGenesis(ctx sdk.Context, k Keeper, data types.GenesisState) { diff --git a/x/resources/keeper/grpc_query.go b/x/resources/keeper/grpc_query.go index cd0ebe8..cfbe128 100644 --- a/x/resources/keeper/grpc_query.go +++ b/x/resources/keeper/grpc_query.go @@ -8,9 +8,9 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - ctypes "github.com/cybercongress/go-cyber/types" + ctypes "github.com/deep-foundation/deep-chain/types" - "github.com/cybercongress/go-cyber/x/resources/types" + "github.com/deep-foundation/deep-chain/x/resources/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/resources/keeper/keeper.go b/x/resources/keeper/keeper.go index 69c9627..7914eff 100644 --- a/x/resources/keeper/keeper.go +++ b/x/resources/keeper/keeper.go @@ -13,9 +13,9 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/tendermint/tendermint/libs/log" - ctypes "github.com/cybercongress/go-cyber/types" - bandwithkeeper "github.com/cybercongress/go-cyber/x/bandwidth/keeper" - "github.com/cybercongress/go-cyber/x/resources/types" + ctypes "github.com/deep-foundation/deep-chain/types" + bandwithkeeper "github.com/deep-foundation/deep-chain/x/bandwidth/keeper" + "github.com/deep-foundation/deep-chain/x/resources/types" ) type Keeper struct { diff --git a/x/resources/keeper/msg_server.go b/x/resources/keeper/msg_server.go index 7abf9e3..048f35c 100644 --- a/x/resources/keeper/msg_server.go +++ b/x/resources/keeper/msg_server.go @@ -8,11 +8,11 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - ctypes "github.com/cybercongress/go-cyber/types" + ctypes "github.com/deep-foundation/deep-chain/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cybercongress/go-cyber/x/resources/types" + "github.com/deep-foundation/deep-chain/x/resources/types" ) type msgServer struct { diff --git a/x/resources/keeper/querier.go b/x/resources/keeper/querier.go index fedda23..72d89c1 100644 --- a/x/resources/keeper/querier.go +++ b/x/resources/keeper/querier.go @@ -6,9 +6,9 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" abci "github.com/tendermint/tendermint/abci/types" - ctypes "github.com/cybercongress/go-cyber/types" + ctypes "github.com/deep-foundation/deep-chain/types" - "github.com/cybercongress/go-cyber/x/resources/types" + "github.com/deep-foundation/deep-chain/x/resources/types" ) func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { diff --git a/x/resources/module.go b/x/resources/module.go index 58cec71..1540ca7 100644 --- a/x/resources/module.go +++ b/x/resources/module.go @@ -16,10 +16,10 @@ import ( "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" - "github.com/cybercongress/go-cyber/x/resources/client/cli" - "github.com/cybercongress/go-cyber/x/resources/client/rest" - "github.com/cybercongress/go-cyber/x/resources/keeper" - "github.com/cybercongress/go-cyber/x/resources/types" + "github.com/deep-foundation/deep-chain/x/resources/client/cli" + "github.com/deep-foundation/deep-chain/x/resources/client/rest" + "github.com/deep-foundation/deep-chain/x/resources/keeper" + "github.com/deep-foundation/deep-chain/x/resources/types" ) var ( diff --git a/x/resources/types/msgs.go b/x/resources/types/msgs.go index d3ebc9e..d22d707 100644 --- a/x/resources/types/msgs.go +++ b/x/resources/types/msgs.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - ctypes "github.com/cybercongress/go-cyber/types" + ctypes "github.com/deep-foundation/deep-chain/types" ) const ( diff --git a/x/resources/types/params.go b/x/resources/types/params.go index f52315a..64c350a 100644 --- a/x/resources/types/params.go +++ b/x/resources/types/params.go @@ -7,7 +7,7 @@ import ( paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - ctypes "github.com/cybercongress/go-cyber/types" + ctypes "github.com/deep-foundation/deep-chain/types" ) const ( diff --git a/x/resources/wasm/interface.go b/x/resources/wasm/interface.go index 7089d47..c7a372c 100644 --- a/x/resources/wasm/interface.go +++ b/x/resources/wasm/interface.go @@ -9,7 +9,7 @@ import ( wasmvmtypes "github.com/CosmWasm/wasmvm/types" - "github.com/cybercongress/go-cyber/x/resources/types" + "github.com/deep-foundation/deep-chain/x/resources/types" ) var _ MsgParserInterface = MsgParser{} diff --git a/x/staking/msg_server.go b/x/staking/msg_server.go index f520fe1..af456d3 100644 --- a/x/staking/msg_server.go +++ b/x/staking/msg_server.go @@ -14,8 +14,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking/types" tmstrings "github.com/tendermint/tendermint/libs/strings" - ctypes "github.com/cybercongress/go-cyber/types" - resourcestypes "github.com/cybercongress/go-cyber/x/resources/types" + ctypes "github.com/deep-foundation/deep-chain/types" + resourcestypes "github.com/deep-foundation/deep-chain/x/resources/types" ) type msgServer struct { From 9ee4298730f656248daedfd2fc75e212f497b85d Mon Sep 17 00:00:00 2001 From: C H Date: Tue, 16 Jan 2024 16:52:11 +0300 Subject: [PATCH 5/7] Refactoring of namings --- .circleci/config.yml | 2 +- .goreleaser.yml | 2 +- Makefile | 6 ++--- app/app.go | 2 +- cmd/{cyber => deepchain}/cmd/genaccounts.go | 0 cmd/{cyber => deepchain}/cmd/root.go | 0 cmd/{cyber => deepchain}/cmd/testnet.go | 4 +-- cmd/{cyber => deepchain}/main.go | 2 +- cmd/iavltool/cmd/root.go | 4 +-- contrib/Dockerfile | 6 ++--- contrib/links-load.sh | 2 +- contrib/single-node.sh | 2 +- docker-compose.yml | 16 ++++++------ networks/local/Makefile | 2 +- networks/local/cybernode/wrapper.sh | 4 +-- scripts/install_cyber.sh | 28 ++++++++++----------- 16 files changed, 41 insertions(+), 41 deletions(-) rename cmd/{cyber => deepchain}/cmd/genaccounts.go (100%) rename cmd/{cyber => deepchain}/cmd/root.go (100%) rename cmd/{cyber => deepchain}/cmd/testnet.go (98%) rename cmd/{cyber => deepchain}/main.go (86%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4b0fe0f..4653ba9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -69,7 +69,7 @@ jobs: cd ~/workdir git clone -q --depth 1 https://${DOCS_GITHUB_TOKEN}@github.com/cybercongress/congress.git - deploy: - name: Update docs from go-cyber repo + name: Update docs from deepchain repo working_directory: ~/workdir/congress command: | # We need to remove current files in folder to avoid duplicating renamed files diff --git a/.goreleaser.yml b/.goreleaser.yml index a459523..8f991b5 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -37,7 +37,7 @@ nfpm: description: Distributed search engine maintainer: Cyber Admin license: MIT - vendor: cyber.Congress + vendor: deepchain formats: - deb - rpm diff --git a/Makefile b/Makefile index a429a65..4bafeff 100644 --- a/Makefile +++ b/Makefile @@ -86,9 +86,9 @@ build: go.sum build-linux: go.sum LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build # mkdir -p ./build -# docker build --tag cybercongress/cyber ./ -# docker create --name temp cybercongress/cyber:latest -# docker cp temp:/usr/bin/cyber ./build/ +# docker build --tag cybercongress/deepchain ./ +# docker create --name temp cybercongress/deepchain:latest +# docker cp temp:/usr/bin/deepchain ./build/ # docker rm temp install: go.sum diff --git a/app/app.go b/app/app.go index 4c1bcb0..f89677d 100644 --- a/app/app.go +++ b/app/app.go @@ -165,7 +165,7 @@ var ( ) // GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to -// produce a list of enabled proposals to pass into cyber app. +// produce a list of enabled proposals to pass into deepchain app. func GetEnabledProposals() []wasm.ProposalType { if EnableSpecificProposals == "" { if ProposalsEnabled == "true" { diff --git a/cmd/cyber/cmd/genaccounts.go b/cmd/deepchain/cmd/genaccounts.go similarity index 100% rename from cmd/cyber/cmd/genaccounts.go rename to cmd/deepchain/cmd/genaccounts.go diff --git a/cmd/cyber/cmd/root.go b/cmd/deepchain/cmd/root.go similarity index 100% rename from cmd/cyber/cmd/root.go rename to cmd/deepchain/cmd/root.go diff --git a/cmd/cyber/cmd/testnet.go b/cmd/deepchain/cmd/testnet.go similarity index 98% rename from cmd/cyber/cmd/testnet.go rename to cmd/deepchain/cmd/testnet.go index f45fcfe..73e4722 100644 --- a/cmd/cyber/cmd/testnet.go +++ b/cmd/deepchain/cmd/testnet.go @@ -55,7 +55,7 @@ necessary files (private validator, genesis, config, etc.). Note, strict routability for addresses is turned off in the config file. Example: - cyber testnet --v 4 --output-dir ./output --starting-ip-address 192.168.10.2 + deepchain testnet --v 4 --output-dir ./output --starting-ip-address 192.168.10.2 `, RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) @@ -85,7 +85,7 @@ Example: cmd.Flags().Int(flagNumValidators, 4, "Number of validators to initialize the testnet with") cmd.Flags().StringP(flagOutputDir, "o", "./mytestnet", "Directory to store initialization data for the testnet") cmd.Flags().String(flagNodeDirPrefix, "node", "Prefix the directory name for each node with (node results in node0, node1, ...)") - cmd.Flags().String(flagNodeDaemonHome, "cyber", "Home directory of the node's daemon configuration") + cmd.Flags().String(flagNodeDaemonHome, "deepchain", "Home directory of the node's daemon configuration") cmd.Flags().String(flagStartingIPAddress, "192.168.0.1", "Starting IP address (192.168.0.1 results in persistent peers list ID0@192.168.0.1:46656, ID1@192.168.0.2:46656, ...)") cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") cmd.Flags().String(server.FlagMinGasPrices, fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), "Minimum gas prices to accept for transactions; All fees in a tx must meet this minimum (e.g. 0.01photino,0.001stake)") diff --git a/cmd/cyber/main.go b/cmd/deepchain/main.go similarity index 86% rename from cmd/cyber/main.go rename to cmd/deepchain/main.go index 1306560..3b29a3d 100644 --- a/cmd/cyber/main.go +++ b/cmd/deepchain/main.go @@ -7,7 +7,7 @@ import ( svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" "github.com/deep-foundation/deep-chain/app" - "github.com/deep-foundation/deep-chain/cmd/cyber/cmd" + "github.com/deep-foundation/deep-chain/cmd/deepchain/cmd" ) func main() { diff --git a/cmd/iavltool/cmd/root.go b/cmd/iavltool/cmd/root.go index a1d263d..09d6c7a 100644 --- a/cmd/iavltool/cmd/root.go +++ b/cmd/iavltool/cmd/root.go @@ -22,7 +22,7 @@ const ( ) var ( - DefaultHome = os.ExpandEnv("$HOME/") + ".cyber/data" + DefaultHome = os.ExpandEnv("$HOME/") + ".deepchain/data" rootCmd = &cobra.Command{Use: "iavltool"} home string ) @@ -57,7 +57,7 @@ func Execute() error { } func init() { - rootCmd.PersistentFlags().StringVar(&home, "home", DefaultHome, "path to cyber data") + rootCmd.PersistentFlags().StringVar(&home, "home", DefaultHome, "path to deepchain data") rootCmd.AddCommand(dataCmd) rootCmd.AddCommand(shapeCmd) rootCmd.AddCommand(versionsCmd) diff --git a/contrib/Dockerfile b/contrib/Dockerfile index 64deb32..2fc0fd0 100644 --- a/contrib/Dockerfile +++ b/contrib/Dockerfile @@ -1,7 +1,7 @@ # Simple usage with a mounted data directory: -# > docker build -t cyber . -# > docker run -it -p 46657:46657 -p 46656:46656 -v ~/.cyber:/root/.cyber -v ~/.cybercli:/root/.cybercli cyber cyber init -# > docker run -it -p 46657:46657 -p 46656:46656 -v ~/.cyber:/root/.cyber -v ~/.cybercli:/root/.cybercli cyber cyber start +# > docker build -t deepchain . +# > docker run -it -p 46657:46657 -p 46656:46656 -v ~/.deepchain:/root/.deepchain -v ~/.cybercli:/root/.cybercli deepchain deepchain init +# > docker run -it -p 46657:46657 -p 46656:46656 -v ~/.deepchain:/root/.deepchain -v ~/.cybercli:/root/.cybercli deepchain deepchain start FROM golang:1.16-alpine3.13 AS build-env # Set up dependencies diff --git a/contrib/links-load.sh b/contrib/links-load.sh index ab73f5d..641f390 100755 --- a/contrib/links-load.sh +++ b/contrib/links-load.sh @@ -33,7 +33,7 @@ if [ -z "$5" ]; then fi #MNEMONIC="" -#echo $MNEMONIC | cyber keys add $ADDR --recover --keyring-backend test +#echo $MNEMONIC | deepchain keys add $ADDR --recover --keyring-backend test while [ ${CNT} -lt $ITER ]; do curr_block=$(curl -s $NODEADDR:26657/status | jq -r '.result.sync_info.latest_block_height') diff --git a/contrib/single-node.sh b/contrib/single-node.sh index 203dad0..0df21d2 100755 --- a/contrib/single-node.sh +++ b/contrib/single-node.sh @@ -15,7 +15,7 @@ if [ -z "$2" ]; then exit 1 fi -# validator and dev accounts should be added to .cyber dir in user's root with keyring-backend test +# validator and dev accounts should be added to .deepchain dir in user's root with keyring-backend test coins="1000000000000boot" cyber init --chain-id "$CHAINID" "$CHAINID" --home "$HMDIR" sed -i '' 's#"stake"#"boot"#g' "$HMDIR"/config/genesis.json diff --git a/docker-compose.yml b/docker-compose.yml index 8c1e70e..eec52d8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,9 +9,9 @@ services: - "1317:1317" environment: - ID=0 - - LOG=${LOG:-cyber.log} + - LOG=${LOG:-deepchain.log} volumes: - - ./build:/cyber:Z + - ./build:/deepchain:Z networks: localnet: ipv4_address: 192.168.10.2 @@ -23,9 +23,9 @@ services: - "26659-26660:26656-26657" environment: - ID=1 - - LOG=${LOG:-cyber.log} + - LOG=${LOG:-deepchain.log} volumes: - - ./build:/cyber:Z + - ./build:/deepchain:Z networks: localnet: ipv4_address: 192.168.10.3 @@ -35,11 +35,11 @@ services: image: "cybercongress/cyber" environment: - ID=2 - - LOG=${LOG:-cyber.log} + - LOG=${LOG:-deepchain.log} ports: - "26661-26662:26656-26657" volumes: - - ./build:/cyber:Z + - ./build:/deepchain:Z networks: localnet: ipv4_address: 192.168.10.4 @@ -49,11 +49,11 @@ services: image: "cybercongress/cyber" environment: - ID=3 - - LOG=${LOG:-cyber.log} + - LOG=${LOG:-deepchain.log} ports: - "26663-26664:26656-26657" volumes: - - ./build:/cyber:Z + - ./build:/deepchain:Z networks: localnet: ipv4_address: 192.168.10.5 diff --git a/networks/local/Makefile b/networks/local/Makefile index bdef749..2cc39cc 100644 --- a/networks/local/Makefile +++ b/networks/local/Makefile @@ -1,4 +1,4 @@ -# Makefile for the "cyber" docker image. +# Makefile for the "deepchain" docker image. all: docker build --tag cybercongress/cyber cybernode diff --git a/networks/local/cybernode/wrapper.sh b/networks/local/cybernode/wrapper.sh index 0e9828e..af2a025 100755 --- a/networks/local/cybernode/wrapper.sh +++ b/networks/local/cybernode/wrapper.sh @@ -3,9 +3,9 @@ ## ## Input parameters ## -BINARY=/cyber/${BINARY:-cyber} +BINARY=/deepchain/${BINARY:-deepchain} ID=${ID:-0} -LOG=${LOG:-cyber.log} +LOG=${LOG:-deepchain.log} ## ## Assert linux binary diff --git a/scripts/install_cyber.sh b/scripts/install_cyber.sh index 76fa379..a2e6a8a 100755 --- a/scripts/install_cyber.sh +++ b/scripts/install_cyber.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Installation script for cyber. It tries to move $bin in one of the +# Installation script for deepchain. It tries to move $bin in one of the # directories stored in $binpaths. binpaths="/usr/local/bin /usr/bin" @@ -10,15 +10,15 @@ libpaths="/usr/lib /usr/local/lib" # because of missing write permissions. is_write_perm_missing="" -# Download archive with cyber binaries according to platform type +# Download archive with deepchain binaries according to platform type PLATFORM=$(uname) case "$PLATFORM" in "Darwin") # macOS - curl -OL https://github.com/cybercongress/go-cyber/releases/download/v0.2.0/cyber_v0.2.0_darwin-amd64.tar.gz - tar -xzf cyber_v0.2.0_darwin-amd64.tar.gz + curl -OL https://github.com/deep-foundaiton/deep-chain/releases/download/v0.2.0/deep_chain_v0.2.0_darwin-amd64.tar.gz + tar -xzf deep_chain_v0.2.0_darwin-amd64.tar.gz for binpath in $binpaths; do - if cp build_v0.2.0_darwin_amd64/cyber "$binpath"; then + if cp build_v0.2.0_darwin_amd64/deepchain "$binpath"; then for libpath in $libpaths; do if cp build_v0.2.0_darwin_amd64/libwasmvm.dylib "$libpath"; then cp build_v0.2.0_darwin_amd64/libwasmvm.so "$libpath" @@ -31,14 +31,14 @@ case "$PLATFORM" in fi done echo "Moved $bin to $binpath" - echo "Enjoy your cyber experience!" - rm cyber_v0.2.0_darwin-amd64.tar.gz + echo "Enjoy your deepchain experience!" + rm deep_chain_v0.2.0_darwin-amd64.tar.gz rm -rf build_v0.2.0_darwin_amd64 exit 0 else if [ -d "$binpath" ] && [ ! -w "$binpath" ]; then is_write_perm_missing=1 - rm cyber_v0.2.0_darwin-amd64.tar.gz + rm deep_chain_v0.2.0_darwin-amd64.tar.gz rm -rf build_v0.2.0_darwin_amd64 fi fi @@ -46,10 +46,10 @@ case "$PLATFORM" in ;; "Linux") # Linux distro, - curl -OL https://github.com/cybercongress/go-cyber/releases/download/v0.2.0/cyber_v0.2.0_linux-amd64.tar.gz - tar -xzf cyber_v0.2.0_linux-amd64.tar.gz -C ./ + curl -OL https://github.com/deep-foundaiton/deep-chain/releases/download/v0.2.0/deep-chain_v0.2.0_linux-amd64.tar.gz + tar -xzf deep_chain_v0.2.0_linux-amd64.tar.gz -C ./ for binpath in $binpaths; do - if cp build_v0.2.0_linux_amd64/cyber "$binpath"; then + if cp build_v0.2.0_linux_amd64/deepchain "$binpath"; then for libpath in $libpaths; do if cp build_v0.2.0_linux_amd64/libwasmvm.dylib "$libpath"; then cp build_v0.2.0_linux_amd64/libwasmvm.so "$libpath" @@ -62,14 +62,14 @@ case "$PLATFORM" in fi done echo "Moved $bin to $binpath" - echo "Enjoy your cyber experience!" - rm cyber_v0.2.0_linux-amd64.tar.gz + echo "Enjoy your deepchain experience!" + rm deep_chain_v0.2.0_linux-amd64.tar.gz rm -rf build_v0.2.0_linux_amd64 exit 0 else if [ -d "$binpath" ] && [ ! -w "$binpath" ]; then is_write_perm_missing=1 - rm cyber_v0.2.0_linux-amd64.tar.gz + rm deep_chain_v0.2.0_linux-amd64.tar.gz rm -rf build_v0.2.0_linux_amd64 fi fi From c2d586658e773ffa545af11c2505f9487a4d137a Mon Sep 17 00:00:00 2001 From: C H Date: Tue, 16 Jan 2024 17:11:10 +0300 Subject: [PATCH 6/7] Increase supported wasm builds size --- app/app.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index f89677d..7782195 100644 --- a/app/app.go +++ b/app/app.go @@ -2,6 +2,7 @@ package app import ( "fmt" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" "io" "net/http" "os" @@ -164,6 +165,10 @@ var ( EnableSpecificProposals = "" ) +func overrideWasmVariables() { + wasmtypes.MaxWasmSize = 2 * 1024 * 1024 +} + // GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to // produce a list of enabled proposals to pass into deepchain app. func GetEnabledProposals() []wasm.ProposalType { @@ -331,7 +336,7 @@ func NewApp( // TODO clean // config := sdk.NewConfig() // config.Seal() - + overrideWasmVariables() appCodec, legacyAmino := encodingConfig.Marshaler, encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry From 0f619aaf5d03e0804f709b0a354dea64e8dc37e2 Mon Sep 17 00:00:00 2001 From: C H Date: Tue, 16 Jan 2024 17:12:54 +0300 Subject: [PATCH 7/7] Updated README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 709d7fd..afa2f1f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +# DEEPCHAIN +# DEEP CYBER HACKATHON January 2024 + + # Semantic non-deterministic Superintelligence consensus computer # Cyber - SuperIntelligence for The Great Web