-
Notifications
You must be signed in to change notification settings - Fork 100
/
define.go
93 lines (76 loc) · 2.13 KB
/
define.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* @file
* @copyright defined in go-seele/LICENSE
*/
package light
import (
"math/big"
"time"
"github.com/seeleteam/go-seele/common"
"github.com/seeleteam/go-seele/core/types"
)
const (
// LightProtoName protoName of Seele service
LightProtoName = "lightSeele"
// LightSeeleVersion version number of Seele protocol
LightSeeleVersion uint = 1
// MaxBlockHashRequest maximum hashes to request per message
MaxBlockHashRequest uint64 = 1024
// MaxBlockHeaderRequest maximum headers to request per message
MaxBlockHeaderRequest uint64 = 256
// MaxGapForAnnounce sends AnnounceQuery message if gap is more than this value
MaxGapForAnnounce uint64 = 256
// MinHashesCached minimum items cached in peer for client mode
MinHashesCached uint64 = 256
forceSyncInterval = time.Second * 13 // interval time of synchronising with remote peer
)
// statusData the structure for peers to exchange status
type statusData struct {
ProtocolVersion uint32
NetworkID string
IsServer bool // whether server mode
TD *big.Int
CurrentBlock common.Hash
CurrentBlockNum uint64
GenesisBlock common.Hash
}
// AnnounceQuery header of AnnounceQuery request
type AnnounceQuery struct {
Magic uint32
Begin uint64
End uint64
}
// AnnounceBody body of AnnounceQuery response
type AnnounceBody struct {
Magic uint32
TD *big.Int
CurrentBlock common.Hash
CurrentBlockNum uint64
BlockNumArr []uint64
HeaderArr []common.Hash
}
// HeaderHashSyncQuery header of HeaderHashSyncQuery request
type HeaderHashSyncQuery struct {
Magic uint32
BeginNum uint64
}
// HeaderHashSync body of HeaderHashSyncQuery response
type HeaderHashSync struct {
Magic uint32
TD *big.Int
CurrentBlock common.Hash
CurrentBlockNum uint64
BeginNum uint64
HeaderArr []common.Hash
}
// DownloadHeaderQuery header of DownloadHeaderQuery request
type DownloadHeaderQuery struct {
ReqID uint32
BeginNum uint64
}
// DownloadHeader body of DownloadHeaderQuery response
type DownloadHeader struct {
ReqID uint32
HasFinished bool
Hearders []*types.BlockHeader
}