Skip to content

Commit

Permalink
added missing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ssd04 committed Mar 19, 2024
1 parent 08fd7d4 commit 58540fc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions factory/wsConnectorFactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func CreateWSConnector(cfg config.WebSocketConfig) (process.WSConnector, error)
return nil, err
}

// TODO: move cache to config
cacheConfig := storageUnit.CacheConfig{
Type: storageUnit.SizeLRUCache,
SizeInBytes: 209715200, // 200MB
Expand Down
6 changes: 6 additions & 0 deletions process/blocksPool.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@ import (
"github.com/multiversx/mx-chain-storage-go/types"
)

// TODO: refactor to use storer

type blocksPool struct {
cacher types.Cacher
}

// NewBlocksPool will create a new blocks pool instance
func NewBlocksPool(cacher types.Cacher) (*blocksPool, error) {
return &blocksPool{cacher: cacher}, nil
}

// PutBlock will put the provided outport block data to the pool
func (bp *blocksPool) PutBlock(hash []byte, outportBlock *outport.OutportBlock) error {
_ = bp.cacher.Put(hash, outportBlock, 0)
return nil
}

// GetBlock will return outport block data from the pool
func (bp *blocksPool) GetBlock(hash []byte) (*outport.OutportBlock, error) {
data, ok := bp.cacher.Get(hash)
if !ok {
Expand All @@ -35,6 +40,7 @@ func (bp *blocksPool) GetBlock(hash []byte) (*outport.OutportBlock, error) {
return outportBlock, nil
}

// IsInterfaceNil returns nil if there is no value under the interface
func (bp *blocksPool) IsInterfaceNil() bool {
return bp == nil
}
3 changes: 3 additions & 0 deletions process/dataAggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type dataAggregator struct {
blocksPool BlocksPool
}

// NewDataAggregator will create a new data aggregator instance
func NewDataAggregator(
blocksPool BlocksPool,
) (*dataAggregator, error) {
Expand All @@ -24,6 +25,8 @@ func NewDataAggregator(
}, nil
}

// ProcessHyperBlock will process meta outport block. It will try to fetch and aggregate
// notarized shards data
func (da *dataAggregator) ProcessHyperBlock(outportBlock *outport.OutportBlock) (*data.HyperOutportBlock, error) {
hyperOutportBlock := &data.HyperOutportBlock{}
hyperOutportBlock.MetaOutportBlock = outportBlock
Expand Down
1 change: 1 addition & 0 deletions process/firehosePublisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func NewFirehosePublisher(
return fp, nil
}

// PublishHyperBlock will push aggregated outport block data to the firehose writer
func (fp *firehosePublisher) PublishHyperBlock(hyperOutportBlock *data.HyperOutportBlock) error {
outportBlock := hyperOutportBlock.MetaOutportBlock

Expand Down
4 changes: 4 additions & 0 deletions process/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,20 @@ type Writer interface {
Close() error
}

// Publisher defines the behaviour of an aggregated outport block publisher component
type Publisher interface {
PublishHyperBlock(hyperOutportBlock *data.HyperOutportBlock) error
Close() error
}

// DataAggregator defines the behaviour of a component that is able to aggregate outport
// block data for shards
type DataAggregator interface {
ProcessHyperBlock(outportBlock *outport.OutportBlock) (*data.HyperOutportBlock, error)
IsInterfaceNil() bool
}

// BlocksPool defines the behaviour of a blocks pool handler component
type BlocksPool interface {
PutBlock(hash []byte, outportBlock *outport.OutportBlock) error
GetBlock(hash []byte) (*outport.OutportBlock, error)
Expand Down

0 comments on commit 58540fc

Please sign in to comment.