-
Notifications
You must be signed in to change notification settings - Fork 200
/
Copy pathblob.go
91 lines (81 loc) · 2.01 KB
/
blob.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
package v2
import (
"fmt"
pb "github.com/Layr-Labs/eigenda/api/grpc/disperser/v2"
core "github.com/Layr-Labs/eigenda/core/v2"
"github.com/Layr-Labs/eigenda/encoding"
)
type BlobStatus uint
const (
Queued BlobStatus = iota
Encoded
Certified
Failed
InsufficientSignatures
)
func (s BlobStatus) String() string {
switch s {
case Queued:
return "Queued"
case Encoded:
return "Encoded"
case Certified:
return "Certified"
case Failed:
return "Failed"
case InsufficientSignatures:
return "Insufficient Signatures"
default:
return "Unknown"
}
}
func (s BlobStatus) ToProfobuf() pb.BlobStatus {
switch s {
case Queued:
return pb.BlobStatus_QUEUED
case Encoded:
return pb.BlobStatus_ENCODED
case Certified:
return pb.BlobStatus_CERTIFIED
case Failed:
return pb.BlobStatus_FAILED
case InsufficientSignatures:
return pb.BlobStatus_INSUFFICIENT_SIGNATURES
default:
return pb.BlobStatus_UNKNOWN
}
}
func BlobStatusFromProtobuf(s pb.BlobStatus) (BlobStatus, error) {
switch s {
case pb.BlobStatus_QUEUED:
return Queued, nil
case pb.BlobStatus_ENCODED:
return Encoded, nil
case pb.BlobStatus_CERTIFIED:
return Certified, nil
case pb.BlobStatus_FAILED:
return Failed, nil
case pb.BlobStatus_INSUFFICIENT_SIGNATURES:
return InsufficientSignatures, nil
default:
return 0, fmt.Errorf("unknown blob status: %v", s)
}
}
// BlobMetadata is an internal representation of a blob's metadata.
type BlobMetadata struct {
BlobHeader *core.BlobHeader
Signature []byte
// BlobStatus indicates the current status of the blob
BlobStatus BlobStatus
// Expiry is Unix timestamp of the blob expiry in seconds from epoch
Expiry uint64
// NumRetries is the number of times the blob has been retried
NumRetries uint
// BlobSize is the size of the blob in bytes
BlobSize uint64
// RequestedAt is the Unix timestamp of when the blob was requested in nanoseconds
RequestedAt uint64
// UpdatedAt is the Unix timestamp of when the blob was last updated in _nanoseconds_
UpdatedAt uint64
*encoding.FragmentInfo
}