This repository has been archived by the owner on Aug 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
struct.go
82 lines (71 loc) · 2.12 KB
/
struct.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
package decenarch
/*
This holds the messages used to communicate with the service over the network.
*/
import (
cosiservice "gopkg.in/dedis/cothority.v2/ftcosi/service"
"gopkg.in/dedis/kyber.v2"
"gopkg.in/dedis/onet.v2"
"gopkg.in/dedis/onet.v2/network"
)
// We need to register all messages so the network knows how to handle them.
func init() {
for _, msg := range []interface{}{
SetupRequest{}, SetupResponse{},
SaveRequest{}, SaveResponse{},
RetrieveRequest{}, RetrieveResponse{},
} {
network.RegisterMessage(msg)
}
}
const (
// ErrorParse indicates an error while parsing the protobuf-file.
ErrorParse = iota + 4000
// CachePath indicates where to cache retrieved websites
CachePath = "/tmp/cocache"
)
type SetupRequest struct {
Roster *onet.Roster
}
type SetupResponse struct {
Key kyber.Point
}
// SaveRequest will save the website in the conodes using the protocol and
// return the exit state of the saving process
type SaveRequest struct {
Url string
Roster *onet.Roster
}
// SaveResponse return an error if the website could not be saved correctly
// - Times collect statistic times in form key;decenarch.StatTimeFormat
type SaveResponse struct {
Times []string
}
// RetrieveRequest will retreive the website from the conode using the protocol
// and return the website file
type RetrieveRequest struct {
Url string
Roster *onet.Roster
Timestamp string
}
// RetrieveResponse return the website requested.
// - Path is the path to the page requested on the filesystem
type RetrieveResponse struct {
Main Webstore
Adds []Webstore
}
// Webstore is used to store website
// - Url is the address of the page
// - ContentType is the MIME TYPE
// - Sig is the collective signature for base64.StdEncoding.DecodeString(Page)
// - Page is a base64 string representing a []byte
// - AddsUrl is the urls of the attached additional ressources
// - Timestamp is the time at which the page was retrieved format 2006/01/02 15:04
type Webstore struct {
Url string
ContentType string
Sig *cosiservice.SignatureResponse
Page string
AddsUrl []string
Timestamp string
}