Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Write to Trillian Map At Revision (#1146)
Browse files Browse the repository at this point in the history
Resolves #1119
  • Loading branch information
gdbelvin authored Dec 13, 2018
1 parent de5f6ce commit 36160ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/sequencer/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (s *Server) ApplyRevision(ctx context.Context, in *spb.ApplyRevisionRequest
}

// Set new leaf values.
mapRoot, err := mapClient.SetLeaves(ctx, newLeaves, metadata)
mapRoot, err := mapClient.SetLeavesAtRevision(ctx, in.Revision, newLeaves, metadata)
if err != nil {
return nil, status.Errorf(codes.Internal, "VerifySignedMapRoot(): %v", err)
}
Expand Down
10 changes: 6 additions & 4 deletions core/sequencer/trillian_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type trillianFactory interface {
// trillianMap communicates with the Trilian map and verifies the responses.
type trillianMap interface {
GetAndVerifyLatestMapRoot(ctx context.Context) (*tpb.SignedMapRoot, *types.MapRootV1, error)
SetLeaves(ctx context.Context, leaves []*tpb.MapLeaf, meta []byte) (*types.MapRootV1, error)
SetLeavesAtRevision(ctx context.Context, rev int64, leaves []*tpb.MapLeaf, meta []byte) (*types.MapRootV1, error)
GetAndVerifyMapRootByRevision(ctx context.Context, rev int64) (*tpb.SignedMapRoot, *types.MapRootV1, error)
GetAndVerifyMapLeavesByRevision(ctx context.Context, rev int64, indexes [][]byte) ([]*tpb.MapLeaf, error)
}
Expand Down Expand Up @@ -99,17 +99,19 @@ type MapClient struct {
*tclient.MapClient
}

// SetLeaves creates a new map revision and returns its verified root.
// SetLeavesAtRevision creates a new map revision and returns its verified root.
// TODO(gbelvin): Move to Trillian Map client.
func (c *MapClient) SetLeaves(ctx context.Context, leaves []*tpb.MapLeaf, metadata []byte) (*types.MapRootV1, error) {
func (c *MapClient) SetLeavesAtRevision(ctx context.Context, rev int64,
leaves []*tpb.MapLeaf, metadata []byte) (*types.MapRootV1, error) {
// Set new leaf values.
setResp, err := c.Conn.SetLeaves(ctx, &tpb.SetMapLeavesRequest{
MapId: c.MapID,
Revision: rev,
Leaves: leaves,
Metadata: metadata,
})
if err != nil {
return nil, status.Errorf(codes.Internal, "tmap.SetLeaves(): %v", err)
return nil, err
}
mapRoot, err := c.VerifySignedMapRoot(setResp.GetMapRoot())
if err != nil {
Expand Down

0 comments on commit 36160ee

Please sign in to comment.