aboutsummaryrefslogtreecommitdiffstats
path: root/eth/protocol.go
diff options
context:
space:
mode:
Diffstat (limited to 'eth/protocol.go')
-rw-r--r--eth/protocol.go54
1 files changed, 49 insertions, 5 deletions
diff --git a/eth/protocol.go b/eth/protocol.go
index 57805d9bd..704a637e2 100644
--- a/eth/protocol.go
+++ b/eth/protocol.go
@@ -1,3 +1,19 @@
+// Copyright 2014 The go-ethereum Authors
+// This file is part of go-ethereum.
+//
+// go-ethereum is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// go-ethereum is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+
package eth
import (
@@ -7,11 +23,15 @@ import (
"github.com/ethereum/go-ethereum/core/types"
)
+// Supported versions of the eth protocol (first is primary).
+var ProtocolVersions = []uint{61, 60}
+
+// Number of implemented message corresponding to different protocol versions.
+var ProtocolLengths = []uint64{9, 8}
+
const (
- ProtocolVersion = 60
NetworkId = 0
- ProtocolLength = uint64(8)
- ProtocolMaxMsgSize = 10 * 1024 * 1024
+ ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message
)
// eth protocol message codes
@@ -24,6 +44,7 @@ const (
GetBlocksMsg
BlocksMsg
NewBlockMsg
+ GetBlockHashesFromNumberMsg
)
type errCode int
@@ -72,8 +93,31 @@ type chainManager interface {
Status() (td *big.Int, currentBlock common.Hash, genesisBlock common.Hash)
}
-// message structs used for RLP serialization
-type newBlockMsgData struct {
+// statusData is the network packet for the status message.
+type statusData struct {
+ ProtocolVersion uint32
+ NetworkId uint32
+ TD *big.Int
+ CurrentBlock common.Hash
+ GenesisBlock common.Hash
+}
+
+// getBlockHashesData is the network packet for the hash based block retrieval
+// message.
+type getBlockHashesData struct {
+ Hash common.Hash
+ Amount uint64
+}
+
+// getBlockHashesFromNumberData is the network packet for the number based block
+// retrieval message.
+type getBlockHashesFromNumberData struct {
+ Number uint64
+ Amount uint64
+}
+
+// newBlockData is the network packet for the block propagation message.
+type newBlockData struct {
Block *types.Block
TD *big.Int
}