@@ -10,27 +10,32 @@ var (
1010 collationsizelimit = int64 (2 ^ 20 )
1111 chunkSize = int64 (32 )
1212 indicatorSize = int64 (1 )
13+ numberOfChunks = collationsizelimit / chunkSize
1314 chunkDataSize = chunkSize - indicatorSize
15+ totalDatasize = numberOfChunks * chunkDataSize
1416)
1517
18+ func (cb collationbody ) length () int64 {
19+
20+ return int64 (len (cb ))
21+ }
22+
1623/* Validate that the collation body is within its bounds and if
1724the size of the body is below the limit it is simply appended
1825till it reaches the required limit */
1926
2027func (cb collationbody ) validateBody () error {
2128
22- length := int64 (len (cb ))
23-
24- if length == 0 {
29+ if cb .length () == 0 {
2530 return fmt .Errorf ("Collation Body has to be a non-zero value" )
2631 }
2732
28- if length > collationsizelimit {
33+ if cb . length () > totalDatasize {
2934 return fmt .Errorf ("Collation Body is over the size limit" )
3035 }
3136
32- if length < collationsizelimit {
33- x := make ([]byte , (collationsizelimit - length ))
37+ if cb . length () < totalDatasize {
38+ x := make ([]byte , (totalDatasize - cb . length () ))
3439 cb = append (cb , x ... )
3540 fmt .Printf ("%b" , x )
3641
@@ -39,12 +44,17 @@ func (cb collationbody) validateBody() error {
3944 return nil
4045}
4146
42- func main () {
47+ /*
48+ add
49+ */
50+
51+ func (cb collationbody ) ParseBlob () {
52+ terminalLength := cb .length () % chunkDataSize
53+ chunksNumber := cb .length () / chunkDataSize
4354
44- x := []byte {'h' , 'e' , 'g' , 'g' }
45- t := x .validateBody ()
46- fmt .Printf ("%b %s" , x , t )
55+ if terminalLength != 0 {
4756
57+ }
4858}
4959
5060/*
0 commit comments