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