db_buffer

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: Apache-2.0 Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultSyncPeriod = 30 * time.Second

Variables

This section is empty.

Functions

func ParallelCopyTxsToDB

func ParallelCopyTxsToDB(transactions interface{}, tableName string) error

Types

type Buffer

type Buffer struct {
	SyncComplete chan SyncResult
	// contains filtered or unexported fields
}

func NewDBBuffer

func NewDBBuffer(db *gorm.DB, cfg Config) *Buffer

func (*Buffer) ClearBuffer

func (b *Buffer) ClearBuffer(dataType string)

func (*Buffer) GetBufferSize

func (b *Buffer) GetBufferSize(dataType string) int

func (*Buffer) GetData

func (b *Buffer) GetData(dataType string) (map[string]interface{}, error)

func (*Buffer) InsertData

func (b *Buffer) InsertData(key string, height int64, data interface{}, notify bool) error

InsertData inserts 'data' into the buffer under the key 'key' if notify is set to true, the condition 'SyncBlockThreshold' will be tested for that specific key

func (*Buffer) SetSyncFunc

func (b *Buffer) SetSyncFunc(cb SyncCB)

SetSyncFunc sets the syncing callback function

func (*Buffer) Start

func (b *Buffer) Start()

Start starts listening for syncing triggering events

func (*Buffer) Stop

func (b *Buffer) Stop()

Stop stops listening for syncing triggering events

type BufferMetrics

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

type Config

type Config struct {
	SyncTimePeriod     time.Duration
	SyncBlockThreshold uint
}

type SyncCB

type SyncCB func() SyncResult

type SyncResult

type SyncResult struct {
	Id            string
	SyncedHeights *[]uint64 // Synced heights
	Error         error     // Error in db insertion process
}

Jump to

Keyboard shortcuts

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