Documentation ¶
Index ¶
- Constants
- func CalculateChallengeHash(challenge HandshakeChallenge, consensusId types.Hash, solution uint64) (hash types.Hash, ok bool)
- func FindChallengeSolution(challenge HandshakeChallenge, consensusId types.Hash, stop *atomic.Bool) (solution uint64, hash types.Hash, ok bool)
- type BanEntry
- type Client
- func (c *Client) Ban(duration time.Duration, err error)
- func (c *Client) BanError() error
- func (c *Client) Close() bool
- func (c *Client) IsGood() bool
- func (c *Client) OnAfterHandshake()
- func (c *Client) OnConnection()
- func (c *Client) Read(buf []byte) (n int, err error)
- func (c *Client) ReadByte() (b byte, err error)
- func (c *Client) SendBlockNotify(id types.Hash)
- func (c *Client) SendBlockRequest(id types.Hash)
- func (c *Client) SendBlockRequestWithBound(id types.Hash, bound int) bool
- func (c *Client) SendBlockResponse(block *sidechain.PoolBlock)
- func (c *Client) SendListenPort()
- func (c *Client) SendMessage(message *ClientMessage)
- func (c *Client) SendMissingBlockRequest(hash types.Hash)
- func (c *Client) SendMissingBlockRequestAtRandom(hash types.Hash, allowedClients []*Client) []*Client
- func (c *Client) SendPeerListRequest()
- func (c *Client) SendPeerListResponse(list []netip.AddrPort)
- func (c *Client) SendUniqueBlockRequest(hash types.Hash)
- func (c *Client) SetError(err error)
- type ClientMessage
- type HandshakeChallenge
- type InternalMessageId
- type MessageId
- type P2PoolInterface
- type PeerList
- type PeerListEntry
- type Server
- func (s *Server) AddCachedBlock(block *sidechain.PoolBlock)
- func (s *Server) AddToPeerList(addressPort netip.AddrPort)
- func (s *Server) Ban(ip netip.Addr, duration time.Duration, err error)
- func (s *Server) Broadcast(block *sidechain.PoolBlock)
- func (s *Server) CleanupBanList()
- func (s *Server) ClearCachedBlocks()
- func (s *Server) Clients() []*Client
- func (s *Server) Close()
- func (s *Server) Connect(addrPort netip.AddrPort) error
- func (s *Server) Consensus() *sidechain.Consensus
- func (s *Server) DirectConnect(addrPort netip.AddrPort) (*Client, error)
- func (s *Server) DownloadMissingBlocks()
- func (s *Server) ExternalListenPort() uint16
- func (s *Server) GetAddressConnected(addr netip.Addr) (result []*Client)
- func (s *Server) GetAddressConnectedPrefix(prefix netip.Prefix) (result []*Client)
- func (s *Server) GetCachedBlock(hash types.Hash) *sidechain.PoolBlock
- func (s *Server) GetFastestClient() *Client
- func (s *Server) GetOutgoingIPv6() []netip.Addr
- func (s *Server) IsBanned(ip netip.Addr) (bool, *BanEntry)
- func (s *Server) Listen() (err error)
- func (s *Server) ListenPort() uint16
- func (s *Server) MainChain() *mainchain.MainChain
- func (s *Server) PeerId() uint64
- func (s *Server) PeerList() PeerList
- func (s *Server) RefreshOutgoingIPv6()
- func (s *Server) RemoveFromPeerList(ip netip.Addr)
- func (s *Server) SideChain() *sidechain.SideChain
- func (s *Server) UpdateClientConnections()
- func (s *Server) UpdateInPeerList(addressPort netip.AddrPort)
- func (s *Server) UpdatePeerList()
- func (s *Server) VersionInformation() *p2pooltypes.PeerVersionInformation
Constants ¶
View Source
const ( MessageHandshakeChallenge = MessageId(iota) MessageHandshakeSolution MessageListenPort MessageBlockRequest MessageBlockResponse MessageBlockBroadcast MessagePeerListRequest MessagePeerListResponse // MessageBlockBroadcastCompact Protocol 1.1 MessageBlockBroadcastCompact // MessageBlockNotify Protocol 1.2 MessageBlockNotify MessageInternal = 0xff )
from p2p_server.h
View Source
const DefaultBanTime = time.Second * 600
View Source
const HandshakeChallengeDifficulty = 10000
View Source
const HandshakeChallengeSize = 8
View Source
const MaxBufferSize = 128 * 1024
View Source
const PeerListResponseMaxPeers = 16
View Source
const PeerRequestDelay = 60
Variables ¶
This section is empty.
Functions ¶
func CalculateChallengeHash ¶
Types ¶
type Client ¶
type Client struct { // Peer general static-ish information PeerId atomic.Uint64 VersionInformation p2pooltypes.PeerVersionInformation ListenPort atomic.Uint32 ConnectionTime time.Time AddressPort netip.AddrPort // Peer general dynamic-ish information BroadcastMaxHeight atomic.Uint64 PingDuration atomic.Uint64 // Internal values Owner *Server Connection *net.TCPConn LastBroadcastTimestamp atomic.Uint64 LastBlockRequestTimestamp atomic.Uint64 LastIncomingPeerListRequestTime time.Time LastActiveTimestamp atomic.Uint64 LastPeerListRequestTimestamp atomic.Uint64 NextOutgoingPeerListRequestTimestamp atomic.Uint64 IsIncomingConnection bool Closed atomic.Bool //State properties HandshakeComplete atomic.Bool SentHandshakeSolution atomic.Bool LastKnownTip atomic.Pointer[sidechain.PoolBlock] BroadcastedHashes *utils.CircularBuffer[types.Hash] RequestedHashes *utils.CircularBuffer[types.Hash] // contains filtered or unexported fields }
func (*Client) OnAfterHandshake ¶
func (c *Client) OnAfterHandshake()
func (*Client) OnConnection ¶
func (c *Client) OnConnection()
func (*Client) SendBlockNotify ¶
func (*Client) SendBlockRequest ¶
func (*Client) SendBlockRequestWithBound ¶
func (*Client) SendBlockResponse ¶
func (*Client) SendListenPort ¶
func (c *Client) SendListenPort()
func (*Client) SendMessage ¶
func (c *Client) SendMessage(message *ClientMessage)
func (*Client) SendMissingBlockRequest ¶
func (*Client) SendMissingBlockRequestAtRandom ¶
func (*Client) SendPeerListRequest ¶
func (c *Client) SendPeerListRequest()
func (*Client) SendPeerListResponse ¶
func (*Client) SendUniqueBlockRequest ¶
type ClientMessage ¶
type HandshakeChallenge ¶
type HandshakeChallenge [HandshakeChallengeSize]byte
type InternalMessageId ¶
type InternalMessageId uint64
type P2PoolInterface ¶
type PeerList ¶
type PeerList []*PeerListEntry
type PeerListEntry ¶
type Server ¶
type Server struct { MaxOutgoingPeers uint32 MaxIncomingPeers uint32 NumOutgoingConnections atomic.Int32 NumIncomingConnections atomic.Int32 PendingOutgoingConnections *utils.CircularBuffer[string] // contains filtered or unexported fields }
func (*Server) AddCachedBlock ¶
func (*Server) AddToPeerList ¶
func (*Server) CleanupBanList ¶
func (s *Server) CleanupBanList()
func (*Server) ClearCachedBlocks ¶
func (s *Server) ClearCachedBlocks()
func (*Server) DirectConnect ¶
func (*Server) DownloadMissingBlocks ¶
func (s *Server) DownloadMissingBlocks()
func (*Server) ExternalListenPort ¶
func (*Server) GetAddressConnected ¶
func (*Server) GetAddressConnectedPrefix ¶
func (*Server) GetCachedBlock ¶
func (*Server) GetFastestClient ¶
func (*Server) GetOutgoingIPv6 ¶
func (*Server) ListenPort ¶
func (*Server) RefreshOutgoingIPv6 ¶
func (s *Server) RefreshOutgoingIPv6()
func (*Server) RemoveFromPeerList ¶
func (*Server) UpdateClientConnections ¶
func (s *Server) UpdateClientConnections()
func (*Server) UpdateInPeerList ¶
func (*Server) UpdatePeerList ¶
func (s *Server) UpdatePeerList()
func (*Server) VersionInformation ¶
func (s *Server) VersionInformation() *p2pooltypes.PeerVersionInformation
Click to show internal directories.
Click to hide internal directories.