Documentation ¶
Index ¶
- Constants
- Variables
- type AccountblockCallback
- type BlockSubscriber
- type Broadcaster
- type Chain
- type ChunkPoolStatus
- type ChunkReqStatus
- type ChunkResponse
- type Config
- type ExecutorStatus
- type Fetcher
- type File
- type FileClientStatus
- type FileConnStatus
- type FilePoolStatus
- type FileServerStatus
- type Files
- type Handler
- type InvalidHash
- type MockPeer
- func (mp *MockPeer) Disconnect(reason p2p.DiscReason)
- func (mp *MockPeer) FileAddress() *net2.TCPAddr
- func (mp *MockPeer) HasBlock(hash types.Hash) bool
- func (mp *MockPeer) Head() types.Hash
- func (mp *MockPeer) Height() uint64
- func (mp *MockPeer) ID() string
- func (mp *MockPeer) Info() PeerInfo
- func (mp *MockPeer) RemoteAddr() *net2.TCPAddr
- func (mp *MockPeer) Report(err error)
- func (mp *MockPeer) SeeBlock(hash types.Hash)
- func (mp *MockPeer) Send(code ViteCmd, msgId uint64, payload p2p.Serializable) (err error)
- func (mp *MockPeer) SendAccountBlocks(bs []*ledger.AccountBlock, msgId uint64) (err error)
- func (mp *MockPeer) SendMsg(msg *p2p.Msg) (err error)
- func (mp *MockPeer) SendNewAccountBlock(b *ledger.AccountBlock) (err error)
- func (mp *MockPeer) SendNewSnapshotBlock(b *ledger.SnapshotBlock) (err error)
- func (mp *MockPeer) SendSnapshotBlocks(bs []*ledger.SnapshotBlock, msgId uint64) (err error)
- func (mp *MockPeer) SetHead(head types.Hash, height uint64)
- type MsgHandler
- type MsgIder
- type Net
- type NodeInfo
- type Peer
- type PeerInfo
- type SnapshotBlockCallback
- type Subscriber
- type SyncDetail
- type SyncState
- type SyncStateCallback
- type SyncStateSubscriber
- type SyncStatus
- type Syncer
- type Task
- type Verifier
- type ViteCmd
Constants ¶
View Source
const CmdSet = 2
View Source
const DefaultPort uint16 = 8484
View Source
const Vite = "vite"
Variables ¶
View Source
var NULL_ADDRESS = types.Address{}
Functions ¶
This section is empty.
Types ¶
type AccountblockCallback ¶
type AccountblockCallback = func(addr types.Address, block *ledger.AccountBlock, source types.BlockSource)
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 a 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 { GetSubLedgerByHeight(start, count uint64, forward bool) ([]*ledger.CompressedFileMeta, [][2]uint64) GetSubLedgerByHash(origin *types.Hash, count uint64, forward bool) ([]*ledger.CompressedFileMeta, [][2]uint64, error) GetConfirmSubLedger(start, end uint64) ([]*ledger.SnapshotBlock, map[types.Address][]*ledger.AccountBlock, error) GetSnapshotBlockByHeight(height uint64) (*ledger.SnapshotBlock, error) GetSnapshotBlockByHash(hash *types.Hash) (*ledger.SnapshotBlock, error) GetSnapshotBlocksByHash(origin *types.Hash, count uint64, forward, content bool) ([]*ledger.SnapshotBlock, error) GetSnapshotBlocksByHeight(height, count uint64, forward, content bool) ([]*ledger.SnapshotBlock, error) GetAccountBlockByHash(blockHash *types.Hash) (*ledger.AccountBlock, error) GetAccountBlockByHeight(addr *types.Address, height uint64) (*ledger.AccountBlock, error) GetAccountBlocksByHash(addr types.Address, origin *types.Hash, count uint64, forward bool) ([]*ledger.AccountBlock, error) GetAccountBlocksByHeight(addr types.Address, start, count uint64, forward bool) ([]*ledger.AccountBlock, error) GetLatestSnapshotBlock() *ledger.SnapshotBlock GetGenesisSnapshotBlock() *ledger.SnapshotBlock // Compressor could compress/uncompress a file Compressor() *compress.Compressor }
type ChunkPoolStatus ¶ added in v1.3.0
type ChunkPoolStatus struct {
Request []ChunkReqStatus
}
type ChunkReqStatus ¶ added in v1.3.0
type ChunkResponse ¶ added in v1.3.0
type ChunkResponse struct {
From, To uint64
}
type ExecutorStatus ¶ added in v1.3.0
type ExecutorStatus struct {
Tasks []string
}
type Fetcher ¶
type Fetcher interface { FetchSnapshotBlocks(start types.Hash, 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 File ¶ added in v1.3.0
type File = *ledger.CompressedFileMeta
type FileClientStatus ¶ added in v1.3.0
type FileClientStatus struct { FPool FilePoolStatus Queue []File }
type FileConnStatus ¶ added in v1.3.0
type FilePoolStatus ¶ added in v1.3.0
type FilePoolStatus struct {
Conns []FileConnStatus
}
type FileServerStatus ¶ added in v1.3.0
type FileServerStatus struct {
Conns []string
}
type Handler ¶ added in v1.3.0
type Handler func(msgId uint64, payload p2p.Serializable)
type InvalidHash ¶ added in v1.3.0
type InvalidHash struct {
HashList []string `json:"hashList"`
}
type MockPeer ¶ added in v1.3.0
func NewMockPeer ¶ added in v1.3.0
func NewMockPeer() *MockPeer
func (*MockPeer) Disconnect ¶ added in v1.3.0
func (mp *MockPeer) Disconnect(reason p2p.DiscReason)
func (*MockPeer) FileAddress ¶ added in v1.3.0
func (*MockPeer) RemoteAddr ¶ added in v1.3.0
func (*MockPeer) SendAccountBlocks ¶ added in v1.3.0
func (mp *MockPeer) SendAccountBlocks(bs []*ledger.AccountBlock, msgId uint64) (err error)
func (*MockPeer) SendNewAccountBlock ¶ added in v1.3.0
func (mp *MockPeer) SendNewAccountBlock(b *ledger.AccountBlock) (err error)
func (*MockPeer) SendNewSnapshotBlock ¶ added in v1.3.0
func (mp *MockPeer) SendNewSnapshotBlock(b *ledger.SnapshotBlock) (err error)
func (*MockPeer) SendSnapshotBlocks ¶ added in v1.3.0
func (mp *MockPeer) SendSnapshotBlocks(bs []*ledger.SnapshotBlock, msgId uint64) (err error)
type MsgHandler ¶
type Net ¶
type Peer ¶
type Peer interface { RemoteAddr() *net2.TCPAddr FileAddress() *net2.TCPAddr SetHead(head types.Hash, height uint64) SeeBlock(hash types.Hash) SendSnapshotBlocks(bs []*ledger.SnapshotBlock, msgId uint64) (err error) SendAccountBlocks(bs []*ledger.AccountBlock, msgId uint64) (err error) SendNewSnapshotBlock(b *ledger.SnapshotBlock) (err error) SendNewAccountBlock(b *ledger.AccountBlock) (err error) Send(code ViteCmd, msgId uint64, payload p2p.Serializable) (err error) SendMsg(msg *p2p.Msg) (err error) Report(err error) ID() string Height() uint64 Head() types.Hash Disconnect(reason p2p.DiscReason) Info() PeerInfo HasBlock(hash types.Hash) bool }
Peer for protocol handle, not p2p Peer.
type PeerInfo ¶
type SnapshotBlockCallback ¶
type SnapshotBlockCallback = func(block *ledger.SnapshotBlock, source types.BlockSource)
source is use to statistic where the block come from, broadcast, sync or fetch
type Subscriber ¶
type Subscriber interface { BlockSubscriber SyncStateSubscriber }
type SyncDetail ¶ added in v1.3.0
type SyncDetail struct { SyncStatus ExecutorStatus FileClientStatus ChunkPoolStatus }
type SyncStateCallback ¶
type SyncStateCallback = func(SyncState)
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 SyncState() SyncState }
type SyncStatus ¶
type Syncer ¶
type Syncer interface { SyncStateSubscriber Status() SyncStatus Detail() SyncDetail }
A Syncer implementation can synchronise blocks to peers
type Verifier ¶
type Verifier interface { VerifyNetSb(block *ledger.SnapshotBlock) error VerifyNetAb(block *ledger.AccountBlock) error }
type ViteCmd ¶
const ( HandshakeCode ViteCmd = iota StatusCode ForkCode // tell peer it has forked, use for respond GetSnapshotBlocksCode GetSubLedgerCode GetSnapshotBlocksCode // get snapshotblocks without content GetSnapshotBlocksContentCode GetFullSnapshotBlocksCode // get snapshotblocks with content GetSnapshotBlocksByHashCode // a batch of hash GetSnapshotBlocksContentByHashCode GetFullSnapshotBlocksByHashCode GetAccountBlocksCode // query single AccountChain GetMultiAccountBlocksCode // query multi AccountChain GetAccountBlocksByHashCode // query accountBlocks by hashList GetFilesCode GetChunkCode SubLedgerCode FileListCode SnapshotBlocksCode SnapshotBlocksContentCode FullSnapshotBlocksCode AccountBlocksCode NewSnapshotBlockCode NewAccountBlockCode ExceptionCode = 127 )
Source Files ¶
Click to show internal directories.
Click to hide internal directories.