blocklog

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChangeKindCreate = "create"
	ChangeKindUpdate = "update"
	ChangeKindDelete = "delete"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockLog

type BlockLog struct {
	BlockId      string            `json:"id"`
	BlockNum     uint64            `json:"num"`
	BlockTime    uint32            `json:"time"`
	Transactions []*TransactionLog `json:"trxs"`
	Changes      []*StateChange    `json:"changes"`
}

func (*BlockLog) FromJsonString

func (log *BlockLog) FromJsonString(j string) error

func (*BlockLog) ToJsonString

func (log *BlockLog) ToJsonString() string

type ChangeDataMaker

type ChangeDataMaker func(id, before, after interface{}) *GenericChange

type GenericChange

type GenericChange struct {
	Id     interface{} `json:"id"`
	Before interface{} `json:"before"`
	After  interface{} `json:"after"`
}

type InterestedChange

type InterestedChange struct {
	Table *table.TableInfo
	Field string
	Maker ChangeDataMaker
}

type InternalStateChangeSlice

type InternalStateChangeSlice []*internalStateChange

type OperationLog

type OperationLog struct {
	Type    string               `json:"type"`
	Data    *prototype.Operation `json:"data"`
	Changes []*StateChange       `json:"changes"`
}

type StateChange

type StateChange struct {
	What       string                 `json:"what"`
	Kind       string                 `json:"kind"`
	Cause      string                 `json:"cause"`
	CauseExtra map[string]interface{} `json:"cause_extra"`
	Change     *GenericChange         `json:"change"`
}

type StateChangeContext

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

func (*StateChangeContext) AddChange

func (ctx *StateChangeContext) AddChange(what, kind string, change *GenericChange)

func (*StateChangeContext) Cause

func (ctx *StateChangeContext) Cause() string

func (*StateChangeContext) CauseExtra

func (ctx *StateChangeContext) CauseExtra() map[string]interface{}

func (*StateChangeContext) Changes

func (*StateChangeContext) ClearChanges

func (ctx *StateChangeContext) ClearChanges()

func (*StateChangeContext) PopAndPushCause

func (ctx *StateChangeContext) PopAndPushCause(cause string)

func (*StateChangeContext) PopCause

func (ctx *StateChangeContext) PopCause()

func (*StateChangeContext) PushCause

func (ctx *StateChangeContext) PushCause(cause string)

func (*StateChangeContext) PutCauseExtra

func (ctx *StateChangeContext) PutCauseExtra(key string, value interface{})

func (*StateChangeContext) Restore

func (ctx *StateChangeContext) Restore(restorePoint int)

func (*StateChangeContext) RestorePoint

func (ctx *StateChangeContext) RestorePoint() int

func (*StateChangeContext) SetCause

func (ctx *StateChangeContext) SetCause(cause string)

func (*StateChangeContext) SetOperation

func (ctx *StateChangeContext) SetOperation(op int)

func (*StateChangeContext) SetTrxAndOperation

func (ctx *StateChangeContext) SetTrxAndOperation(trxId string, op int)

type TransactionLog

type TransactionLog struct {
	TrxId      string                        `json:"id"`
	Receipt    *prototype.TransactionReceipt `json:"receipt"`
	Operations []*OperationLog               `json:"ops"`
}

type Watcher

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

func NewWatcher

func NewWatcher(dbSvcId uint32, callback WatcherCallback) (w *Watcher)

func (*Watcher) BeginBlock

func (w *Watcher) BeginBlock(blockNum uint64) error

func (*Watcher) CurrentBlockContext

func (w *Watcher) CurrentBlockContext() (ctx *StateChangeContext)

func (*Watcher) EndBlock

func (w *Watcher) EndBlock(ok bool, block *prototype.SignedBlock) error

func (*Watcher) GetOrCreateStateChangeContext

func (w *Watcher) GetOrCreateStateChangeContext(branch string, trxId string, op int, cause string) (ctx *StateChangeContext)

type WatcherCallback

type WatcherCallback func(*BlockLog, string)

Jump to

Keyboard shortcuts

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