dc5de1fa6d
[Peer] - Closes #239 - moved response handlers to their own functions - removed DefaultConfig from LocalConfig file - passed peer as a parameter to all response handlers - added peer start height - refactored NewPeer function to be more concise and clear - removed empty lines at end of functions - Added AddMessage/RemoveMessage for Detector in outgoing and ingoing requests for Block and Headers
31 lines
966 B
Go
31 lines
966 B
Go
package peer
|
|
|
|
import (
|
|
"github.com/CityOfZion/neo-go/pkg/wire/payload"
|
|
"github.com/CityOfZion/neo-go/pkg/wire/protocol"
|
|
)
|
|
|
|
// LocalConfig specifies the properties that should be available for each remote peer
|
|
type LocalConfig struct {
|
|
Net protocol.Magic
|
|
UserAgent string
|
|
Services protocol.ServiceFlag
|
|
Nonce uint32
|
|
ProtocolVer protocol.Version
|
|
Relay bool
|
|
Port uint16
|
|
|
|
// pointer to config will keep the startheight updated
|
|
StartHeight func() uint32
|
|
|
|
// Response Handlers
|
|
OnHeader func(*Peer, *payload.HeadersMessage)
|
|
OnGetHeaders func(*Peer, *payload.GetHeadersMessage)
|
|
OnAddr func(*Peer, *payload.AddrMessage)
|
|
OnGetAddr func(*Peer, *payload.GetAddrMessage)
|
|
OnInv func(*Peer, *payload.InvMessage)
|
|
OnGetData func(*Peer, *payload.GetDataMessage)
|
|
OnBlock func(*Peer, *payload.BlockMessage)
|
|
OnGetBlocks func(*Peer, *payload.GetBlocksMessage)
|
|
OnTx func(*Peer, *payload.TXMessage)
|
|
}
|