types

package
v0.0.0-...-00e1031 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChangeTypeTx    = RawLogType("change_tx")
	ChangeTypeBlock = RawLogType("change_block")

	// ChangeTypeChain 目前只关注 change chain,每一种 change 对应独立的日志文件
	ChangeTypeChain            = RawLogType("change_chain")
	ChangeTypeChain_Create     = RawLogType("change_chain_create")
	ChangeTypeChain_Remove     = RawLogType("change_chain_remove")
	ChangeTypeChain_Extend     = RawLogType("change_chain_extend")
	ChangeTypeChain_Reduce     = RawLogType("change_chain_reduce")
	ChangeTypeChain_Fork       = RawLogType("change_chain_fork")
	ChangeTypeChain_Reorganize = RawLogType("change_chain_reorganize")

	ChangeTypeNetwork = RawLogType("change_network")

	ChangeTypeUnknown = RawLogType("change_unknown")
)

ChangeType

View Source
const (
	StatueTypeTx = RawLogType("status_tx")

	StatueTypeBlock = RawLogType("status_block")

	StatueTypeChain = RawLogType("status_chain")

	StatueTypeNetwork = RawLogType("status_network")

	StatusTypeUnknown = RawLogType("status_unknown")
)

StatusType

View Source
const (
	// EventTypeBlock_Arrival arrival
	EventTypeBlock_Arrival = RawLogType("event_block_arrival")

	// EventTypeBlock_Verify verify
	EventTypeBlock_Verify = RawLogType("event_block_verify")

	// EventTypeBlock_Genesis genesis
	EventTypeBlock_Genesis = RawLogType("event_block_genesis")

	// EventTypeBlock_Connect connect
	EventTypeBlock_Connect = RawLogType("event_block_connect")

	// EventTypeBlock_Orphan orphan
	EventTypeBlock_Orphan = RawLogType("event_block_orphan")

	// EventTypeBlock_Stale stale
	EventTypeBlock_Stale = RawLogType("event_block_stale")

	// EventTypeBlock_Disconnect disconnect
	EventTypeBlock_Disconnect = RawLogType("event_block_disconnect")
)

EventType for StatusTypeBlock

View Source
const (
	EventTypeNetwork = RawLogType("event_network")
	EventTypeUnknown = RawLogType("event_unknown")
)

EventType for StatusTypeNetwork

View Source
const (
	ResultTypeBlock_VerifySuccess = RawLogType("result_block_verify_success")
	ResultTypeBlock_VerifyFailed  = RawLogType("result_block_verify_failed")

	ResultTypeBlock_Connect_MainChain    = RawLogType("result_block_connect_mainchain")     // extending mainchain
	ResultTypeBlock_Connect_SideChain    = RawLogType("result_block_connect_sidechain")     // extending or creating a sidechain
	ResultTypeBlock_Connect_Attach       = RawLogType("result_block_connect_attach")        // if reorganize attach into mainchain
	ResultTypeBlock_Connect_Detach       = RawLogType("result_block_connect_detach")        // if reorganize detach from mainchain
	ResultTypeBlock_Connect_BecomeOrphan = RawLogType("result_block_connect_become_orphan") // become orphan when connect parent not exist
	ResultTypeBlock_Connect_BecomeStale  = RawLogType("result_block_connect_become_stale")  // become stale when detach
	ResultTypeBlock_Connect_BecomeBest   = RawLogType("result_block_connect_become_best")   // become best when connect or attach

	ResultTypeBlock_Orphan_BecomeStale   = RawLogType("result_block_orphan_become_stale")   // become stale when connect into orphan
	ResultTypeBlock_Orphan_AddIntoPool   = RawLogType("result_block_orphan_add_into_pool")  // orphan store into orphan pool
	ResultTypeBlock_Orphan_ExpireDiscard = RawLogType("result_block_orphan_expire_discard") // orphan discard when expire in orphan pool

	ResultTypeBlock_Stale_AddIntoPool = RawLogType("result_block_stale_add_into_pool") // stale store into orphan pool
	ResultTypeBlock_Stale_Discard     = RawLogType("result_block_stale_add_into_pool") // stale discard when detach or expire in orphan pool

	ResultTypeBlock_Disconnect_MainChain   = RawLogType("result_block_disconnect_mainchain")
	ResultTypeBlock_Disconnect_SideChain   = RawLogType("result_block_disconnect_sidechain")
	ResultTypeBlock_Disconnect_BecomeStale = RawLogType("result_block_disconnect_become_stale") // become stale when disconnect from mainchain or sidechain
)

ResultType for EventTypeBlock

View Source
const (
	ResultTypeNetwork = RawLogType("result_network")
	ResultTypeUnknown = RawLogType("result_unknown")
)

ResultType for EventTypeNetwork

View Source
const (
	// EventTypeChain chain
	EventTypeChain = RawLogType("event_chain")
)

EventType for StatusTypeChain

View Source
const (
	// EventTypeTx tx
	EventTypeTx = RawLogType("event_tx")
)

EventType for StatusTypeTx

View Source
const (
	// ResultTypeChain chain
	ResultTypeChain = RawLogType("result_chain")
)

ResultType for EventTypeChain

View Source
const (
	// ResultTypeTx tx
	ResultTypeTx = RawLogType("result_tx")
)

ResultType for EventTypeTx

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeLog

type ChangeLog struct {
	// change detail
	ChangeRaw RawLog

	// resolver
	ID                 common.ID
	PrevChangeLog      *ChangeLog
	NextChangeLog      *ChangeLog
	RelevantStatusLogs []*StatusLog
}

func (*ChangeLog) String

func (changeLog *ChangeLog) String() string

type EventLog

type EventLog struct {
	// event detail
	EventRaw RawLog

	// resolver
	ID                common.ID
	PrevEventLog      *EventLog
	NextEventLog      *EventLog
	RelevantResultLog *ResultLog
	RelevantStatusLog *StatusLog
}

func (*EventLog) String

func (eventLog *EventLog) String() string

type Log

type Log interface {
	ID() common.ID
	Raw() RawLog
	Prev() Log
	Next() Log
}

type LogTree

type LogTree struct {
	Root     *RawLog                       `json:"root"`     // *ChangeLog raw
	Children map[RawLogType][]*LogTreeNode `json:"children"` // map[StatusType][]*StatusLog raw
}

func NewLogTree

func NewLogTree() *LogTree

func (*LogTree) AddChild

func (tree *LogTree) AddChild(logType RawLogType, status *RawLog) error

func (*LogTree) GetChild

func (tree *LogTree) GetChild(logType RawLogType) (*LogTreeNode, error)

func (*LogTree) Serialize

func (tree *LogTree) Serialize(change *RawLog) ([]byte, error)

type LogTreeNode

type LogTreeNode struct {
	Node         *RawLog   `json:"node"`          // StatusLog raw
	NodeChildren []*RawLog `json:"node_children"` // []*EventLog raw
}

func NewLogTreeNode

func NewLogTreeNode(status *RawLog) *LogTreeNode

func (*LogTreeNode) AddNodeChild

func (node *LogTreeNode) AddNodeChild(event *RawLog)

type RawLog

type RawLog struct {
	Type      RawLogType `json:"type"`
	Timestamp Timestamp  `json:"timestamp"`
	Raw       []byte     `json:"raw"`
}

RawLog parsing from the logs output by btcd

type RawLogType

type RawLogType string

func (RawLogType) String

func (t RawLogType) String() string

type ResultLog

type ResultLog struct {
	// result detail
	ResultRaw RawLog

	// resolver
	ID               common.ID
	RelevantEventLog *EventLog
}

func (*ResultLog) String

func (resultLog *ResultLog) String() string

type StatusLog

type StatusLog struct {
	// status detail
	StatusRaw RawLog

	// resolver
	ID                common.ID
	PrevStatusLog     *StatusLog
	NextStatusLog     *StatusLog
	RelevantEventLogs []*EventLog
	RelevantChangeLog *ChangeLog
}

func (*StatusLog) String

func (statusLog *StatusLog) String() string

type TimePoint

type TimePoint struct {
	Timestamp
	Log
}

type Timeline

type Timeline struct {
	TimePointSet []TimePoint
	Since        Timestamp
}

func NewTimeline

func NewTimeline(point TimePoint) Timeline

func (*Timeline) GetPointBefore

func (tl *Timeline) GetPointBefore(pivot Timestamp) Timeline

GetPointBefore find the TimestampStatus Before the time point

func (*Timeline) GetPointByRange

func (tl *Timeline) GetPointByRange(start, end Timestamp) Timeline

GetPointByRange find range TimestampStatus between start and end

func (*Timeline) GetPointByTime

func (tl *Timeline) GetPointByTime(pivot Timestamp) Timeline

GetPointByTime find left and right TimestampStatus about the pivot

func (*Timeline) GetPointByType

func (tl *Timeline) GetPointByType(t RawLogType) Timeline

GetPointByType find the TimestampStatus that Type in ts

func (*Timeline) GetPointSince

func (tl *Timeline) GetPointSince(pivot Timestamp) Timeline

GetPointSince find the TimestampStatus Since the time point

func (*Timeline) PushPoint

func (tl *Timeline) PushPoint(points ...TimePoint)

PushPoint push a point into point set

type Timestamp

type Timestamp int64

func FromInt64

func FromInt64(t int64) Timestamp

func FromNow

func FromNow() Timestamp

func FromTime

func FromTime(t time.Time) Timestamp

func (Timestamp) FormatString

func (t Timestamp) FormatString() string

TODO add more method about Timestamp

func (Timestamp) FormatTime

func (t Timestamp) FormatTime() time.Time

TODO add more method about Timestamp

Jump to

Keyboard shortcuts

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