Documentation ¶
Index ¶
- Constants
- type BestState
- type EventOrphan
- type EventType
- type Revision
- type RevisionData
- type RevisionDataBlockReceiveFinal
- type RevisionDataBlockReceiveInit
- type RevisionDataBlockVerifyFinal
- type RevisionDataBlockVerifyInit
- type RevisionDataChainSwapFinal
- type RevisionDataChainSwapInit
- type RevisionDataChainVerifyFinal
- type RevisionDataChainVerifyInit
- type RevisionDataMainChainExtendFinal
- type RevisionDataMainChainExtendInit
- type RevisionDataOrphanExtendFinal
- type RevisionDataOrphanExtendInit
- type RevisionDataOrphanProcessFinal
- type RevisionDataOrphanProcessInit
- type RevisionDataSideChainExtendFinal
- type RevisionDataSideChainExtendInit
- type RevisionType
- type Snapshot
- type SnapshotType
Constants ¶
View Source
const ( SnapshotTypeInit = iota SnapshotTypeFinal SnapshotTypeSync SnapshotTypeUnknown )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BestState ¶
type BestState struct { Hash string `json:"hash"` // The hash of the block. Height int32 `json:"height"` // The height of the block. Bits uint32 `json:"bits"` // The difficulty bits of the block. BlockSize uint64 `json:"block_size"` // The size of the block. BlockWeight uint64 `json:"block_weight"` // The weight of the block. NumTxns uint64 `json:"num_txns"` // The number of txns in the block. TotalTxns uint64 `json:"total_txns"` // The total number of txns in the chain. MedianTimestamp common.Timestamp `json:"median_timestamp"` // Median time as per CalcPastMedianTime. }
BestState from btcd chain.BestState
type EventOrphan ¶ added in v0.0.2
type EventOrphan struct { SnapshotID string `json:"snapshot_id"` Type EventType `json:"event_type_orphan"` OrphanParentBlockHash string `json:"orphan_parent_block_hash"` OrphanBlockHash string `json:"orphan_block_hash"` ConnectMainChain bool `json:"connect_main_chain"` Timestamp common.Timestamp `json:"timestamp"` // Revision 开始时间戳 }
func NewEventOrphan ¶ added in v0.0.2
func NewEventOrphan(t EventType, snapshotID string, parentBlockHash, blockHash string, connectMainChain bool) *EventOrphan
type Revision ¶
type Revision struct { SnapshotID string `json:"snapshot_id"` Type RevisionType `json:"revision_type"` // 代表区块同步过程的一个阶段 InitTimestamp common.Timestamp `json:"init_timestamp"` // Revision 开始时间戳 InitData RevisionData `json:"init_data"` // 根据 Tag 不同获取不同的数据,在 Revision 开始和时输出 FinalTimestamp common.Timestamp `json:"final_timestamp"` // Revision 生效时间,结合 Timestamp 和 CommitTimestamp 确定 Revision 持续时间 FinalData RevisionData `json:"final_data"` // 根据 Tag 不同获取不同的数据,在 Revision 结束时输出 }
Revision 代表一个区块同步过程中的某一个阶段结束, 同一个 Snapshot 期间,每一个过程结束时输出一次
func NewRevision ¶
func NewRevision(t RevisionType, snapshotID string, data RevisionData) *Revision
type RevisionData ¶
type RevisionData interface{}
type RevisionDataBlockReceiveFinal ¶ added in v0.0.2
type RevisionDataBlockReceiveFinal struct {
OK bool `json:"ok"`
}
type RevisionDataBlockReceiveInit ¶ added in v0.0.2
type RevisionDataBlockVerifyFinal ¶ added in v0.0.2
type RevisionDataBlockVerifyInit ¶ added in v0.0.2
type RevisionDataBlockVerifyInit struct { Hash string `json:"hash"` ParentHash string `json:"parent_hash"` Height int32 `json:"height"` NumTxns uint64 `json:"num_txns"` Version int32 `json:"version"` Bits uint32 `json:"bits"` WorkSum string `json:"work_sum"` MerkleRootHash string `json:"merkle_root_hash"` Nonce uint32 `json:"nonce"` }
type RevisionDataChainSwapFinal ¶ added in v0.0.2
type RevisionDataChainSwapInit ¶ added in v0.0.2
type RevisionDataChainSwapInit struct {
OldBestBlockHash string `json:"old_best_block_hash"`
}
type RevisionDataChainVerifyFinal ¶ added in v0.0.2
type RevisionDataChainVerifyFinal struct { }
type RevisionDataChainVerifyInit ¶ added in v0.0.2
type RevisionDataChainVerifyInit struct { }
type RevisionDataMainChainExtendFinal ¶ added in v0.0.2
type RevisionDataMainChainExtendFinal struct {
OK bool `json:"ok"`
}
type RevisionDataMainChainExtendInit ¶ added in v0.0.2
type RevisionDataMainChainExtendInit struct {
BlockHash string `json:"block_hash"`
}
type RevisionDataOrphanExtendFinal ¶ added in v0.0.2
type RevisionDataOrphanExtendFinal struct { }
type RevisionDataOrphanExtendInit ¶ added in v0.0.2
type RevisionDataOrphanExtendInit struct { }
type RevisionDataOrphanProcessFinal ¶ added in v0.0.2
type RevisionDataOrphanProcessFinal struct { }
type RevisionDataOrphanProcessInit ¶ added in v0.0.2
type RevisionDataOrphanProcessInit struct { }
type RevisionDataSideChainExtendFinal ¶ added in v0.0.2
type RevisionDataSideChainExtendInit ¶ added in v0.0.2
type RevisionDataSideChainExtendInit struct {
ForkParentBlockHash string `json:"fork_parent_block_hash"`
}
type RevisionType ¶
type RevisionType int
const ( RevisionTypeBlockReceive RevisionType = iota RevisionTypeBlockVerify RevisionTypeOrphanProcess RevisionTypeOrphanExtend RevisionTypeMainChainExtend RevisionTypeSideChainExtend RevisionTypeChainSwap RevisionTypeChainVerify RevisionTypeUnknown )
每一种 Type 都对应一种 RevisionData
type Snapshot ¶
type Snapshot struct { // for all snapshot ID string `json:"snapshot_id"` // 19+1+2+1+10:init timestamp string + chain id + chain height TargetChainID string `json:"target_chain_id"` TargetChainHeight int32 `json:"target_chain_height"` Type SnapshotType `json:"snapshot_type"` Timestamp common.Timestamp `json:"timestamp"` State *BestState `json:"state"` // 当前先用 any,目前不包括任何信息,后面可以加 // for init and final snapshot BlockHash string `json:"block_hash"` IsOrphan bool `json:"is_orphan"` RevisionList []*Revision `json:"revision_list"` EventOrphanList []*EventOrphan `json:"event_orphan_list"` }
Snapshot 代表一次完整的区块同步流程,主要由一系列的 Revision 组成, 输出两次,初始化一次,结束一次,之间所有 ID 一致的 Revision 都属于这个 Snapshot, 在 Resolver 处会将一对 Snapshot 合并为一个,然后写入数据库
func NewInitSnapshot ¶
func NewSyncSnapshot ¶
func (*Snapshot) CommitOrphanEvent ¶ added in v0.0.2
func (s *Snapshot) CommitOrphanEvent(eventOrphan *EventOrphan)
CommitOrphanEvent 被 init snapshot 调用
func (*Snapshot) CommitRevision ¶
CommitRevision 被 init snapshot 调用
type SnapshotType ¶
type SnapshotType int
Click to show internal directories.
Click to hide internal directories.