aboutsummaryrefslogtreecommitdiffstats
path: root/dex/protocol.go
diff options
context:
space:
mode:
authorSonic <sonic@dexon.org>2019-02-12 16:16:13 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:22 +0800
commit5ea856585a994390c0f22f11868086a985c1f3f7 (patch)
tree46e344ef50c5f41ba82503894f5aeeda6f017c1d /dex/protocol.go
parent003088b6787dae1b718785ddddfe361d2fe5c505 (diff)
downloadgo-tangerine-5ea856585a994390c0f22f11868086a985c1f3f7.tar
go-tangerine-5ea856585a994390c0f22f11868086a985c1f3f7.tar.gz
go-tangerine-5ea856585a994390c0f22f11868086a985c1f3f7.tar.bz2
go-tangerine-5ea856585a994390c0f22f11868086a985c1f3f7.tar.lz
go-tangerine-5ea856585a994390c0f22f11868086a985c1f3f7.tar.xz
go-tangerine-5ea856585a994390c0f22f11868086a985c1f3f7.tar.zst
go-tangerine-5ea856585a994390c0f22f11868086a985c1f3f7.zip
dex: Add a flag to GetBlockHeadersMsg and GetBlockBodiesMsg (#188)
* dex: Add a flag to GetBlockHeadersMsg and GetBlockBodiesMsg So that we can dispatch the response msg to fetcher or downloader easily. * fixup! dex: Add a flag to GetBlockHeadersMsg and GetBlockBodiesMsg
Diffstat (limited to 'dex/protocol.go')
-rw-r--r--dex/protocol.go27
1 files changed, 26 insertions, 1 deletions
diff --git a/dex/protocol.go b/dex/protocol.go
index 0cb00ada6..6ee02959a 100644
--- a/dex/protocol.go
+++ b/dex/protocol.go
@@ -113,6 +113,11 @@ const (
ErrSuspendedPeer
)
+const (
+ fetcherReq = uint8(iota)
+ downloaderReq
+)
+
func (e errCode) String() string {
return errorToString[int(e)]
}
@@ -195,6 +200,7 @@ type getBlockHeadersData struct {
Reverse bool // Query direction (false = rising towards latest, true = falling towards genesis)
WithGov bool
+ Flag uint8
}
// hashOrNumber is a combined field for specifying an origin block.
@@ -233,11 +239,27 @@ func (hn *hashOrNumber) DecodeRLP(s *rlp.Stream) error {
return err
}
+// headersData is the network packet for header content distribution.
+type headersData struct {
+ Flag uint8
+ Headers []*types.HeaderWithGovState
+}
+
// newBlockData is the network packet for the block propagation message.
type newBlockData struct {
Block *types.Block
}
+type getBlockBodiesData struct {
+ Flag uint8
+ Hashes rlp.RawValue
+}
+
+type blockBodiesDataRLP struct {
+ Flag uint8
+ Bodies []rlp.RawValue
+}
+
// blockBody represents the data content of a single block.
type blockBody struct {
Transactions []*types.Transaction // Transactions contained within a block
@@ -245,7 +267,10 @@ type blockBody struct {
}
// blockBodiesData is the network packet for block content distribution.
-type blockBodiesData []*blockBody
+type blockBodiesData struct {
+ Flag uint8
+ Bodies []*blockBody
+}
func rlpHash(x interface{}) (h common.Hash) {
hw := sha3.NewLegacyKeccak256()