Documentation ¶
Index ¶
- Constants
- Variables
- type AccountblockCallback
- type Broadcaster
- type Chain
- type Config
- type Fetcher
- type Filter
- type MsgHandler
- type Net
- type Peer
- func (p *Peer) FileAddress() *net2.TCPAddr
- func (p *Peer) Handshake(our *message.HandShake) error
- func (p *Peer) Info() *PeerInfo
- func (p *Peer) ReadHandshake() (their *message.HandShake, err error)
- func (p *Peer) SeeBlock(hash types.Hash)
- func (p *Peer) Send(code cmd, msgId uint64, payload p2p.Serializable) error
- func (p *Peer) SendAccountBlocks(bs []*ledger.AccountBlock, msgId uint64) (err error)
- func (p *Peer) SendNewAccountBlock(b *ledger.AccountBlock) (err error)
- func (p *Peer) SendNewSnapshotBlock(b *ledger.SnapshotBlock) (err error)
- func (p *Peer) SendSnapshotBlocks(bs []*ledger.SnapshotBlock, msgId uint64) (err error)
- func (p *Peer) SendSubLedger(bs []*ledger.SnapshotBlock, abs []*ledger.AccountBlock, msgId uint64) (err error)
- func (p *Peer) SetHead(head types.Hash, height uint64)
- type PeerInfo
- type Peers
- type Receiver
- type Request
- type RequestPool
- type SnapshotBlockCallback
- type Subscriber
- type SyncState
- type SyncStateCallback
- type SyncStateFeed
- type SyncStatus
- type Syncer
- type Verifier
Constants ¶
View Source
const ( HandshakeCode cmd = 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 )
View Source
const CmdSet = 2
View Source
const CmdSetName = "vite"
@section Cmd
View Source
const DefaultPort uint16 = 8484
View Source
const INIT_ID uint64 = 1
@section requestPool
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)
type Broadcaster ¶
type Broadcaster interface { BroadcastSnapshotBlock(block *ledger.SnapshotBlock) BroadcastSnapshotBlocks(blocks []*ledger.SnapshotBlock) BroadcastAccountBlock(block *ledger.AccountBlock) BroadcastAccountBlocks(blocks []*ledger.AccountBlock) }
@section Broadcaster
type Chain ¶
type Chain interface { // the second return value mean chunk befor/after file GetSubLedgerByHeight(start, count uint64, forward bool) ([]*ledger.CompressedFileMeta, [][2]uint64) GetSubLedgerByHash(origin *types.Hash, count uint64, forward bool) ([]*ledger.CompressedFileMeta, [][2]uint64, error) // query chunk GetConfirmSubLedger(start, end uint64) ([]*ledger.SnapshotBlock, map[types.Address][]*ledger.AccountBlock, error) GetSnapshotBlocksByHash(origin *types.Hash, count uint64, forward, content bool) ([]*ledger.SnapshotBlock, error) GetSnapshotBlocksByHeight(height, count uint64, forward, content bool) ([]*ledger.SnapshotBlock, error) // batcher 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) // single GetAccountBlockByHash(blockHash *types.Hash) (*ledger.AccountBlock, error) GetAccountBlockByHeight(addr *types.Address, height uint64) (*ledger.AccountBlock, error) GetLatestSnapshotBlock() *ledger.SnapshotBlock GetGenesisSnapshotBlock() *ledger.SnapshotBlock Compressor() *compress.Compressor }
all query include from block
type Fetcher ¶
type Fetcher interface { FetchSnapshotBlocks(start types.Hash, count uint64) // address is optional FetchAccountBlocks(start types.Hash, count uint64, address *types.Address) }
@section Broadcaster
type MsgHandler ¶
type Net ¶
type Net interface { Syncer Fetcher Broadcaster Receiver Protocols() []*p2p.Protocol Start(svr *p2p.Server) error Stop() }
@section Net
type Peer ¶
type Peer struct { *p2p.Peer ID string CmdSet uint64 // which cmdSet it belongs KnownBlocks *cuckoofilter.CuckooFilter // contains filtered or unexported fields }
func (*Peer) FileAddress ¶
func (*Peer) SendAccountBlocks ¶
func (p *Peer) SendAccountBlocks(bs []*ledger.AccountBlock, msgId uint64) (err error)
func (*Peer) SendNewAccountBlock ¶
func (p *Peer) SendNewAccountBlock(b *ledger.AccountBlock) (err error)
func (*Peer) SendNewSnapshotBlock ¶
func (p *Peer) SendNewSnapshotBlock(b *ledger.SnapshotBlock) (err error)
func (*Peer) SendSnapshotBlocks ¶
func (p *Peer) SendSnapshotBlocks(bs []*ledger.SnapshotBlock, msgId uint64) (err error)
func (*Peer) SendSubLedger ¶
func (p *Peer) SendSubLedger(bs []*ledger.SnapshotBlock, abs []*ledger.AccountBlock, msgId uint64) (err error)
type PeerInfo ¶
type Receiver ¶
type Receiver interface { ReceiveSnapshotBlocks(blocks []*ledger.SnapshotBlock) ReceiveAccountBlocks(blocks []*ledger.AccountBlock) ReceiveNewSnapshotBlock(block *ledger.SnapshotBlock) ReceiveNewAccountBlock(block *ledger.AccountBlock) SubscribeAccountBlock(fn AccountblockCallback) (subId int) // if subId is 0, then ignore UnsubscribeAccountBlock(subId int) // return the subId, use to unsubscibe // subId is always larger than 0 SubscribeSnapshotBlock(fn SnapshotBlockCallback) (subId int) // if subId is 0, then ignore UnsubscribeSnapshotBlock(subId int) }
@section Receiver
type RequestPool ¶
type SnapshotBlockCallback ¶
type SnapshotBlockCallback = func(block *ledger.SnapshotBlock)
@section Subscriber
type Subscriber ¶
type Subscriber interface { // return the subId, use to unsubscibe // subId is always larger than 0 SubscribeAccountBlock(fn AccountblockCallback) (subId int) // if subId is 0, then ignore UnsubscribeAccountBlock(subId int) // return the subId, use to unsubscibe // subId is always larger than 0 SubscribeSnapshotBlock(fn SnapshotBlockCallback) (subId int) // if subId is 0, then ignore UnsubscribeSnapshotBlock(subId int) // return the subId, use to unsubscibe // subId is always larger than 0 SubscribeSyncStatus(fn SyncStateCallback) (subId int) // if subId is 0, then ignore UnsubscribeSyncStatus(subId int) SyncState() SyncState }
type SyncStateCallback ¶
type SyncStateCallback = func(SyncState)
type SyncStateFeed ¶
type SyncStateFeed struct {
// contains filtered or unexported fields
}
func (*SyncStateFeed) Notify ¶
func (s *SyncStateFeed) Notify(st SyncState)
func (*SyncStateFeed) Sub ¶
func (s *SyncStateFeed) Sub(fn SyncStateCallback) int
func (*SyncStateFeed) Unsub ¶
func (s *SyncStateFeed) Unsub(subId int)
type Syncer ¶
type Syncer interface { Status() *SyncStatus SubscribeSyncStatus(fn SyncStateCallback) (subId int) UnsubscribeSyncStatus(subId int) SyncState() SyncState }
@section Syncer
type Verifier ¶
type Verifier interface {
VerifyforP2P(block *ledger.AccountBlock) bool
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.