1
- package clients
1
+ package v2
2
2
3
3
import (
4
4
"context"
@@ -16,21 +16,21 @@ import (
16
16
"google.golang.org/grpc"
17
17
)
18
18
19
- type DisperserClientV2Config struct {
19
+ type DisperserClientConfig struct {
20
20
Hostname string
21
21
Port string
22
22
UseSecureGrpcFlag bool
23
23
}
24
24
25
- type DisperserClientV2 interface {
25
+ type DisperserClient interface {
26
26
Close () error
27
27
DisperseBlob (ctx context.Context , data []byte , blobVersion corev2.BlobVersion , quorums []core.QuorumID , salt uint32 ) (* dispv2.BlobStatus , corev2.BlobKey , error )
28
28
GetBlobStatus (ctx context.Context , blobKey corev2.BlobKey ) (* disperser_rpc.BlobStatusReply , error )
29
29
GetBlobCommitment (ctx context.Context , data []byte ) (* disperser_rpc.BlobCommitmentReply , error )
30
30
}
31
31
32
- type disperserClientV2 struct {
33
- config * DisperserClientV2Config
32
+ type disperserClient struct {
33
+ config * DisperserClientConfig
34
34
signer corev2.BlobRequestSigner
35
35
initOnce sync.Once
36
36
conn * grpc.ClientConn
@@ -39,18 +39,18 @@ type disperserClientV2 struct {
39
39
accountant * Accountant
40
40
}
41
41
42
- var _ DisperserClientV2 = & disperserClientV2 {}
42
+ var _ DisperserClient = & disperserClient {}
43
43
44
- // DisperserClientV2 maintains a single underlying grpc connection to the disperser server,
44
+ // DisperserClient maintains a single underlying grpc connection to the disperser server,
45
45
// through which it sends requests to disperse blobs and get blob status.
46
46
// The connection is established lazily on the first method call. Don't forget to call Close(),
47
47
// which is safe to call even if the connection was never established.
48
48
//
49
- // DisperserClientV2 is safe to be used concurrently by multiple goroutines.
49
+ // DisperserClient is safe to be used concurrently by multiple goroutines.
50
50
//
51
51
// Example usage:
52
52
//
53
- // client := NewDisperserClientV2 (config, signer)
53
+ // client := NewDisperserClient (config, signer)
54
54
// defer client.Close()
55
55
//
56
56
// // The connection will be established on the first call
@@ -61,7 +61,7 @@ var _ DisperserClientV2 = &disperserClientV2{}
61
61
//
62
62
// // Subsequent calls will use the existing connection
63
63
// status2, blobKey2, err := client.DisperseBlob(ctx, data, blobHeader)
64
- func NewDisperserClientV2 (config * DisperserClientV2Config , signer corev2.BlobRequestSigner , prover encoding.Prover , accountant * Accountant ) (* disperserClientV2 , error ) {
64
+ func NewDisperserClient (config * DisperserClientConfig , signer corev2.BlobRequestSigner , prover encoding.Prover , accountant * Accountant ) (* disperserClient , error ) {
65
65
if config == nil {
66
66
return nil , api .NewErrorInvalidArg ("config must be provided" )
67
67
}
@@ -75,7 +75,7 @@ func NewDisperserClientV2(config *DisperserClientV2Config, signer corev2.BlobReq
75
75
return nil , api .NewErrorInvalidArg ("signer must be provided" )
76
76
}
77
77
78
- return & disperserClientV2 {
78
+ return & disperserClient {
79
79
config : config ,
80
80
signer : signer ,
81
81
prover : prover ,
@@ -85,7 +85,7 @@ func NewDisperserClientV2(config *DisperserClientV2Config, signer corev2.BlobReq
85
85
}
86
86
87
87
// PopulateAccountant populates the accountant with the payment state from the disperser.
88
- func (c * disperserClientV2 ) PopulateAccountant (ctx context.Context ) error {
88
+ func (c * disperserClient ) PopulateAccountant (ctx context.Context ) error {
89
89
paymentState , err := c .GetPaymentState (ctx )
90
90
if err != nil {
91
91
return fmt .Errorf ("error getting payment state for initializing accountant: %w" , err )
@@ -100,7 +100,7 @@ func (c *disperserClientV2) PopulateAccountant(ctx context.Context) error {
100
100
101
101
// Close closes the grpc connection to the disperser server.
102
102
// It is thread safe and can be called multiple times.
103
- func (c * disperserClientV2 ) Close () error {
103
+ func (c * disperserClient ) Close () error {
104
104
if c .conn != nil {
105
105
err := c .conn .Close ()
106
106
c .conn = nil
@@ -110,7 +110,7 @@ func (c *disperserClientV2) Close() error {
110
110
return nil
111
111
}
112
112
113
- func (c * disperserClientV2 ) DisperseBlob (
113
+ func (c * disperserClient ) DisperseBlob (
114
114
ctx context.Context ,
115
115
data []byte ,
116
116
blobVersion corev2.BlobVersion ,
@@ -217,7 +217,7 @@ func (c *disperserClientV2) DisperseBlob(
217
217
}
218
218
219
219
// GetBlobStatus returns the status of a blob with the given blob key.
220
- func (c * disperserClientV2 ) GetBlobStatus (ctx context.Context , blobKey corev2.BlobKey ) (* disperser_rpc.BlobStatusReply , error ) {
220
+ func (c * disperserClient ) GetBlobStatus (ctx context.Context , blobKey corev2.BlobKey ) (* disperser_rpc.BlobStatusReply , error ) {
221
221
err := c .initOnceGrpcConnection ()
222
222
if err != nil {
223
223
return nil , api .NewErrorInternal (err .Error ())
@@ -230,7 +230,7 @@ func (c *disperserClientV2) GetBlobStatus(ctx context.Context, blobKey corev2.Bl
230
230
}
231
231
232
232
// GetPaymentState returns the payment state of the disperser client
233
- func (c * disperserClientV2 ) GetPaymentState (ctx context.Context ) (* disperser_rpc.GetPaymentStateReply , error ) {
233
+ func (c * disperserClient ) GetPaymentState (ctx context.Context ) (* disperser_rpc.GetPaymentStateReply , error ) {
234
234
err := c .initOnceGrpcConnection ()
235
235
if err != nil {
236
236
return nil , api .NewErrorInternal (err .Error ())
@@ -257,7 +257,7 @@ func (c *disperserClientV2) GetPaymentState(ctx context.Context) (*disperser_rpc
257
257
// While the blob commitment can be calculated by anyone, it requires SRS points to
258
258
// be loaded. For service that does not have access to SRS points, this method can be
259
259
// used to calculate the blob commitment in blob header, which is required for dispersal.
260
- func (c * disperserClientV2 ) GetBlobCommitment (ctx context.Context , data []byte ) (* disperser_rpc.BlobCommitmentReply , error ) {
260
+ func (c * disperserClient ) GetBlobCommitment (ctx context.Context , data []byte ) (* disperser_rpc.BlobCommitmentReply , error ) {
261
261
err := c .initOnceGrpcConnection ()
262
262
if err != nil {
263
263
return nil , api .NewErrorInternal (err .Error ())
@@ -271,7 +271,7 @@ func (c *disperserClientV2) GetBlobCommitment(ctx context.Context, data []byte)
271
271
272
272
// initOnceGrpcConnection initializes the grpc connection and client if they are not already initialized.
273
273
// If initialization fails, it caches the error and will return it on every subsequent call.
274
- func (c * disperserClientV2 ) initOnceGrpcConnection () error {
274
+ func (c * disperserClient ) initOnceGrpcConnection () error {
275
275
var initErr error
276
276
c .initOnce .Do (func () {
277
277
addr := fmt .Sprintf ("%v:%v" , c .config .Hostname , c .config .Port )
0 commit comments