Skip to content

Commit

Permalink
remove renaming of flow.Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
illia-malachyn committed Sep 12, 2024
1 parent 1ed31af commit 291e452
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion access/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type Client interface {
GetBlockByHeight(ctx context.Context, height uint64) (*flow.Block, error)

// GetCollection gets a collection by ID.
GetCollection(ctx context.Context, colID flow.Identifier) (*flow.LightCollection, error)
GetCollection(ctx context.Context, colID flow.Identifier) (*flow.Collection, error)

// SendTransaction submits a transaction to the network.
SendTransaction(ctx context.Context, tx flow.Transaction) error
Expand Down
4 changes: 2 additions & 2 deletions access/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ func (c *Client) GetBlockByHeight(ctx context.Context, height uint64) (*flow.Blo
return c.grpc.GetBlockByHeight(ctx, height)
}

func (c *Client) GetCollection(ctx context.Context, colID flow.Identifier) (*flow.LightCollection, error) {
func (c *Client) GetCollection(ctx context.Context, colID flow.Identifier) (*flow.Collection, error) {
return c.grpc.GetCollection(ctx, colID)
}

func (c *Client) GetCollectionByID(ctx context.Context, id flow.Identifier) (*flow.LightCollection, error) {
func (c *Client) GetCollectionByID(ctx context.Context, id flow.Identifier) (*flow.Collection, error) {
return c.grpc.GetLightCollectionByID(ctx, id)
}

Expand Down
8 changes: 4 additions & 4 deletions access/grpc/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func MessageToCadenceValue(m []byte, options []jsoncdc.Option) (cadence.Value, e
return v, nil
}

func LightCollectionToMessage(c flow.LightCollection) *entities.Collection {
func LightCollectionToMessage(c flow.Collection) *entities.Collection {
transactionIDMessages := make([][]byte, len(c.TransactionIDs))
for i, transactionID := range c.TransactionIDs {
transactionIDMessages[i] = transactionID.Bytes()
Expand All @@ -267,9 +267,9 @@ func FullCollectionToTransactionsMessage(tx flow.FullCollection) ([]*entities.Tr
return convertedTxs, nil
}

func MessageToLightCollection(m *entities.Collection) (flow.LightCollection, error) {
func MessageToLightCollection(m *entities.Collection) (flow.Collection, error) {
if m == nil {
return flow.LightCollection{}, ErrEmptyMessage
return flow.Collection{}, ErrEmptyMessage
}

transactionIDMessages := m.GetTransactionIds()
Expand All @@ -279,7 +279,7 @@ func MessageToLightCollection(m *entities.Collection) (flow.LightCollection, err
transactionIDs[i] = flow.HashToID(transactionIDMsg)
}

return flow.LightCollection{
return flow.Collection{
TransactionIDs: transactionIDs,
}, nil
}
Expand Down
4 changes: 2 additions & 2 deletions access/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func (c *BaseClient) GetCollection(
ctx context.Context,
colID flow.Identifier,
opts ...grpc.CallOption,
) (*flow.LightCollection, error) {
) (*flow.Collection, error) {
req := &access.GetCollectionByIDRequest{
Id: colID.Bytes(),
}
Expand All @@ -318,7 +318,7 @@ func (c *BaseClient) GetLightCollectionByID(
ctx context.Context,
id flow.Identifier,
opts ...grpc.CallOption,
) (*flow.LightCollection, error) {
) (*flow.Collection, error) {
req := &access.GetCollectionByIDRequest{
Id: id.Bytes(),
}
Expand Down
2 changes: 1 addition & 1 deletion access/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (c *Client) GetBlockByHeight(ctx context.Context, height uint64) (*flow.Blo
return blocks[0], nil
}

func (c *Client) GetCollection(ctx context.Context, ID flow.Identifier) (*flow.LightCollection, error) {
func (c *Client) GetCollection(ctx context.Context, ID flow.Identifier) (*flow.Collection, error) {
return c.httpClient.GetCollection(ctx, ID)
}

Expand Down
4 changes: 2 additions & 2 deletions access/http/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ func ToBlock(block *models.Block) (*flow.Block, error) {
}, nil
}

func ToCollection(collection *models.Collection) *flow.LightCollection {
func ToCollection(collection *models.Collection) *flow.Collection {
IDs := make([]flow.Identifier, len(collection.Transactions))
for i, tx := range collection.Transactions {
IDs[i] = flow.HexToID(tx.Id)
}
return &flow.LightCollection{
return &flow.Collection{
TransactionIDs: IDs,
}
}
Expand Down
2 changes: 1 addition & 1 deletion access/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func (c *BaseClient) GetCollection(
ctx context.Context,
ID flow.Identifier,
opts ...queryOpts,
) (*flow.LightCollection, error) {
) (*flow.Collection, error) {
collection, err := c.handler.getCollection(ctx, ID.String(), opts...)
if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions access/mocks/Client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@

package flow

// A LightCollection is a list of transactions bundled together for inclusion in a block.
type LightCollection struct {
// A Collection is a list of transactions bundled together for inclusion in a block.
type Collection struct {
TransactionIDs []Identifier
}

// ID returns the canonical SHA3-256 hash of this collection.
func (c LightCollection) ID() Identifier {
func (c Collection) ID() Identifier {
return HashToID(defaultEntityHasher.ComputeHash(c.Encode()))
}

// Encode returns the canonical RLP byte representation of this collection.
func (c LightCollection) Encode() []byte {
func (c Collection) Encode() []byte {
transactionIDs := make([][]byte, len(c.TransactionIDs))
for i, id := range c.TransactionIDs {
transactionIDs[i] = id.Bytes()
Expand All @@ -53,8 +53,8 @@ type FullCollection struct {
}

// Light returns the light, reference-only version of the collection.
func (c FullCollection) Light() LightCollection {
lc := LightCollection{TransactionIDs: make([]Identifier, 0, len(c.Transactions))}
func (c FullCollection) Light() Collection {
lc := Collection{TransactionIDs: make([]Identifier, 0, len(c.Transactions))}
for _, tx := range c.Transactions {
lc.TransactionIDs = append(lc.TransactionIDs, tx.ID())
}
Expand Down
2 changes: 1 addition & 1 deletion examples/get_collection/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func demo(exampleCollectionID flow.Identifier) {
printCollection(collection, err)
}

func printCollection(collection *flow.LightCollection, err error) {
func printCollection(collection *flow.Collection, err error) {
examples.Handle(err)

fmt.Printf("\nID: %s", collection.ID().String())
Expand Down
4 changes: 2 additions & 2 deletions test/entities.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ func LightCollectionGenerator() *LightCollection {
}
}

func (g *LightCollection) New() *flow.LightCollection {
return &flow.LightCollection{
func (g *LightCollection) New() *flow.Collection {
return &flow.Collection{
TransactionIDs: []flow.Identifier{
g.ids.New(),
g.ids.New(),
Expand Down

0 comments on commit 291e452

Please sign in to comment.