Skip to content

Commit

Permalink
Merge pull request #779 from The-K-R-O-K/illia-malachyn/768-collectio…
Browse files Browse the repository at this point in the history
…n-guarantee-response-object

align collection guarantee with protobuf schema
  • Loading branch information
franklywatson authored Oct 21, 2024
2 parents fb225b9 + 92f5c6d commit aadf896
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
10 changes: 8 additions & 2 deletions access/grpc/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,10 @@ func MessageToFullCollection(m []*entities.Transaction) (flow.FullCollection, er

func CollectionGuaranteeToMessage(g flow.CollectionGuarantee) *entities.CollectionGuarantee {
return &entities.CollectionGuarantee{
CollectionId: g.CollectionID.Bytes(),
CollectionId: g.CollectionID.Bytes(),
ReferenceBlockId: g.ReferenceBlockID.Bytes(),
Signature: g.Signature,
SignerIndices: g.SignerIndices,
}
}

Expand Down Expand Up @@ -453,7 +456,10 @@ func MessageToCollectionGuarantee(m *entities.CollectionGuarantee) (flow.Collect
}

return flow.CollectionGuarantee{
CollectionID: flow.HashToID(m.CollectionId),
CollectionID: flow.HashToID(m.CollectionId),
ReferenceBlockID: flow.HashToID(m.ReferenceBlockId),
Signature: m.Signature,
SignerIndices: m.SignerIndices,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion access/http/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func ToCollectionGuarantees(guarantees []models.CollectionGuarantee) []*flow.Col

for i, guarantee := range guarantees {
flowGuarantees[i] = &flow.CollectionGuarantee{
flow.HexToID(guarantee.CollectionId),
CollectionID: flow.HexToID(guarantee.CollectionId),
}
}

Expand Down
5 changes: 4 additions & 1 deletion collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ func (c Collection) Encode() []byte {

// A CollectionGuarantee is an attestation signed by the nodes that have guaranteed a collection.
type CollectionGuarantee struct {
CollectionID Identifier
CollectionID Identifier
ReferenceBlockID Identifier
Signature []byte
SignerIndices []byte
}

type FullCollection struct {
Expand Down
13 changes: 10 additions & 3 deletions test/entities.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ func (c *FullCollection) New() *flow.FullCollection {
}

type CollectionGuarantees struct {
ids *Identifiers
ids *Identifiers
bytes *Bytes
sigs *Signatures
}

type BlockSeals struct {
Expand All @@ -236,13 +238,18 @@ type BlockSeals struct {

func CollectionGuaranteeGenerator() *CollectionGuarantees {
return &CollectionGuarantees{
ids: IdentifierGenerator(),
ids: IdentifierGenerator(),
bytes: BytesGenerator(),
sigs: SignaturesGenerator(),
}
}

func (g *CollectionGuarantees) New() *flow.CollectionGuarantee {
return &flow.CollectionGuarantee{
CollectionID: g.ids.New(),
CollectionID: g.ids.New(),
ReferenceBlockID: g.ids.New(),
Signature: g.sigs.New()[0],
SignerIndices: g.bytes.New(),
}
}

Expand Down

0 comments on commit aadf896

Please sign in to comment.