engine

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2019 License: MIT Imports: 18 Imported by: 0 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

This section is empty.

Variables

View Source
var (
	Chains = ChainMap{

		RWMutex: new(sync.RWMutex),
		// contains filtered or unexported fields
	}
)

Functions

func GetSyncStatus

func GetSyncStatus() (sync, current uint32)

GetSyncStatus is a threadsafe way to get the sync height and current Factom Blockchain height.

func Process

func Process(ctx context.Context, dbKeyMR *factom.Bytes32, eb factom.EBlock) error

func ProcessPending

func ProcessPending(ctx context.Context, es ...factom.Entry) error

func Start

func Start(ctx context.Context) (done <-chan struct{})

Start launches the main engine goroutine, which loads state and starts the worker goroutines. If stop is closed or if an error occurs, the engine will finish processing the current DBlock, cleanup and close state, all goroutines will exit, and done will be closed. If the done channel is closed before the stop channel is closed, an error occurred.

Types

type Chain

type Chain struct {
	ChainStatus
	db.Chain

	Pending Pending
}

func OpenNew

func OpenNew(ctx context.Context, c *factom.Client,
	dbKeyMR *factom.Bytes32, eb factom.EBlock) (chain Chain, err error)

func OpenNewByChainID

func OpenNewByChainID(ctx context.Context,
	c *factom.Client, chainID *factom.Bytes32) (chain Chain, err error)

func (*Chain) Apply

func (chain *Chain) Apply(ctx context.Context, c *factom.Client,
	dbKeyMR *factom.Bytes32, eb factom.EBlock) error

func (Chain) String

func (chain Chain) String() string

func (*Chain) Sync

func (chain *Chain) Sync(ctx context.Context, c *factom.Client) error

func (*Chain) SyncEBlocks

func (chain *Chain) SyncEBlocks(
	ctx context.Context, c *factom.Client, ebs []factom.EBlock) error

type ChainMap

type ChainMap struct {
	*sync.RWMutex
	// contains filtered or unexported fields
}

func (*ChainMap) Close

func (cm *ChainMap) Close()

func (*ChainMap) Get

func (cm *ChainMap) Get(ctx context.Context,
	id *factom.Bytes32, pending bool) (Chain, func(), error)

Get returns a threadsafe connection to the database, and a function to release the connection back to the pool. If pending is true, the chain will reflect the state with pending entries applied. Otherwise the chain will reflect the official state after the most recent EBlock.

func (*ChainMap) GetIssued

func (cm *ChainMap) GetIssued() []*factom.Bytes32

func (*ChainMap) GetTracked

func (cm *ChainMap) GetTracked() []*factom.Bytes32

type ChainStatus

type ChainStatus uint
const (
	ChainStatusUnknown ChainStatus = 0
	ChainStatusTracked ChainStatus = 1
	ChainStatusIssued  ChainStatus = 3
	ChainStatusIgnored ChainStatus = 4
)

func (ChainStatus) IsIgnored

func (status ChainStatus) IsIgnored() bool

func (ChainStatus) IsIssued

func (status ChainStatus) IsIssued() bool

func (ChainStatus) IsTracked

func (status ChainStatus) IsTracked() bool

func (ChainStatus) IsUnknown

func (status ChainStatus) IsUnknown() bool

func (ChainStatus) String

func (status ChainStatus) String() string

type Pending

type Pending struct {
	OfficialSnapshot *sqlite.Snapshot

	Session       *sqlite.Session
	OfficialChain db.Chain

	Entries map[factom.Bytes32]factom.Entry
}

Jump to

Keyboard shortcuts

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