@@ -3,7 +3,6 @@ package clients
3
3
import (
4
4
"context"
5
5
"crypto/tls"
6
- "errors"
7
6
"fmt"
8
7
"sync"
9
8
"time"
@@ -55,10 +54,8 @@ type DisperserClient interface {
55
54
// DisperseBlobAuthenticated disperses a blob with an authenticated request.
56
55
// The BlobStatus returned will always be PROCESSSING if error is nil.
57
56
DisperseBlobAuthenticated (ctx context.Context , data []byte , customQuorums []uint8 ) (* disperser.BlobStatus , []byte , error )
58
- DispersePaidBlob (ctx context.Context , data []byte , customQuorums []uint8 ) (* disperser.BlobStatus , []byte , error )
59
57
GetBlobStatus (ctx context.Context , key []byte ) (* disperser_rpc.BlobStatusReply , error )
60
58
RetrieveBlob (ctx context.Context , batchHeaderHash []byte , blobIndex uint32 ) ([]byte , error )
61
- InitializePaymentState (ctx context.Context ) error
62
59
}
63
60
64
61
// See the NewDisperserClient constructor's documentation for details and usage examples.
@@ -190,59 +187,6 @@ func (c *disperserClient) DisperseBlob(ctx context.Context, data []byte, quorums
190
187
return blobStatus , reply .GetRequestId (), nil
191
188
}
192
189
193
- // DispersePaidBlob disperses a blob with a payment header and signature. Similar to DisperseBlob but with signed payment header.
194
- func (c * disperserClient ) DispersePaidBlob (ctx context.Context , data []byte , quorums []uint8 ) (* disperser.BlobStatus , []byte , error ) {
195
- if c .accountant == nil {
196
- return nil , nil , api .NewErrorInternal ("not implemented" )
197
- }
198
-
199
- err := c .initOnceGrpcConnection ()
200
- if err != nil {
201
- return nil , nil , fmt .Errorf ("error initializing connection: %w" , err )
202
- }
203
-
204
- ctxTimeout , cancel := context .WithTimeout (ctx , c .config .Timeout )
205
- defer cancel ()
206
-
207
- quorumNumbers := make ([]uint32 , len (quorums ))
208
- for i , q := range quorums {
209
- quorumNumbers [i ] = uint32 (q )
210
- }
211
-
212
- // check every 32 bytes of data are within the valid range for a bn254 field element
213
- _ , err = rs .ToFrArray (data )
214
- if err != nil {
215
- return nil , nil , fmt .Errorf ("encountered an error to convert a 32-bytes into a valid field element, please use the correct format where every 32bytes(big-endian) is less than 21888242871839275222246405745257275088548364400416034343698204186575808495617 %w" , err )
216
- }
217
-
218
- header , signature , err := c .accountant .AccountBlob (ctx , uint64 (encoding .GetBlobLength (uint (len (data )))), quorums )
219
- if header == nil {
220
- return nil , nil , errors .New ("accountant returned nil pointer to header" )
221
- }
222
- if err != nil {
223
- return nil , nil , err
224
- }
225
-
226
- request := & disperser_rpc.DispersePaidBlobRequest {
227
- Data : data ,
228
- QuorumNumbers : quorumNumbers ,
229
- PaymentHeader : header ,
230
- PaymentSignature : signature ,
231
- }
232
-
233
- reply , err := c .client .DispersePaidBlob (ctxTimeout , request )
234
- if err != nil {
235
- return nil , nil , err
236
- }
237
-
238
- blobStatus , err := disperser .FromBlobStatusProto (reply .GetResult ())
239
- if err != nil {
240
- return nil , nil , err
241
- }
242
-
243
- return blobStatus , reply .GetRequestId (), nil
244
- }
245
-
246
190
func (c * disperserClient ) DisperseBlobAuthenticated (ctx context.Context , data []byte , quorums []uint8 ) (* disperser.BlobStatus , []byte , error ) {
247
191
err := c .initOnceGrpcConnection ()
248
192
if err != nil {
@@ -384,54 +328,6 @@ func (c *disperserClient) RetrieveBlob(ctx context.Context, batchHeaderHash []by
384
328
return reply .Data , nil
385
329
}
386
330
387
- func (c * disperserClient ) getPaymentState (ctx context.Context ) (* disperser_rpc.GetPaymentStateReply , error ) {
388
- err := c .initOnceGrpcConnection ()
389
- if err != nil {
390
- return nil , fmt .Errorf ("error initializing connection: %w" , err )
391
- }
392
-
393
- ctxTimeout , cancel := context .WithTimeout (ctx , time .Second * 60 )
394
- defer cancel ()
395
-
396
- request , err := c .accountant .AuthenticatePaymentStateRequest ()
397
- if err != nil {
398
- return nil , err
399
- }
400
- reply , err := c .client .GetPaymentState (ctxTimeout , request )
401
- if err != nil {
402
- return nil , err
403
- }
404
-
405
- return reply , nil
406
- }
407
-
408
- func (c * disperserClient ) InitializePaymentState (ctx context.Context ) error {
409
- paymentState , err := c .getPaymentState (ctx )
410
- if err != nil {
411
- return fmt .Errorf ("error getting payment state from disperser: %w" , err )
412
- }
413
- c .accountant .SetPaymentState (paymentState )
414
- // c.accountant.binUsages = []uint64{uint64(paymentState.CurrentBinUsage), uint64(paymentState.NextBinUsage), uint64(paymentState.OverflowBinUsage)}
415
- // c.accountant.cumulativePayment = new(big.Int).SetBytes(paymentState.CumulativePayment)
416
- // quorumNumbers := make([]uint8, len(paymentState.Reservation.QuorumNumbers))
417
- // for i, q := range paymentState.Reservation.QuorumNumbers {
418
- // quorumNumbers[i] = uint8(q)
419
- // }
420
- // c.accountant.reservation = core.ActiveReservation{
421
- // StartTimestamp: uint64(paymentState.Reservation.StartTimestamp),
422
- // EndTimestamp: uint64(paymentState.Reservation.EndTimestamp),
423
- // SymbolsPerSec: paymentState.Reservation.SymbolsPerSecond,
424
- // QuorumNumbers: quorumNumbers,
425
- // }
426
- // c.accountant.onDemand = core.OnDemandPayment{
427
- // CumulativePayment: new(big.Int).SetBytes(paymentState.OnChainCumulativePayment),
428
- // }
429
- // c.accountant.reservationWindow = paymentState.PaymentGlobalParams.ReservationWindow
430
- // c.accountant.pricePerSymbol = paymentState.PaymentGlobalParams.PricePerSymbol
431
- // c.accountant.minNumSymbols = paymentState.PaymentGlobalParams.MinNumSymbols
432
- return nil
433
- }
434
-
435
331
// initOnceGrpcConnection initializes the grpc connection and client if they are not already initialized.
436
332
// If initialization fails, it caches the error and will return it on every subsequent call.
437
333
func (c * disperserClient ) initOnceGrpcConnection () error {
0 commit comments