Documentation
¶
Index ¶
- func Apply(chain Chain, dbKeyMR *factom.Bytes32, eb factom.EBlock) (err error)
- func SyncEBlocks(ctx context.Context, c *factom.Client, chain Chain, eblocks []factom.EBlock) error
- type Chain
- type FATChain
- func (chain *FATChain) ApplyEBlock(dbKeyMR *factom.Bytes32, eb factom.EBlock) error
- func (chain *FATChain) ApplyEntry(e factom.Entry) (eID int64, err error)
- func (chain *FATChain) ApplyFAT0Tx(eID int64, e factom.Entry) (tx fat0.Transaction, txErr, err error)
- func (chain *FATChain) ApplyFAT1Tx(eID int64, e factom.Entry) (tx fat1.Transaction, txErr, err error)
- func (chain *FATChain) ApplyIssuance(ei int64, e factom.Entry) (txErr, err error)
- func (chain *FATChain) ApplyTx(eID int64, e factom.Entry) (tx interface{}, txErr, err error)
- func (chain *FATChain) Copy() Chain
- func (chain *FATChain) IsIssued() bool
- func (chain *FATChain) Save() func(err *error)
- func (chain *FATChain) SetSync(height uint32, dbKeyMR *factom.Bytes32) error
- func (chain *FATChain) ToDBFATChain() *db.FATChain
- func (chain *FATChain) ToFactomChain() *db.FactomChain
- func (chain *FATChain) UpdateSidechainData(ctx context.Context, c *factom.Client) error
- func (chain *FATChain) Validate(ctx context.Context, repair bool) (err error)
- type FactomChain
- func (chain *FactomChain) ApplyEBlock(dbKeyMR *factom.Bytes32, eb factom.EBlock) error
- func (chain *FactomChain) ApplyEntry(e factom.Entry) (eID int64, err error)
- func (chain *FactomChain) Close() error
- func (chain *FactomChain) Copy() Chain
- func (chain *FactomChain) Save() func(err *error)
- func (chain *FactomChain) SetSync(height uint32, dbKeyMR *factom.Bytes32) error
- func (chain *FactomChain) ToFactomChain() *db.FactomChain
- func (chain *FactomChain) UpdateSidechainData(context.Context, *factom.Client) error
- type ParallelChain
- func (chain *ParallelChain) ApplyEBlockCtx(ctx context.Context, dbKeyMR *factom.Bytes32, eb factom.EBlock) error
- func (chain *ParallelChain) ApplyPendingEntries(ctx context.Context, es []factom.Entry) error
- func (chain *ParallelChain) Close() error
- func (chain *ParallelChain) SetSync(height uint32, dbKeyMR *factom.Bytes32) error
- type PendingChain
- type State
- func (state *State) ApplyEBlock(ctx context.Context, dbKeyMR *factom.Bytes32, eb factom.EBlock) (err error)
- func (state *State) ApplyPendingEntries(ctx context.Context, es []factom.Entry) error
- func (state *State) Close()
- func (state *State) Get(ctx context.Context, id *factom.Bytes32, includePending bool) (_ Chain, _ func(), err error)
- func (state *State) GetSync() uint32
- func (state *State) IssuedIDs() []*factom.Bytes32
- func (state *State) NewParallelChain(ctx context.Context, chainID *factom.Bytes32, ...) error
- func (state *State) SetSync(ctx context.Context, height uint32, dbKeyMR *factom.Bytes32) error
- func (state *State) TrackedIDs() []*factom.Bytes32
- type UnknownChain
- func (chain UnknownChain) ApplyEBlock(*factom.Bytes32, factom.EBlock) error
- func (chain UnknownChain) ApplyEntry(factom.Entry) (int64, error)
- func (chain UnknownChain) Close() error
- func (chain UnknownChain) Copy() Chain
- func (chain UnknownChain) Save() func(*error)
- func (chain UnknownChain) SetSync(uint32, *factom.Bytes32) error
- func (chain UnknownChain) ToFactomChain() *db.FactomChain
- func (chain UnknownChain) UpdateSidechainData(context.Context, *factom.Client) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Chain ¶
type Chain interface { // UpdateSidechainData updates any data from external Chains that the // state depends on. This should be called before ApplyEBlock. UpdateSidechainData(context.Context, *factom.Client) error // Apply applies the next EBlock to the chain state. ApplyEBlock(*factom.Bytes32, factom.EBlock) error // ApplyEntry applies the next Entry. This is used by the engine for // applying pending entries. ApplyEntry(factom.Entry) (id int64, err error) SetSync(uint32, *factom.Bytes32) error // Copy returns a copy of the current state. This allows the engine to // save and rollback the in-memory state data. Copy() Chain Save() func(*error) // ToFactomChain returns a pointer to the underlying db.FactomChain // that all chains embed. ToFactomChain() *db.FactomChain Close() error }
Chain is the interface for advancing a Chain's state. This is used by the engine to apply EBlocks and Entries.
type FATChain ¶
func NewFATChain ¶
func NewFATChainByEBlock ¶
func ToFATChain ¶
func (*FATChain) ApplyEBlock ¶
func (*FATChain) ApplyEntry ¶
func (*FATChain) ApplyFAT0Tx ¶
func (*FATChain) ApplyFAT1Tx ¶
func (*FATChain) ApplyIssuance ¶
func (*FATChain) Save ¶
Save the current state of the chain and the database that can be rolled back to if the returned closure is called with a non-nil error.
func (*FATChain) ToDBFATChain ¶ added in v1.1.3
func (*FATChain) ToFactomChain ¶
func (chain *FATChain) ToFactomChain() *db.FactomChain
func (*FATChain) UpdateSidechainData ¶
type FactomChain ¶
type FactomChain db.FactomChain
func ToFactomChain ¶
func ToFactomChain(chain Chain) (factomChain *FactomChain, ok bool)
func (*FactomChain) ApplyEBlock ¶
func (*FactomChain) ApplyEntry ¶
func (chain *FactomChain) ApplyEntry(e factom.Entry) (eID int64, err error)
func (*FactomChain) Close ¶
func (chain *FactomChain) Close() error
func (*FactomChain) Copy ¶
func (chain *FactomChain) Copy() Chain
func (*FactomChain) Save ¶
func (chain *FactomChain) Save() func(err *error)
Save the current state of the chain and the database that can be rolled back to if the returned closure is called with a non-nil error.
func (*FactomChain) SetSync ¶
func (chain *FactomChain) SetSync(height uint32, dbKeyMR *factom.Bytes32) error
func (*FactomChain) ToFactomChain ¶
func (chain *FactomChain) ToFactomChain() *db.FactomChain
func (*FactomChain) UpdateSidechainData ¶
type ParallelChain ¶
type ParallelChain struct { Chain trylock.TryLocker // contains filtered or unexported fields }
func ToParallelChain ¶
func ToParallelChain(chain Chain) *ParallelChain
func (*ParallelChain) ApplyEBlockCtx ¶
func (*ParallelChain) ApplyPendingEntries ¶
func (*ParallelChain) Close ¶
func (chain *ParallelChain) Close() error
type PendingChain ¶
type PendingChain struct { Chain OfficialState Chain OfficialSnapshot *sqlite.Snapshot Session *sqlite.Session Entries map[factom.Bytes32]factom.Entry // contains filtered or unexported fields }
func NewPendingChain ¶
func ToPendingChain ¶
func ToPendingChain(chain Chain) (pending *PendingChain, ok bool)
func (*PendingChain) ApplyPendingEntries ¶
func (pending *PendingChain) ApplyPendingEntries(es []factom.Entry) error
func (*PendingChain) Close ¶
func (pending *PendingChain) Close() error
func (*PendingChain) LoadFromCache ¶
func (pending *PendingChain) LoadFromCache(eb *factom.EBlock)
func (*PendingChain) Revert ¶
func (pending *PendingChain) Revert() (Chain, error)
type State ¶
type State struct { Chains map[factom.Bytes32]Chain sync.RWMutex DBPath string NetworkID factom.NetworkID IgnoreNewChains bool SyncHeight uint32 SyncDBKeyMR *factom.Bytes32 Log log.Log Lockfile lockfile.Lockfile // contains filtered or unexported fields }
func (*State) ApplyEBlock ¶
func (*State) ApplyPendingEntries ¶
func (*State) Get ¶
func (state *State) Get(ctx context.Context, id *factom.Bytes32, includePending bool) (_ Chain, _ func(), err 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 (*State) NewParallelChain ¶
func (*State) TrackedIDs ¶
type UnknownChain ¶
type UnknownChain struct{}
func (UnknownChain) ApplyEBlock ¶
func (UnknownChain) ApplyEntry ¶
func (chain UnknownChain) ApplyEntry(factom.Entry) (int64, error)
func (UnknownChain) Close ¶
func (chain UnknownChain) Close() error
func (UnknownChain) Copy ¶
func (chain UnknownChain) Copy() Chain
func (UnknownChain) Save ¶
func (chain UnknownChain) Save() func(*error)
func (UnknownChain) ToFactomChain ¶
func (chain UnknownChain) ToFactomChain() *db.FactomChain