p2p: rework protocol API

This commit is contained in:
Felix Lange
2014-11-04 13:21:44 +01:00
parent 8cf9ed0ea5
commit f38052c499
14 changed files with 1042 additions and 1307 deletions

View File

@ -9,10 +9,9 @@ type ErrorCode int
const errorChanCapacity = 10
const (
PacketTooShort = iota
PacketTooLong = iota
PayloadTooShort
MagicTokenMismatch
EmptyPayload
ReadError
WriteError
MiscError
@ -31,10 +30,9 @@ const (
)
var errorToString = map[ErrorCode]string{
PacketTooShort: "Packet too short",
PacketTooLong: "Packet too long",
PayloadTooShort: "Payload too short",
MagicTokenMismatch: "Magic token mismatch",
EmptyPayload: "Empty payload",
ReadError: "Read error",
WriteError: "Write error",
MiscError: "Misc error",
@ -71,6 +69,6 @@ func (self *PeerError) Error() string {
return self.message
}
func NewPeerErrorChannel() chan *PeerError {
return make(chan *PeerError, errorChanCapacity)
func NewPeerErrorChannel() chan error {
return make(chan error, errorChanCapacity)
}