services

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: BSD-3-Clause Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TableTransactions          = "avm_transactions"
	TableOutputsRedeeming      = "avm_outputs_redeeming"
	TableOutputs               = "avm_outputs"
	TableAssets                = "avm_assets"
	TableAddresses             = "addresses"
	TableAddressChain          = "address_chain"
	TableOutputAddresses       = "avm_output_addresses"
	TableTransactionsEpochs    = "transactions_epoch"
	TableCvmAddresses          = "cvm_addresses"
	TableCvmTransactions       = "cvm_transactions"
	TablePvmBlocks             = "pvm_blocks"
	TableRewards               = "rewards"
	TableTransactionsValidator = "transactions_validator"
	TableTransactionsBlock     = "transactions_block"
)
View Source
const (
	MetricProduceProcessedCountKey = "produce_records_processed"
	MetricProduceSuccessCountKey   = "produce_records_success"
	MetricProduceFailureCountKey   = "produce_records_failure"

	MetricConsumeProcessedCountKey       = "consume_records_processed"
	MetricConsumeProcessMillisCounterKey = "consume_records_process_millis"
	MetricConsumeSuccessCountKey         = "consume_records_success"
	MetricConsumeFailureCountKey         = "consume_records_failure"
)

Variables

This section is empty.

Functions

func EventErr added in v1.1.3

func EventErr(t string, upd bool, err error) error

func NewRedisConn

func NewRedisConn(opts *redis.Options) (*redis.Client, error)

func NewStream

func NewStream() *health.Stream

Types

type AddressChain added in v1.1.3

type AddressChain struct {
	Address   string
	ChainID   string
	CreatedAt time.Time
}

type Addresses added in v1.1.3

type Addresses struct {
	Address   string
	PublicKey []byte
	CreatedAt time.Time
}

type Assets added in v1.1.3

type Assets struct {
	ID            string
	ChainID       string
	Name          string
	Symbol        string
	Denomination  byte
	Alias         string
	CurrentSupply uint64
	CreatedAt     time.Time
}

type Connections

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

func NewConnections

func NewConnections(s *health.Stream, db *db.Conn, r *redis.Client) *Connections

func NewConnectionsFromConfig

func NewConnectionsFromConfig(conf cfg.Services, ro bool) (*Connections, error)

func (Connections) Cache

func (c Connections) Cache() *cache.Cache

func (Connections) Close added in v1.1.0

func (c Connections) Close() error

func (Connections) DB

func (c Connections) DB() *db.Conn

func (Connections) Redis

func (c Connections) Redis() *redis.Client

func (Connections) Stream

func (c Connections) Stream() *health.Stream

type Consumable

type Consumable interface {
	ID() string
	ChainID() string
	Body() []byte
	Timestamp() int64
	KafkaMessage() *kafkaMessage.Message
}

type Consumer

type Consumer interface {
	Name() string
	Bootstrap(context.Context, Persist) error
	Consume(context.Context, Consumable, Persist) error
	ConsumeConsensus(context.Context, Consumable, Persist) error
}

Consumer takes in Consumables and adds them to the service's backend

type ConsumerCtx

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

ConsumerCtx

func NewConsumerContext

func NewConsumerContext(ctx context.Context, job *health.Job, db dbr.SessionRunner, ts int64, persist Persist) ConsumerCtx

func (ConsumerCtx) Ctx

func (ic ConsumerCtx) Ctx() context.Context

func (ConsumerCtx) DB

func (ic ConsumerCtx) DB() dbr.SessionRunner

func (ConsumerCtx) Job

func (ic ConsumerCtx) Job() *health.Job

func (ConsumerCtx) Persist added in v1.1.3

func (ic ConsumerCtx) Persist() Persist

func (ConsumerCtx) Time

func (ic ConsumerCtx) Time() time.Time

type Control added in v1.1.3

type Control struct {
	Services cfg.Services
	Log      logging.Logger
	Persist  Persist
}

func (*Control) Database added in v1.1.3

func (s *Control) Database() (*Connections, error)

func (*Control) DatabaseRO added in v1.1.3

func (s *Control) DatabaseRO() (*Connections, error)

func (*Control) Init added in v1.1.3

func (s *Control) Init()

func (*Control) InitConsumeMetrics added in v1.1.3

func (s *Control) InitConsumeMetrics()

func (*Control) InitProduceMetrics added in v1.1.3

func (s *Control) InitProduceMetrics()

type CvmAddresses added in v1.1.3

type CvmAddresses struct {
	ID            string
	Type          models.CChainType
	Idx           uint64
	TransactionID string
	Address       string
	AssetID       string
	Amount        uint64
	Nonce         uint64
	CreatedAt     time.Time
}

type CvmTransactions added in v1.1.3

type CvmTransactions struct {
	ID           string
	Type         models.CChainType
	BlockchainID string
	Block        string
	CreatedAt    time.Time
}

type MockPersist added in v1.1.3

type MockPersist struct {
	Transactions          map[string]*Transactions
	Outputs               map[string]*Outputs
	OutputsRedeeming      map[string]*OutputsRedeeming
	CvmTransactions       map[string]*CvmTransactions
	CvmAddresses          map[string]*CvmAddresses
	TransactionsValidator map[string]*TransactionsValidator
	TransactionsBlock     map[string]*TransactionsBlock
	Rewards               map[string]*Rewards
	Addresses             map[string]*Addresses
	AddressChain          map[string]*AddressChain
	OutputAddresses       map[string]*OutputAddresses
	Assets                map[string]*Assets
	TransactionsEpoch     map[string]*TransactionsEpoch
	PvmBlocks             map[string]*PvmBlocks
	// contains filtered or unexported fields
}

func NewPersistMock added in v1.1.3

func NewPersistMock() *MockPersist

func (*MockPersist) InsertAddressChain added in v1.1.3

func (m *MockPersist) InsertAddressChain(ctx context.Context, runner dbr.SessionRunner, v *AddressChain, b bool) error

func (*MockPersist) InsertAddresses added in v1.1.3

func (m *MockPersist) InsertAddresses(ctx context.Context, runner dbr.SessionRunner, v *Addresses, b bool) error

func (*MockPersist) InsertAssets added in v1.1.3

func (m *MockPersist) InsertAssets(ctx context.Context, runner dbr.SessionRunner, v *Assets, b bool) error

func (*MockPersist) InsertCvmAddresses added in v1.1.3

func (m *MockPersist) InsertCvmAddresses(ctx context.Context, runner dbr.SessionRunner, v *CvmAddresses, b bool) error

func (*MockPersist) InsertCvmTransactions added in v1.1.3

func (m *MockPersist) InsertCvmTransactions(ctx context.Context, runner dbr.SessionRunner, v *CvmTransactions, b bool) error

func (*MockPersist) InsertOutputAddresses added in v1.1.3

func (m *MockPersist) InsertOutputAddresses(ctx context.Context, runner dbr.SessionRunner, v *OutputAddresses, b bool) error

func (*MockPersist) InsertOutputs added in v1.1.3

func (m *MockPersist) InsertOutputs(ctx context.Context, runner dbr.SessionRunner, v *Outputs, b bool) error

func (*MockPersist) InsertOutputsRedeeming added in v1.1.3

func (m *MockPersist) InsertOutputsRedeeming(ctx context.Context, runner dbr.SessionRunner, v *OutputsRedeeming, b bool) error

func (*MockPersist) InsertPvmBlocks added in v1.1.3

func (m *MockPersist) InsertPvmBlocks(ctx context.Context, runner dbr.SessionRunner, v *PvmBlocks, b bool) error

func (*MockPersist) InsertRewards added in v1.1.3

func (m *MockPersist) InsertRewards(ctx context.Context, runner dbr.SessionRunner, v *Rewards, b bool) error

func (*MockPersist) InsertTransaction added in v1.1.3

func (m *MockPersist) InsertTransaction(ctx context.Context, runner dbr.SessionRunner, v *Transactions, b bool) error

func (*MockPersist) InsertTransactionsBlock added in v1.1.3

func (m *MockPersist) InsertTransactionsBlock(ctx context.Context, runner dbr.SessionRunner, v *TransactionsBlock, b bool) error

func (*MockPersist) InsertTransactionsEpoch added in v1.1.3

func (m *MockPersist) InsertTransactionsEpoch(ctx context.Context, runner dbr.SessionRunner, v *TransactionsEpoch, b bool) error

func (*MockPersist) InsertTransactionsValidator added in v1.1.3

func (m *MockPersist) InsertTransactionsValidator(ctx context.Context, runner dbr.SessionRunner, v *TransactionsValidator, b bool) error

func (*MockPersist) QueryAddressChain added in v1.1.3

func (m *MockPersist) QueryAddressChain(ctx context.Context, runner dbr.SessionRunner, v *AddressChain) (*AddressChain, error)

func (*MockPersist) QueryAddresses added in v1.1.3

func (m *MockPersist) QueryAddresses(ctx context.Context, runner dbr.SessionRunner, v *Addresses) (*Addresses, error)

func (*MockPersist) QueryAssets added in v1.1.3

func (m *MockPersist) QueryAssets(ctx context.Context, runner dbr.SessionRunner, v *Assets) (*Assets, error)

func (*MockPersist) QueryCvmAddresses added in v1.1.3

func (m *MockPersist) QueryCvmAddresses(ctx context.Context, runner dbr.SessionRunner, v *CvmAddresses) (*CvmAddresses, error)

func (*MockPersist) QueryCvmTransactions added in v1.1.3

func (m *MockPersist) QueryCvmTransactions(ctx context.Context, runner dbr.SessionRunner, v *CvmTransactions) (*CvmTransactions, error)

func (*MockPersist) QueryOutputAddresses added in v1.1.3

func (m *MockPersist) QueryOutputAddresses(ctx context.Context, runner dbr.SessionRunner, v *OutputAddresses) (*OutputAddresses, error)

func (*MockPersist) QueryOutputs added in v1.1.3

func (m *MockPersist) QueryOutputs(ctx context.Context, runner dbr.SessionRunner, v *Outputs) (*Outputs, error)

func (*MockPersist) QueryOutputsRedeeming added in v1.1.3

func (m *MockPersist) QueryOutputsRedeeming(ctx context.Context, runner dbr.SessionRunner, v *OutputsRedeeming) (*OutputsRedeeming, error)

func (*MockPersist) QueryPvmBlocks added in v1.1.3

func (m *MockPersist) QueryPvmBlocks(ctx context.Context, runner dbr.SessionRunner, v *PvmBlocks) (*PvmBlocks, error)

func (*MockPersist) QueryRewards added in v1.1.3

func (m *MockPersist) QueryRewards(ctx context.Context, runner dbr.SessionRunner, v *Rewards) (*Rewards, error)

func (*MockPersist) QueryTransactions added in v1.1.3

func (m *MockPersist) QueryTransactions(ctx context.Context, runner dbr.SessionRunner, v *Transactions) (*Transactions, error)

func (*MockPersist) QueryTransactionsBlock added in v1.1.3

func (m *MockPersist) QueryTransactionsBlock(ctx context.Context, runner dbr.SessionRunner, v *TransactionsBlock) (*TransactionsBlock, error)

func (*MockPersist) QueryTransactionsEpoch added in v1.1.3

func (m *MockPersist) QueryTransactionsEpoch(ctx context.Context, runner dbr.SessionRunner, v *TransactionsEpoch) (*TransactionsEpoch, error)

func (*MockPersist) QueryTransactionsValidator added in v1.1.3

func (m *MockPersist) QueryTransactionsValidator(ctx context.Context, runner dbr.SessionRunner, v *TransactionsValidator) (*TransactionsValidator, error)

func (*MockPersist) UpdateOutputAddresses added in v1.1.3

func (m *MockPersist) UpdateOutputAddresses(ctx context.Context, runner dbr.SessionRunner, v *OutputAddresses) error

type OutputAddresses added in v1.1.3

type OutputAddresses struct {
	OutputID           string
	Address            string
	RedeemingSignature []byte
	CreatedAt          time.Time
}

type Outputs added in v1.1.3

type Outputs struct {
	ID            string
	ChainID       string
	TransactionID string
	OutputIndex   uint32
	OutputType    models.OutputType
	AssetID       string
	Amount        uint64
	Locktime      uint64
	Threshold     uint32
	GroupID       uint32
	Payload       []byte
	StakeLocktime uint64
	Stake         bool
	Frozen        bool
	CreatedAt     time.Time
}

type OutputsRedeeming added in v1.1.3

type OutputsRedeeming struct {
	ID                     string
	RedeemedAt             time.Time
	RedeemingTransactionID string
	Amount                 uint64
	OutputIndex            uint32
	Intx                   string
	AssetID                string
	ChainID                string
	CreatedAt              time.Time
}

type Persist added in v1.1.3

type Persist interface {
	QueryTransactions(
		context.Context,
		dbr.SessionRunner,
		*Transactions,
	) (*Transactions, error)
	InsertTransaction(
		context.Context,
		dbr.SessionRunner,
		*Transactions,
		bool,
	) error

	QueryOutputsRedeeming(
		context.Context,
		dbr.SessionRunner,
		*OutputsRedeeming,
	) (*OutputsRedeeming, error)
	InsertOutputsRedeeming(
		context.Context,
		dbr.SessionRunner,
		*OutputsRedeeming,
		bool,
	) error

	QueryOutputs(
		context.Context,
		dbr.SessionRunner,
		*Outputs,
	) (*Outputs, error)
	InsertOutputs(
		context.Context,
		dbr.SessionRunner,
		*Outputs,
		bool,
	) error

	QueryAssets(
		context.Context,
		dbr.SessionRunner,
		*Assets,
	) (*Assets, error)
	InsertAssets(
		context.Context,
		dbr.SessionRunner,
		*Assets,
		bool,
	) error

	QueryAddresses(
		context.Context,
		dbr.SessionRunner,
		*Addresses,
	) (*Addresses, error)
	InsertAddresses(
		context.Context,
		dbr.SessionRunner,
		*Addresses,
		bool,
	) error

	QueryAddressChain(
		context.Context,
		dbr.SessionRunner,
		*AddressChain,
	) (*AddressChain, error)

	InsertAddressChain(
		context.Context,
		dbr.SessionRunner,
		*AddressChain,
		bool,
	) error

	QueryOutputAddresses(
		context.Context,
		dbr.SessionRunner,
		*OutputAddresses,
	) (*OutputAddresses, error)
	InsertOutputAddresses(
		context.Context,
		dbr.SessionRunner,
		*OutputAddresses,
		bool,
	) error
	UpdateOutputAddresses(
		context.Context,
		dbr.SessionRunner,
		*OutputAddresses,
	) error

	QueryTransactionsEpoch(
		context.Context,
		dbr.SessionRunner,
		*TransactionsEpoch,
	) (*TransactionsEpoch, error)
	InsertTransactionsEpoch(
		context.Context,
		dbr.SessionRunner,
		*TransactionsEpoch,
		bool,
	) error

	QueryCvmAddresses(
		context.Context,
		dbr.SessionRunner,
		*CvmAddresses,
	) (*CvmAddresses, error)
	InsertCvmAddresses(
		context.Context,
		dbr.SessionRunner,
		*CvmAddresses,
		bool,
	) error

	QueryCvmTransactions(
		context.Context,
		dbr.SessionRunner,
		*CvmTransactions,
	) (*CvmTransactions, error)
	InsertCvmTransactions(
		context.Context,
		dbr.SessionRunner,
		*CvmTransactions,
		bool,
	) error

	QueryPvmBlocks(
		context.Context,
		dbr.SessionRunner,
		*PvmBlocks,
	) (*PvmBlocks, error)
	InsertPvmBlocks(
		context.Context,
		dbr.SessionRunner,
		*PvmBlocks,
		bool,
	) error

	QueryRewards(
		context.Context,
		dbr.SessionRunner,
		*Rewards,
	) (*Rewards, error)
	InsertRewards(
		context.Context,
		dbr.SessionRunner,
		*Rewards,
		bool,
	) error

	QueryTransactionsValidator(
		context.Context,
		dbr.SessionRunner,
		*TransactionsValidator,
	) (*TransactionsValidator, error)
	InsertTransactionsValidator(
		context.Context,
		dbr.SessionRunner,
		*TransactionsValidator,
		bool,
	) error

	QueryTransactionsBlock(
		context.Context,
		dbr.SessionRunner,
		*TransactionsBlock,
	) (*TransactionsBlock, error)

	InsertTransactionsBlock(
		context.Context,
		dbr.SessionRunner,
		*TransactionsBlock,
		bool,
	) error
}

func NewPersist added in v1.1.3

func NewPersist() Persist

type PvmBlocks added in v1.1.3

type PvmBlocks struct {
	ID            string
	ChainID       string
	Type          models.BlockType
	ParentID      string
	Serialization []byte
	CreatedAt     time.Time
}

type Rewards added in v1.1.3

type Rewards struct {
	ID                 string
	BlockID            string
	Txid               string
	Shouldprefercommit bool
	CreatedAt          time.Time
}

type Transactions added in v1.1.3

type Transactions struct {
	ID                     string
	ChainID                string
	Type                   string
	Memo                   []byte
	CanonicalSerialization []byte
	Txfee                  uint64
	Genesis                bool
	CreatedAt              time.Time
}

type TransactionsBlock added in v1.1.3

type TransactionsBlock struct {
	ID        string
	TxBlockID string
	CreatedAt time.Time
}

type TransactionsEpoch added in v1.1.3

type TransactionsEpoch struct {
	ID        string
	Epoch     uint32
	VertexID  string
	CreatedAt time.Time
}

type TransactionsValidator added in v1.1.3

type TransactionsValidator struct {
	ID        string
	NodeID    string
	Start     uint64
	End       uint64
	CreatedAt time.Time
}

Directories

Path Synopsis
indexes
avm
cvm
pvm

Jump to

Keyboard shortcuts

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