Change pointerdb pointer to use time.Time for Creation date (#2483)
This commit is contained in:
parent
674742d1a7
commit
3587e1a579
@ -273,6 +273,7 @@ func makePointer(storageNodes []*storagenode.Peer, rs storj.RedundancyScheme,
|
||||
|
||||
if inline {
|
||||
inlinePointer := &pb.Pointer{
|
||||
CreationDate: time.Now(),
|
||||
Type: pb.Pointer_INLINE,
|
||||
InlineSegment: make([]byte, segmentSize),
|
||||
SegmentSize: segmentSize,
|
||||
@ -290,7 +291,8 @@ func makePointer(storageNodes []*storagenode.Peer, rs storj.RedundancyScheme,
|
||||
}
|
||||
|
||||
pointer := &pb.Pointer{
|
||||
Type: pb.Pointer_REMOTE,
|
||||
CreationDate: time.Now(),
|
||||
Type: pb.Pointer_REMOTE,
|
||||
Remote: &pb.RemoteSegment{
|
||||
Redundancy: &pb.RedundancyScheme{
|
||||
Type: pb.RedundancyScheme_RS,
|
||||
|
@ -173,6 +173,7 @@ func makePointer(path storj.Path, expiration *timestamp.Timestamp) *pb.Pointer {
|
||||
NodeId: teststorj.NodeIDFromString("testId"),
|
||||
})
|
||||
return &pb.Pointer{
|
||||
CreationDate: time.Now(),
|
||||
ExpirationDate: expiration,
|
||||
Type: pb.Pointer_REMOTE,
|
||||
Remote: &pb.RemoteSegment{
|
||||
|
@ -501,8 +501,7 @@ func (verifier *Verifier) checkIfSegmentDeleted(ctx context.Context, stripe *Str
|
||||
return err
|
||||
}
|
||||
|
||||
if pointer.GetCreationDate().GetSeconds() != stripe.Segment.GetCreationDate().GetSeconds() ||
|
||||
pointer.GetCreationDate().GetNanos() != stripe.Segment.GetCreationDate().GetNanos() {
|
||||
if !pointer.CreationDate.Equal(stripe.Segment.CreationDate) {
|
||||
return ErrSegmentDeleted.New(stripe.SegmentPath)
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ package audit
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -129,7 +130,8 @@ func TestCreatePendingAudits(t *testing.T) {
|
||||
stripe := Stripe{
|
||||
Index: 3,
|
||||
Segment: &pb.Pointer{
|
||||
Type: pb.Pointer_REMOTE,
|
||||
CreationDate: time.Now(),
|
||||
Type: pb.Pointer_REMOTE,
|
||||
Remote: &pb.RemoteSegment{
|
||||
RootPieceId: storj.NewPieceID(),
|
||||
Redundancy: &pb.RedundancyScheme{
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
"golang.org/x/sync/errgroup"
|
||||
@ -181,12 +180,7 @@ func (checker *Checker) updateSegmentStatus(ctx context.Context, pointer *pb.Poi
|
||||
return nil
|
||||
}
|
||||
|
||||
createdAt, err := ptypes.Timestamp(pointer.CreationDate)
|
||||
if err != nil {
|
||||
return Error.New("error parsing creation date %s", err)
|
||||
}
|
||||
|
||||
missingPieces, err := checker.nodestate.MissingPieces(ctx, createdAt, pieces)
|
||||
missingPieces, err := checker.nodestate.MissingPieces(ctx, pointer.CreationDate, pieces)
|
||||
if err != nil {
|
||||
return Error.New("error getting missing pieces %s", err)
|
||||
}
|
||||
|
@ -87,6 +87,7 @@ func TestIdentifyIrreparableSegments(t *testing.T) {
|
||||
expectedLostPieces[int32(i)] = true
|
||||
}
|
||||
pointer := &pb.Pointer{
|
||||
CreationDate: time.Now(),
|
||||
Remote: &pb.RemoteSegment{
|
||||
Redundancy: &pb.RedundancyScheme{
|
||||
MinReq: int32(3),
|
||||
@ -136,6 +137,7 @@ func TestIdentifyIrreparableSegments(t *testing.T) {
|
||||
|
||||
// make the pointer repairable
|
||||
pointer = &pb.Pointer{
|
||||
CreationDate: time.Now(),
|
||||
Remote: &pb.RemoteSegment{
|
||||
Redundancy: &pb.RedundancyScheme{
|
||||
MinReq: int32(2),
|
||||
@ -185,6 +187,7 @@ func makePointer(t *testing.T, planet *testplanet.Planet, pieceID string, create
|
||||
minReq, repairThreshold = numOfStorageNodes-1, numOfStorageNodes+1
|
||||
}
|
||||
pointer := &pb.Pointer{
|
||||
CreationDate: time.Now(),
|
||||
Remote: &pb.RemoteSegment{
|
||||
Redundancy: &pb.RedundancyScheme{
|
||||
MinReq: int32(minReq),
|
||||
|
@ -8,7 +8,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"storj.io/storj/internal/testcontext"
|
||||
"storj.io/storj/pkg/pb"
|
||||
@ -27,70 +28,75 @@ func TestIrreparable(t *testing.T) {
|
||||
var segments []*pb.IrreparableSegment
|
||||
for i := 0; i < 3; i++ {
|
||||
segments = append(segments, &pb.IrreparableSegment{
|
||||
Path: []byte(strconv.Itoa(i)),
|
||||
SegmentDetail: &pb.Pointer{},
|
||||
Path: []byte(strconv.Itoa(i)),
|
||||
SegmentDetail: &pb.Pointer{
|
||||
CreationDate: time.Now(),
|
||||
},
|
||||
LostPieces: int32(i),
|
||||
LastRepairAttempt: time.Now().Unix(),
|
||||
RepairAttemptCount: int64(10),
|
||||
})
|
||||
|
||||
err := irrdb.IncrementRepairAttempts(ctx, segments[i])
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
{ // GetLimited limit 1, offset 0
|
||||
segs, err := irrdb.GetLimited(ctx, 1, 0)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, len(segs))
|
||||
assert.Equal(t, segments[0], segs[0])
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(segs))
|
||||
require.Empty(t, cmp.Diff(segments[0], segs[0], cmp.Comparer(pb.Equal)))
|
||||
}
|
||||
|
||||
{ // GetLimited limit 1, offset 1
|
||||
segs, err := irrdb.GetLimited(ctx, 1, 1)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, len(segs))
|
||||
assert.Equal(t, segments[1], segs[0])
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(segs))
|
||||
require.Empty(t, cmp.Diff(segments[1], segs[0], cmp.Comparer(pb.Equal)))
|
||||
|
||||
}
|
||||
|
||||
{ // GetLimited limit 2, offset 0
|
||||
segs, err := irrdb.GetLimited(ctx, 2, 0)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 2, len(segs))
|
||||
assert.Equal(t, segments[0], segs[0])
|
||||
assert.Equal(t, segments[1], segs[1])
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 2, len(segs))
|
||||
require.Empty(t, cmp.Diff(segments[0], segs[0], cmp.Comparer(pb.Equal)))
|
||||
require.Empty(t, cmp.Diff(segments[1], segs[1], cmp.Comparer(pb.Equal)))
|
||||
}
|
||||
|
||||
{ // GetLimited limit 2, offset 1
|
||||
segs, err := irrdb.GetLimited(ctx, 2, 1)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 2, len(segs))
|
||||
assert.Equal(t, segments[1], segs[0])
|
||||
assert.Equal(t, segments[2], segs[1])
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 2, len(segs))
|
||||
require.Empty(t, cmp.Diff(segments[1], segs[0], cmp.Comparer(pb.Equal)))
|
||||
require.Empty(t, cmp.Diff(segments[2], segs[1], cmp.Comparer(pb.Equal)))
|
||||
|
||||
}
|
||||
|
||||
{ // GetLimited limit 3, offset 1
|
||||
segs, err := irrdb.GetLimited(ctx, 3, 1)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 2, len(segs))
|
||||
assert.Equal(t, segments[1], segs[0])
|
||||
assert.Equal(t, segments[2], segs[1])
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 2, len(segs))
|
||||
require.Empty(t, cmp.Diff(segments[1], segs[0], cmp.Comparer(pb.Equal)))
|
||||
require.Empty(t, cmp.Diff(segments[2], segs[1], cmp.Comparer(pb.Equal)))
|
||||
}
|
||||
|
||||
{ // Test repair count incrementation
|
||||
err := irrdb.IncrementRepairAttempts(ctx, segments[0])
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
segments[0].RepairAttemptCount++
|
||||
|
||||
dbxInfo, err := irrdb.Get(ctx, segments[0].Path)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, segments[0], dbxInfo)
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, cmp.Diff(segments[0], dbxInfo, cmp.Comparer(pb.Equal)))
|
||||
}
|
||||
|
||||
{ //Delete existing entry
|
||||
err := irrdb.Delete(ctx, segments[0].Path)
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = irrdb.Get(ctx, segments[0].Path)
|
||||
assert.Error(t, err)
|
||||
require.Error(t, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ func (db *DB) getInfo(ctx context.Context, bucket string, path storj.Path) (obj
|
||||
}
|
||||
|
||||
lastSegmentMeta := segments.Meta{
|
||||
Modified: convertTime(pointer.GetCreationDate()),
|
||||
Modified: pointer.CreationDate,
|
||||
Expiration: convertTime(pointer.GetExpirationDate()),
|
||||
Size: pointer.GetSegmentSize(),
|
||||
Data: pointer.GetMetadata(),
|
||||
|
@ -9,12 +9,14 @@ import (
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
timestamp "github.com/golang/protobuf/ptypes/timestamp"
|
||||
math "math"
|
||||
time "time"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
var _ = time.Kitchen
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
@ -255,7 +257,7 @@ type Pointer struct {
|
||||
InlineSegment []byte `protobuf:"bytes,3,opt,name=inline_segment,json=inlineSegment,proto3" json:"inline_segment,omitempty"`
|
||||
Remote *RemoteSegment `protobuf:"bytes,4,opt,name=remote,proto3" json:"remote,omitempty"`
|
||||
SegmentSize int64 `protobuf:"varint,5,opt,name=segment_size,json=segmentSize,proto3" json:"segment_size,omitempty"`
|
||||
CreationDate *timestamp.Timestamp `protobuf:"bytes,6,opt,name=creation_date,json=creationDate,proto3" json:"creation_date,omitempty"`
|
||||
CreationDate time.Time `protobuf:"bytes,6,opt,name=creation_date,json=creationDate,proto3,stdtime" json:"creation_date"`
|
||||
ExpirationDate *timestamp.Timestamp `protobuf:"bytes,7,opt,name=expiration_date,json=expirationDate,proto3" json:"expiration_date,omitempty"`
|
||||
Metadata []byte `protobuf:"bytes,8,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
@ -315,11 +317,11 @@ func (m *Pointer) GetSegmentSize() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Pointer) GetCreationDate() *timestamp.Timestamp {
|
||||
func (m *Pointer) GetCreationDate() time.Time {
|
||||
if m != nil {
|
||||
return m.CreationDate
|
||||
}
|
||||
return nil
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (m *Pointer) GetExpirationDate() *timestamp.Timestamp {
|
||||
@ -451,50 +453,51 @@ func init() {
|
||||
func init() { proto.RegisterFile("pointerdb.proto", fileDescriptor_75fef806d28fc810) }
|
||||
|
||||
var fileDescriptor_75fef806d28fc810 = []byte{
|
||||
// 713 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xcd, 0x6e, 0xeb, 0x44,
|
||||
0x14, 0x6e, 0xfe, 0x9c, 0xf4, 0xd8, 0xf9, 0xb9, 0xa3, 0x2b, 0xb0, 0x72, 0x91, 0x52, 0x2c, 0x5d,
|
||||
0x28, 0xe2, 0xca, 0x45, 0xbe, 0x3b, 0xba, 0x40, 0x2a, 0xa9, 0x44, 0xa4,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0x5e, 0x86, 0x9a, 0x25, 0x4c, 0x33, 0xbf, 0x67, 0x66,
|
||||
0xdf, 0xeb, 0x41, 0x00, 0xbd, 0x9a, 0x2f, 0x02, 0xe0, 0xcc, 0xe6, 0x37, 0xb3, 0xf9, 0xf5, 0xe8,
|
||||
0xa4, 0x94, 0xe9, 0xf5, 0xcf, 0xbf, 0x2c, 0xaf, 0x47, 0x8d, 0xe0, 0x8f, 0x06, 0x78, 0x37, 0x5c,
|
||||
0x69, 0x8a, 0xaa, 0x10, 0xb9, 0x42, 0x12, 0x41, 0x87, 0x6b, 0xcc, 0x94, 0xdf, 0x30, 0x5b, 0xfe,
|
||||
0xe2, 0x88, 0xaa, 0x63, 0x5c, 0x38, 0xd3, 0x98, 0x51, 0x0b, 0x25, 0x04, 0xda, 0x99, 0x90, 0x68,
|
||||
0xae, 0xa9, 0x47, 0x8d, 0x3c, 0x46, 0x68, 0x97, 0x90, 0xd2, 0x57, 0x30, 0x9d, 0x9a, 0x9d, 0x9e,
|
||||
0x52, 0x23, 0x93, 0x0f, 0xd0, 0xad, 0xb2, 0x9a, 0x10, 0x37, 0x22, 0xaf, 0x57, 0x4d, 0x6b, 0x48,
|
||||
0xf9, 0xe0, 0xb8, 0x8a, 0x0b, 0x89, 0x77, 0xfc, 0xc1, 0xec, 0xb7, 0x47, 0x7b, 0x5c, 0xdd, 0x1a,
|
||||
0xfd, 0xaa, 0xfd, 0x6b, 0xb3, 0x58, 0xad, 0x1c, 0xc3, 0xd4, 0xc7, 0x7f, 0x03, 0x00, 0x00, 0xff,
|
||||
0xff, 0x30, 0xf7, 0x57, 0xab, 0x2a, 0x05, 0x00, 0x00,
|
||||
// 723 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xcd, 0x8e, 0xe3, 0x44,
|
||||
0x10, 0x1e, 0xe7, 0xc7, 0xf1, 0x94, 0x9d, 0x9f, 0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, 0x92, 0xa7, 0xd0, 0xd7, 0x42, 0xb3, 0x7d, 0xd8, 0x35,
|
||||
0x66, 0xab, 0x90, 0x6f, 0x60, 0x22, 0xb1, 0x62, 0x5c, 0xa6, 0x3a, 0x97, 0xa8, 0x72, 0xb1, 0xcf,
|
||||
0xc2, 0x9e, 0x01, 0x8c, 0xad, 0x7d, 0xdd, 0x9a, 0xc9, 0xb7, 0xf0, 0x44, 0x1d, 0xb6, 0x5b, 0x54,
|
||||
0xea, 0x0c, 0xdb, 0x37, 0xd8, 0x49, 0xe3, 0x38, 0x81, 0x5f, 0x00, 0x41, 0xc9, 0xd4, 0x41, 0x62,
|
||||
0xaa, 0x72, 0x56, 0x7f, 0xf9, 0x23, 0x86, 0xae, 0x45, 0x37, 0x9e, 0x55, 0xed, 0x58, 0xf1, 0x47,
|
||||
0x8c, 0x9e, 0x02, 0x9c, 0x1e, 0x42, 0x5c, 0xe8, 0xd0, 0xd5, 0xe4, 0x22, 0x7a, 0x04, 0x9f, 0x62,
|
||||
0x21, 0x34, 0xde, 0x73, 0xdc, 0x22, 0x79, 0x06, 0x97, 0x55, 0x2d, 0xa4, 0xe5, 0xa1, 0x30, 0xd4,
|
||||
0xf4, 0xa9, 0x67, 0x0c, 0xcb, 0x43, 0x41, 0xbe, 0x86, 0x41, 0xcd, 0x71, 0xca, 0x33, 0xf3, 0xec,
|
||||
0xe0, 0x76, 0xf4, 0xd7, 0xfb, 0xd9, 0xc5, 0xdf, 0xef, 0x67, 0xee, 0x52, 0x64, 0xb8, 0x98, 0x53,
|
||||
0xb7, 0x76, 0x2f, 0x32, 0xf2, 0x1c, 0x7a, 0x39, 0x53, 0xb9, 0x61, 0xc1, 0x4f, 0x9e, 0xc4, 0xcd,
|
||||
0x34, 0x4c, 0x89, 0x1f, 0x99, 0xca, 0xa9, 0x71, 0x47, 0x1f, 0x1c, 0x18, 0xda, 0xe2, 0x2b, 0xdc,
|
||||
0x15, 0x58, 0x6a, 0xf2, 0x0a, 0x40, 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x00,
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ message Pointer {
|
||||
RemoteSegment remote = 4;
|
||||
int64 segment_size = 5;
|
||||
|
||||
google.protobuf.Timestamp creation_date = 6;
|
||||
google.protobuf.Timestamp creation_date = 6 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
|
||||
google.protobuf.Timestamp expiration_date = 7;
|
||||
|
||||
bytes metadata = 8;
|
||||
|
@ -126,6 +126,7 @@ func (s *segmentStore) Put(ctx context.Context, data io.Reader, expiration time.
|
||||
path = p
|
||||
|
||||
pointer = &pb.Pointer{
|
||||
CreationDate: time.Now(),
|
||||
Type: pb.Pointer_INLINE,
|
||||
InlineSegment: peekReader.thresholdBuf,
|
||||
SegmentSize: int64(len(peekReader.thresholdBuf)),
|
||||
@ -256,7 +257,8 @@ func makeRemotePointer(nodes []*pb.Node, hashes []*pb.PieceHash, rs eestream.Red
|
||||
}
|
||||
|
||||
pointer = &pb.Pointer{
|
||||
Type: pb.Pointer_REMOTE,
|
||||
CreationDate: time.Now(),
|
||||
Type: pb.Pointer_REMOTE,
|
||||
Remote: &pb.RemoteSegment{
|
||||
Redundancy: &pb.RedundancyScheme{
|
||||
Type: pb.RedundancyScheme_RS,
|
||||
@ -356,7 +358,7 @@ func CalcNeededNodes(rs *pb.RedundancyScheme) int32 {
|
||||
// convertMeta converts pointer to segment metadata
|
||||
func convertMeta(pr *pb.Pointer) Meta {
|
||||
return Meta{
|
||||
Modified: convertTime(pr.GetCreationDate()),
|
||||
Modified: pr.GetCreationDate(),
|
||||
Expiration: convertTime(pr.GetExpirationDate()),
|
||||
Size: pr.GetSegmentSize(),
|
||||
Data: pr.GetMetadata(),
|
||||
|
@ -57,7 +57,7 @@ func TestSegmentStoreMeta(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, expectedSize, meta.Size)
|
||||
assert.Equal(t, test.metadata, meta.Data)
|
||||
assert.Equal(t, test.expiration, meta.Expiration)
|
||||
assert.True(t, test.expiration.Equal(meta.Expiration))
|
||||
assert.True(t, meta.Modified.After(beforeModified))
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ func TestSegmentStoreMeta(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, expectedSize, meta.Size)
|
||||
assert.Equal(t, test.metadata, meta.Data)
|
||||
assert.Equal(t, test.expiration, meta.Expiration)
|
||||
assert.True(t, test.expiration.Equal(meta.Expiration))
|
||||
assert.True(t, meta.Modified.After(beforeModified))
|
||||
} else {
|
||||
require.Contains(t, err.Error(), test.err)
|
||||
|
12
proto.lock
12
proto.lock
@ -3497,7 +3497,17 @@
|
||||
{
|
||||
"id": 6,
|
||||
"name": "creation_date",
|
||||
"type": "google.protobuf.Timestamp"
|
||||
"type": "google.protobuf.Timestamp",
|
||||
"options": [
|
||||
{
|
||||
"name": "(gogoproto.stdtime)",
|
||||
"value": "true"
|
||||
},
|
||||
{
|
||||
"name": "(gogoproto.nullable)",
|
||||
"value": "false"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
|
@ -333,8 +333,9 @@ func TestCommitSegment(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
pointer := &pb.Pointer{
|
||||
Type: pb.Pointer_REMOTE,
|
||||
SegmentSize: 10,
|
||||
CreationDate: time.Now(),
|
||||
Type: pb.Pointer_REMOTE,
|
||||
SegmentSize: 10,
|
||||
Remote: &pb.RemoteSegment{
|
||||
RootPieceId: rootPieceID,
|
||||
Redundancy: redundancy,
|
||||
@ -746,8 +747,9 @@ func createTestPointer(t *testing.T) *pb.Pointer {
|
||||
expiration, err := ptypes.TimestampProto(timestamp)
|
||||
require.NoError(t, err)
|
||||
pointer := &pb.Pointer{
|
||||
Type: pb.Pointer_REMOTE,
|
||||
SegmentSize: segmentSize,
|
||||
CreationDate: time.Now(),
|
||||
Type: pb.Pointer_REMOTE,
|
||||
SegmentSize: segmentSize,
|
||||
Remote: &pb.RemoteSegment{
|
||||
Redundancy: rs,
|
||||
RemotePieces: []*pb.RemotePiece{
|
||||
|
@ -5,9 +5,9 @@ package metainfo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
|
||||
@ -32,7 +32,7 @@ func (s *Service) Put(ctx context.Context, path string, pointer *pb.Pointer) (er
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
// Update the pointer with the creation date
|
||||
pointer.CreationDate = ptypes.TimestampNow()
|
||||
pointer.CreationDate = time.Now()
|
||||
|
||||
pointerBytes, err := proto.Marshal(pointer)
|
||||
if err != nil {
|
||||
|
@ -54,7 +54,7 @@ func (db *vouchersdb) Put(ctx context.Context, voucher *pb.Voucher) (err error)
|
||||
func (db *vouchersdb) NeedVoucher(ctx context.Context, satelliteID storj.NodeID, expirationBuffer time.Duration) (need bool, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
expiresBefore := time.Now().Add(expirationBuffer)
|
||||
expiresBefore := time.Now().UTC().Add(expirationBuffer)
|
||||
|
||||
// query returns row if voucher is good. If not, it is either expiring or does not exist
|
||||
row := db.db.QueryRow(`
|
||||
|
Loading…
Reference in New Issue
Block a user