cosmos

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CollectionNameBlock = "sync_cosmos_block"
)
View Source
const (
	CollectionNameCosmosTx = "sync_cosmos_tx"
)
View Source
const (
	CollectionNameSyncCosmosTask = "sync_cosmos_task"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Height     int64 `bson:"height"`
	CreateTime int64 `bson:"create_time"`
}

type Coin

type Coin struct {
	Denom  string `bson:"denom"  json:"denom"`
	Amount int64  `bson:"amount"  json:"amount"`
}

type Coins

type Coins []*Coin

type CosmosTx

type CosmosTx struct {
	Time      time.Time         `bson:"time"`
	Height    int64             `bson:"height"`
	TxHash    string            `bson:"tx_hash"`
	From      string            `bson:"from"`
	To        string            `bson:"to"`
	Initiator string            `bson:"initiator"`
	Amount    []*Coin           `bson:"amount"`
	Type      string            `bson:"type"`
	Fee       *Fee              `bson:"fee"`
	Memo      string            `bson:"memo"`
	Status    string            `bson:"status"`
	Code      uint32            `bson:"code"`
	Tags      map[string]string `bson:"tags"`
}

func (CosmosTx) Name

func (d CosmosTx) Name() string

func (CosmosTx) PkKvPair

func (d CosmosTx) PkKvPair() map[string]interface{}

type Fee

type Fee struct {
	Amount []*Coin `bson:"amount" json:"amount"`
	Gas    int64   `bson:"gas" json:"gas"`
}

type RawLog

type RawLog struct {
	MsgIndex int    `json:"msg_index,string"`
	Success  bool   `json:"success"`
	Log      string `json:"log"`
}

type SyncCosmosTask

type SyncCosmosTask struct {
	ID             bson.ObjectId `bson:"_id"`
	StartHeight    int64         `bson:"start_height"`     // task start height
	EndHeight      int64         `bson:"end_height"`       // task end height
	CurrentHeight  int64         `bson:"current_height"`   // task current height
	Status         string        `bson:"status"`           // task status
	WorkerId       string        `bson:"worker_id"`        // worker id
	WorkerLogs     []WorkerLog   `bson:"worker_logs"`      // worker logs
	LastUpdateTime int64         `bson:"last_update_time"` // unix timestamp
}

func (*SyncCosmosTask) GetExecutableTask

func (d *SyncCosmosTask) GetExecutableTask(maxWorkerSleepTime int64) ([]SyncCosmosTask, error)

func (*SyncCosmosTask) GetMaxBlockHeight

func (d *SyncCosmosTask) GetMaxBlockHeight() (int64, error)

get max block height in sync task

func (*SyncCosmosTask) GetTaskById

func (d *SyncCosmosTask) GetTaskById(id bson.ObjectId) (SyncCosmosTask, error)

func (*SyncCosmosTask) GetTaskByIdAndWorker

func (d *SyncCosmosTask) GetTaskByIdAndWorker(id bson.ObjectId, worker string) (SyncCosmosTask, error)

func (*SyncCosmosTask) Name

func (d *SyncCosmosTask) Name() string

func (*SyncCosmosTask) PkKvPair

func (d *SyncCosmosTask) PkKvPair() map[string]interface{}

func (*SyncCosmosTask) QueryAll

func (d *SyncCosmosTask) QueryAll(status []string, taskType string) ([]SyncCosmosTask, error)

query record by status

func (*SyncCosmosTask) TakeOverTask

func (d *SyncCosmosTask) TakeOverTask(task SyncCosmosTask, workerId string) error

take over a task update status, worker_id, worker_logs and last_update_time

func (*SyncCosmosTask) UpdateLastUpdateTime

func (d *SyncCosmosTask) UpdateLastUpdateTime(task SyncCosmosTask) error

update task last update time

type Tag

type Tag map[string]string

type WorkerLog

type WorkerLog struct {
	WorkerId  string    `bson:"worker_id"`  // worker id
	BeginTime time.Time `bson:"begin_time"` // time which worker begin handle this task
}

Jump to

Keyboard shortcuts

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