diff --git a/da/avail/avail.go b/da/avail/avail.go index 42b0c9e47..d8536cb0b 100644 --- a/da/avail/avail.go +++ b/da/avail/avail.go @@ -18,11 +18,12 @@ import ( ) type Config struct { + BaseURL string `json:"base_url"` Seed string `json:"seed"` ApiURL string `json:"api_url"` Size int `json:"size"` AppID int `json:"app_id"` - confidence float32 `json:"confidence"` + confidence float64 `json:"confidence"` } type DataAvailabilityLayerClient struct { @@ -32,6 +33,17 @@ type DataAvailabilityLayerClient struct { logger log.Logger } +type Confidence struct { + Block uint32 `json:"block"` + Confidence float64 `json:"confidence"` + SerialisedConfidence *string `json:"serialised_confidence,omitempty"` +} + +type AppData struct { + Block uint32 `json:"block"` + Extrinsics string `json:"extrinsics"` +} + var _ da.DataAvailabilityLayerClient = &DataAvailabilityLayerClient{} var _ da.BlockRetriever = &DataAvailabilityLayerClient{} @@ -48,6 +60,7 @@ func (c *DataAvailabilityLayerClient) Init(namespaceID types.NamespaceID, config // Start prepares DataAvailabilityLayerClient to work. func (c *DataAvailabilityLayerClient) Start() error { + c.logger.Info("starting avail Data Availability Layer Client", "baseURL", c.config.ApiURL) return nil @@ -55,7 +68,9 @@ func (c *DataAvailabilityLayerClient) Start() error { // Stop stops DataAvailabilityLayerClient. func (c *DataAvailabilityLayerClient) Stop() error { + c.logger.Info("stopping Avail Data Availability Layer Client") + return nil } @@ -72,7 +87,7 @@ func (c *DataAvailabilityLayerClient) SubmitBlock(ctx context.Context, block *ty } } - txHash, err := datasubmit.SubmitData(1000, c.config.ApiURL, c.config.Seed, c.config.AppID, data) + txHash, err := datasubmit.SubmitData(c.config.Size, c.config.ApiURL, c.config.Seed, c.config.AppID, data) if err != nil { return da.ResultSubmitBlock{ @@ -95,14 +110,8 @@ func (c *DataAvailabilityLayerClient) SubmitBlock(ctx context.Context, block *ty // CheckBlockAvailability queries DA layer to check data availability of block. func (c *DataAvailabilityLayerClient) CheckBlockAvailability(ctx context.Context, dataLayerHeight uint64) da.ResultCheckBlock { - type Confidence struct { - Block uint32 `json:"block"` - Confidence float64 `json:"confidence"` - SerialisedConfidence *string `json:"serialised_confidence,omitempty"` - } - blockNumber := dataLayerHeight - confidenceURL := fmt.Sprintf("http://localhost:7000/v1/confidence/%d", blockNumber) + confidenceURL := fmt.Sprintf(c.config.BaseURL+"/confidence/%d", blockNumber) response, err := http.Get(confidenceURL) @@ -141,16 +150,11 @@ func (c *DataAvailabilityLayerClient) CheckBlockAvailability(ctx context.Context func (c *DataAvailabilityLayerClient) RetrieveBlocks(ctx context.Context, dataLayerHeight uint64) da.ResultRetrieveBlocks { - type AppData struct { - Block uint32 `json:"block"` - Extrinsics string `json:"extrinsics"` - } - blocks := make([]*types.Block, 1) blocks[0] = new(types.Block) blockNumber := dataLayerHeight - appDataURL := fmt.Sprintf("http://localhost:7000/v1/appdata/%d?decode=true", blockNumber) + appDataURL := fmt.Sprintf(c.config.BaseURL+"/appdata/%d?decode=true", blockNumber) response, err := http.Get(appDataURL) if err != nil { return da.ResultRetrieveBlocks{