Documentation ¶
Index ¶
- Constants
- type AccountBlockCallback
- type BlockSubscriber
- type Broadcaster
- type Chain
- type Chunk
- type ChunkReader
- type Chunks
- type Config
- type Connector
- type Consensus
- type DownloaderStatus
- type Fetcher
- type FilePoolStatus
- type FileServerStatus
- type InvalidHash
- type IrreversibleReader
- type MsgIder
- type Net
- type NodeInfo
- type Peer
- type PeerInfo
- type SnapshotBlockCallback
- type Subscriber
- type SyncConnectionStatus
- type SyncDetail
- type SyncState
- type SyncStateCallback
- type SyncStateSubscriber
- type SyncStatus
- type Syncer
- type Tracer
- type Verifier
Examples ¶
Constants ¶
const DefaultFilePort = 8484
const DefaultForwardStrategy = "cross"
const ID = 1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountBlockCallback ¶
type AccountBlockCallback = func(addr types.Address, block *ledger.AccountBlock, source types.BlockSource)
AccountBlockCallback will be invoked when receive a block, source mark where the block come from: broadcast, sync or fetch
type BlockSubscriber ¶ added in v1.3.0
type BlockSubscriber interface { // SubscribeAccountBlock return the subId, always larger than 0, use to unsubscribe SubscribeAccountBlock(fn AccountBlockCallback) (subId int) // UnsubscribeAccountBlock if subId is 0, then ignore UnsubscribeAccountBlock(subId int) // SubscribeSnapshotBlock return the subId, always larger than 0, use to unsubscribe SubscribeSnapshotBlock(fn SnapshotBlockCallback) (subId int) // UnsubscribeSnapshotBlock if subId is 0, then ignore UnsubscribeSnapshotBlock(subId int) }
A BlockSubscriber implementation can be subscribed and Unsubscribed, when got chain block, should notify subscribers
type Broadcaster ¶
type Broadcaster interface { BroadcastSnapshotBlock(block *ledger.SnapshotBlock) BroadcastSnapshotBlocks(blocks []*ledger.SnapshotBlock) BroadcastAccountBlock(block *ledger.AccountBlock) BroadcastAccountBlocks(blocks []*ledger.AccountBlock) }
A Broadcaster implementation can send blocks to the peers connected
type Chain ¶
type Chain interface {
// contains filtered or unexported methods
}
type Chunk ¶
type Chunk struct { SnapshotChunks []ledger.SnapshotChunk SnapshotRange [2]*ledger.HashHeight AccountRange map[types.Address][2]*ledger.HashHeight HashMap map[types.Hash]struct{} Source types.BlockSource // contains filtered or unexported fields }
Chunk means a chain chunk, contains snapshot blocks and dependent account blocks, SnapshotRange means the chunk range, the first HashHeight is the prevHash and prevHeight. eg. Chunk is from 101 to 200, SnapshotChunks is [101 ... 200], but SnapshotRange is [100, 200]. AccountRange like SnapshotRange but describe every account chain. HashMap record all blocks hash in Chunk, it can quickly tell if a block is in the chunk.
type Config ¶
type Config struct { Single bool FileListenAddress string TraceEnabled bool ForwardStrategy string // default `cross` AccessControl string `json:"AccessControl"` // producer special any AccessAllowKeys []string `json:"AccessAllowKeys"` AccessDenyKeys []string `json:"AccessDenyKeys"` BlackBlockHashList []string MinePrivateKey ed25519.PrivateKey P2PPrivateKey ed25519.PrivateKey Chain Verifier }
type Consensus ¶
type DownloaderStatus ¶
type DownloaderStatus struct { Tasks []string `json:"tasks"` Connections []SyncConnectionStatus `json:"connections"` }
type Fetcher ¶
type Fetcher interface { FetchSnapshotBlocks(start types.Hash, count uint64) FetchSnapshotBlocksWithHeight(hash types.Hash, height uint64, count uint64) // FetchAccountBlocks address is optional FetchAccountBlocks(start types.Hash, count uint64, address *types.Address) // FetchAccountBlocksWithHeight add snapshot height FetchAccountBlocksWithHeight(start types.Hash, count uint64, address *types.Address, sHeight uint64) }
A Fetcher implementation can request the wanted blocks to peers
type FilePoolStatus ¶ added in v1.3.0
type FilePoolStatus struct {
Connections []SyncConnectionStatus `json:"connections"`
}
type FileServerStatus ¶ added in v1.3.0
type FileServerStatus struct {
Connections []SyncConnectionStatus `json:"connections"`
}
type IrreversibleReader ¶
type IrreversibleReader interface {
GetIrreversibleBlock() *ledger.SnapshotBlock
}
type Net ¶
type Net interface { p2p.Protocol Syncer Fetcher Broadcaster BlockSubscriber Init(consensus Consensus, irreader IrreversibleReader) Start(svr p2p.P2P) error Stop() error Info() NodeInfo Trace() }
type NodeInfo ¶
type Peer ¶
Peer for protocol handle, not p2p Peer.
type PeerInfo ¶
PeerInfo is for api
type SnapshotBlockCallback ¶
type SnapshotBlockCallback = func(block *ledger.SnapshotBlock, source types.BlockSource)
SnapshotBlockCallback will be invoked when receive a block, source mark where the block come from: broadcast, sync or fetch
type Subscriber ¶
type Subscriber interface { BlockSubscriber SyncStateSubscriber }
type SyncConnectionStatus ¶
type SyncDetail ¶ added in v1.3.0
type SyncDetail struct { SyncStatus DownloaderStatus Chunks [][2]*ledger.HashHeight `json:"chunks"` Caches interfaces.SegmentList `json:"caches"` }
type SyncState ¶
type SyncState byte
type SyncStateCallback ¶
type SyncStateCallback = func(SyncState)
SyncStateCallback will be invoked when sync state change, the param is state after change
type SyncStateSubscriber ¶ added in v1.3.0
type SyncStateSubscriber interface { // SubscribeSyncStatus return the subId, always larger than 0, use to unsubscribe SubscribeSyncStatus(fn SyncStateCallback) (subId int) // UnsubscribeSyncStatus if subId is 0, then ignore UnsubscribeSyncStatus(subId int) // SyncState return the latest sync state_bak SyncState() SyncState }
type SyncStatus ¶
type Syncer ¶
type Syncer interface { SyncStateSubscriber ChunkReader Status() SyncStatus Detail() SyncDetail }
A Syncer implementation can synchronise blocks to peers
type Tracer ¶
type Tracer interface { Trace() // contains filtered or unexported methods }
type Verifier ¶
type Verifier interface { VerifyNetSb(block *ledger.SnapshotBlock) error VerifyNetAb(block *ledger.AccountBlock) error }