@@ -6,19 +6,13 @@ import (
6
6
"io"
7
7
)
8
8
9
- func (ss * DomainSet ) WriteBin (w io.Writer , count int64 ) (err error ) {
9
+ func (ss * DomainSet ) WriteBin (w io.Writer ) (err error ) {
10
10
// version
11
11
_ , err = w .Write ([]byte {1 })
12
12
if err != nil {
13
13
return err
14
14
}
15
15
16
- // count
17
- err = binary .Write (w , binary .BigEndian , count )
18
- if err != nil {
19
- return err
20
- }
21
-
22
16
// leaves
23
17
err = binary .Write (w , binary .BigEndian , int64 (len (ss .leaves )))
24
18
if err != nil {
@@ -56,21 +50,15 @@ func (ss *DomainSet) WriteBin(w io.Writer, count int64) (err error) {
56
50
return nil
57
51
}
58
52
59
- func ReadDomainSetBin (r io.Reader ) (ds * DomainSet , count int64 , err error ) {
53
+ func ReadDomainSetBin (r io.Reader ) (ds * DomainSet , err error ) {
60
54
// version
61
55
version := make ([]byte , 1 )
62
56
_ , err = io .ReadFull (r , version )
63
57
if err != nil {
64
- return nil , 0 , err
58
+ return nil , err
65
59
}
66
60
if version [0 ] != 1 {
67
- return nil , 0 , errors .New ("version is invalid" )
68
- }
69
-
70
- // count
71
- err = binary .Read (r , binary .BigEndian , & count )
72
- if err != nil {
73
- return nil , 0 , err
61
+ return nil , errors .New ("version is invalid" )
74
62
}
75
63
76
64
ds = & DomainSet {}
@@ -79,49 +67,49 @@ func ReadDomainSetBin(r io.Reader) (ds *DomainSet, count int64, err error) {
79
67
// leaves
80
68
err = binary .Read (r , binary .BigEndian , & length )
81
69
if err != nil {
82
- return nil , 0 , err
70
+ return nil , err
83
71
}
84
72
if length < 1 {
85
- return nil , 0 , errors .New ("length is invalid" )
73
+ return nil , errors .New ("length is invalid" )
86
74
}
87
75
ds .leaves = make ([]uint64 , length )
88
76
for i := int64 (0 ); i < length ; i ++ {
89
77
err = binary .Read (r , binary .BigEndian , & ds .leaves [i ])
90
78
if err != nil {
91
- return nil , 0 , err
79
+ return nil , err
92
80
}
93
81
}
94
82
95
83
// labelBitmap
96
84
err = binary .Read (r , binary .BigEndian , & length )
97
85
if err != nil {
98
- return nil , 0 , err
86
+ return nil , err
99
87
}
100
88
if length < 1 {
101
- return nil , 0 , errors .New ("length is invalid" )
89
+ return nil , errors .New ("length is invalid" )
102
90
}
103
91
ds .labelBitmap = make ([]uint64 , length )
104
92
for i := int64 (0 ); i < length ; i ++ {
105
93
err = binary .Read (r , binary .BigEndian , & ds .labelBitmap [i ])
106
94
if err != nil {
107
- return nil , 0 , err
95
+ return nil , err
108
96
}
109
97
}
110
98
111
99
// labels
112
100
err = binary .Read (r , binary .BigEndian , & length )
113
101
if err != nil {
114
- return nil , 0 , err
102
+ return nil , err
115
103
}
116
104
if length < 1 {
117
- return nil , 0 , errors .New ("length is invalid" )
105
+ return nil , errors .New ("length is invalid" )
118
106
}
119
107
ds .labels = make ([]byte , length )
120
108
_ , err = io .ReadFull (r , ds .labels )
121
109
if err != nil {
122
- return nil , 0 , err
110
+ return nil , err
123
111
}
124
112
125
113
ds .init ()
126
- return ds , count , nil
114
+ return ds , nil
127
115
}
0 commit comments