diff options
author | Sonic <sonic@dexon.org> | 2019-02-12 16:16:13 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:57 +0800 |
commit | b3622c655271c594d19c78eb92b26c1f539ea31b (patch) | |
tree | a90ec42b2fdb9da67556b12e69e732d0c664a18f /dex/protocol.go | |
parent | 4df167061e22b7e8e8e54eaf6e5d08fd30f884a2 (diff) | |
download | dexon-b3622c655271c594d19c78eb92b26c1f539ea31b.tar dexon-b3622c655271c594d19c78eb92b26c1f539ea31b.tar.gz dexon-b3622c655271c594d19c78eb92b26c1f539ea31b.tar.bz2 dexon-b3622c655271c594d19c78eb92b26c1f539ea31b.tar.lz dexon-b3622c655271c594d19c78eb92b26c1f539ea31b.tar.xz dexon-b3622c655271c594d19c78eb92b26c1f539ea31b.tar.zst dexon-b3622c655271c594d19c78eb92b26c1f539ea31b.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.go | 27 |
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() |