-
Notifications
You must be signed in to change notification settings - Fork 1
/
model.go
71 lines (60 loc) · 1.69 KB
/
model.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
package model
import (
"fmt"
"time"
)
// RootHash model
type RootHash struct {
Publisher string `json:"publisher"`
Signature string `json:"signature"`
Sequence uint64 `json:"sequence"`
Timestamp time.Time `json:"timestamp"`
ObjectHeaderHash string `json:"objectHeaderHash"`
}
// Key returns parcel key constructed in "publisher_sequence" format
func (r *RootHash) Key() string {
return fmt.Sprintf("%s_%v", r.Publisher, r.Sequence)
}
// Parcel model
type Parcel struct {
ObjectHeaders []ObjectHeader `json:"objectHeaders"`
Objects []Object `json:"objects"`
}
// ObjectHeader model
type ObjectHeader struct {
ObjectHash string `json:"objectHash"`
ObjectSize uint64 `json:"objectSize"`
ExternalReferences []string `json:"externalReferences"`
ExternalReferencesSize uint64 `json:"externalReferencesSize"`
Size uint64 `json:"size"`
RecursiveSizeFirstLevel uint64 `json:"recursiveSizeFirstLevel"`
RecursiveSizeTotal uint64 `json:"recursiveSizeTotal"`
Meta []Meta `json:"meta"`
}
// Meta model
type Meta struct {
Key string `json:"key"`
Value string `json:"value"`
}
// Object model
type Object struct {
Length uint64 `json:"length"`
Data []byte `json:"data"`
}
// PublishDataRequest model
type PublishDataRequest struct {
RootHash RootHash `json:"rootHash"`
Parcel Parcel `json:"parcel"`
}
// GetObjectHeadersResponse model
type GetObjectHeadersResponse struct {
ObjectHeaders []ObjectHeader `json:"objectHeaders"`
}
type RegisterAppRequest struct {
Address string
Name string
}
type NotifyAppRequest struct {
RootHash RootHash
Parcel Parcel
}