Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

align collection guarantee with protobuf schema #779

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading