refactor: make protocol message tags a separate type

This commit is contained in:
Matthias Radestock committed 2015-01-20 21:51:18 +00:00
1 parent a1ef2def2b
commit 644697977b
2 files changed
+11 -9

No files matched your search

+1 -1
View File
@@ -530,7 +530,7 @@ func (conn *LocalConnection) receiveTCP(decoder *gob.Decoder) {
continue continue
} }
payload := msg[1:] payload := msg[1:]
switch msg[0] { switch ProtocolMsg(msg[0]) {
case ProtocolConnectionEstablished: case ProtocolConnectionEstablished:
// We sent fast heartbeats to the remote peer, which has // We sent fast heartbeats to the remote peer, which has
// now received at least one of them and told us via this // now received at least one of them and told us via this
+10 -8
View File
@@ -5,8 +5,10 @@ const (
ProtocolVersion = 10 ProtocolVersion = 10
) )
type ProtocolMsg byte
const ( const (
ProtocolConnectionEstablished = iota ProtocolConnectionEstablished ProtocolMsg = iota
ProtocolFragmentationReceived ProtocolFragmentationReceived
ProtocolStartFragmentationTest ProtocolStartFragmentationTest
ProtocolNonce ProtocolNonce
@@ -16,11 +18,11 @@ const (
) )
var ( var (
ProtocolConnectionEstablishedByte = []byte{ProtocolConnectionEstablished} ProtocolConnectionEstablishedByte = []byte{byte(ProtocolConnectionEstablished)}
ProtocolFragmentationReceivedByte = []byte{ProtocolFragmentationReceived} ProtocolFragmentationReceivedByte = []byte{byte(ProtocolFragmentationReceived)}
ProtocolStartFragmentationTestByte = []byte{ProtocolStartFragmentationTest} ProtocolStartFragmentationTestByte = []byte{byte(ProtocolStartFragmentationTest)}
ProtocolNonceByte = []byte{ProtocolNonce} ProtocolNonceByte = []byte{byte(ProtocolNonce)}
ProtocolFetchAllByte = []byte{ProtocolFetchAll} ProtocolFetchAllByte = []byte{byte(ProtocolFetchAll)}
ProtocolUpdateByte = []byte{ProtocolUpdate} ProtocolUpdateByte = []byte{byte(ProtocolUpdate)}
ProtocolPMTUVerifiedByte = []byte{ProtocolPMTUVerified} ProtocolPMTUVerifiedByte = []byte{byte(ProtocolPMTUVerified)}
) )