Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dead code across packages #73

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions assetlists/assetlists.go

This file was deleted.

13 changes: 0 additions & 13 deletions assetlists/types.go

This file was deleted.

3 changes: 0 additions & 3 deletions cmd/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,6 @@ func setupIndex(cmd *cobra.Command, args []string) error {
func setupIndexer() *Indexer {
var err error

// Setup chain specific stuff
core.ChainSpecificMessageTypeHandlerBootstrap(indexer.cfg.Probe.ChainID)

config.SetChainConfig(indexer.cfg.Probe.AccountPrefix)

indexer.cl = probe.GetProbeClient(indexer.cfg.Probe)
Expand Down
20 changes: 0 additions & 20 deletions config/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ type Logger struct{}
// Log is exposed on the config as a drop-in replacement for our old logger
var Log *Logger

func (l *Logger) ZDeubg() *zerolog.Event {
return zlog.Debug()
}

// These functions are provided to reduce refactoring.
func (l *Logger) Debug(msg string, err ...error) {
if len(err) == 1 {
Expand All @@ -32,10 +28,6 @@ func (l *Logger) Debugf(msg string, args ...interface{}) {
zlog.Debug().Msg(fmt.Sprintf(msg, args...))
}

func (l *Logger) ZInfo() *zerolog.Event {
return zlog.Info()
}

func (l *Logger) Info(msg string, err ...error) {
if len(err) == 1 {
zlog.Info().Err(err[0]).Msg(msg)
Expand Down Expand Up @@ -84,18 +76,6 @@ func (l *Logger) Fatalf(msg string, args ...interface{}) {
zlog.Fatal().Msg(fmt.Sprintf(msg, args...))
}

func (l *Logger) Panic(msg string, err ...error) {
if len(err) == 1 {
zlog.Panic().Err(err[0]).Msg(msg)
return
}
zlog.Panic().Msg(msg)
}

func (l *Logger) Panicf(msg string, args ...interface{}) {
zlog.Panic().Msg(fmt.Sprintf(msg, args...))
}

func DoConfigureLogger(logPath string, logLevel string, prettyLogging bool) {
writers := io.MultiWriter(os.Stdout)
if len(logPath) > 0 {
Expand Down
20 changes: 0 additions & 20 deletions core/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,6 @@ import (
"gorm.io/gorm"
)

// Unmarshal JSON to a particular type. There can be more than one handler for each type.
// TODO: Remove this map and replace with a more generic solution
var messageTypeHandler = map[string][]func() txtypes.CosmosMessage{}

// var messageTypeIgnorer = map[string]interface{}{}

// Merge the chain specific message type handlers into the core message type handler map.
// Chain specific handlers will be registered BEFORE any generic handlers.
// TODO: Remove this function and replace with a more generic solution
func ChainSpecificMessageTypeHandlerBootstrap(chainID string) {
var chainSpecificMessageTpeHandler map[string][]func() txtypes.CosmosMessage
for key, value := range chainSpecificMessageTpeHandler {
if list, ok := messageTypeHandler[key]; ok {
messageTypeHandler[key] = append(value, list...)
} else {
messageTypeHandler[key] = value
}
}
}

func toAttributes(attrs []types.Attribute) []txtypes.Attribute {
list := []txtypes.Attribute{}
for _, attr := range attrs {
Expand Down
17 changes: 0 additions & 17 deletions cosmos/modules/tx/errors.go

This file was deleted.

62 changes: 0 additions & 62 deletions cosmos/modules/tx/types.go
Original file line number Diff line number Diff line change
@@ -1,45 +1,11 @@
package tx

import (
parsingTypes "github.com/DefiantLabs/cosmos-indexer/cosmos/modules"
cosmTx "github.com/cosmos/cosmos-sdk/types/tx"

sdk "github.com/cosmos/cosmos-sdk/types"
)

type GetTxsEventResponseWrapper struct {
CosmosGetTxsEventResponse *cosmTx.GetTxsEventResponse
Height int64
}

type GetBlockByHeightResponse struct {
BlockID BlockID `json:"block_id"`
Block BlockResponse `json:"block"`
}

type BlockResponse struct {
BlockData BlockData `json:"data"`
BlockHeader BlockHeader `json:"header"`
}

type BlockID struct {
Hash string `json:"hash"`
}

type BlockData struct {
Txs []string `json:"txs"`
}

type BlockHeader struct {
Height string `json:"height"`
}

type GetTxByBlockHeightResponse struct {
Txs []IndexerTx `json:"txs"`
TxResponses []Response `json:"tx_responses"`
Pagination Pagination `json:"pagination"`
}

type IndexerTx struct {
Body Body `json:"body"`
AuthInfo cosmTx.AuthInfo
Expand Down Expand Up @@ -121,36 +87,8 @@ type PublicKey struct {
Key string `json:"key"`
}

type Pagination struct {
NextKey string `json:"next_key"`
Total string `json:"total"`
}

// In the json, TX data is split into 2 arrays, used to merge the full dataset
type MergedTx struct {
Tx IndexerTx
TxResponse Response
}

type GetLatestBlockResponse struct {
BlockID BlockID `json:"block_id"`
Block BlockResponse `json:"block"`
}

type Message struct {
Type string `json:"@type"`
}

func (sf *Message) GetType() string {
return sf.Type
}

// CosmosMessage represents a Cosmos blockchain Message (part of a transaction).
// CosmUnmarshal() unmarshals the specific cosmos message type (e.g. MsgSend).
// First arg must always be the message type itself, as this won't be parsed in CosmUnmarshal.
type CosmosMessage interface {
HandleMsg(string, sdk.Msg, *LogMessage) error
ParseRelevantData() []parsingTypes.MessageRelevantInformation
GetType() string
String() string
}
18 changes: 0 additions & 18 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@ import (
"gorm.io/gorm/logger"
)

func GetAddresses(addressList []string, db *gorm.DB) ([]models.Address, error) {
// Look up all DB Addresses that match the search
var addresses []models.Address
result := db.Where("address IN ?", addressList).Find(&addresses)
fmt.Printf("Found %d addresses in the db\n", result.RowsAffected)
if result.Error != nil {
config.Log.Error("Error searching DB for addresses.", result.Error)
}

return addresses, result.Error
}

// PostgresDbConnect connects to the database according to the passed in parameters
func PostgresDbConnect(host string, port string, database string, user string, password string, level string) (*gorm.DB, error) {
dsn := fmt.Sprintf("host=%s port=%s dbname=%s user=%s password=%s sslmode=disable", host, port, database, user, password)
Expand All @@ -36,12 +24,6 @@ func PostgresDbConnect(host string, port string, database string, user string, p
return gorm.Open(postgres.Open(dsn), &gorm.Config{Logger: logger.Default.LogMode(gormLogLevel)})
}

// PostgresDbConnect connects to the database according to the passed in parameters
func PostgresDbConnectLogInfo(host string, port string, database string, user string, password string) (*gorm.DB, error) {
dsn := fmt.Sprintf("host=%s port=%s dbname=%s user=%s password=%s sslmode=disable", host, port, database, user, password)
return gorm.Open(postgres.Open(dsn), &gorm.Config{Logger: logger.Default.LogMode(logger.Info)})
}

// MigrateModels runs the gorm automigrations with all the db models. This will migrate as needed and do nothing if nothing has changed.
func MigrateModels(db *gorm.DB) error {
if err := migrateChainModels(db); err != nil {
Expand Down
Loading
Loading