storagenode/gracefulexit: get hash and limit using original piece ID (#3557)

This commit is contained in:
Yingrong Zhao 2019-11-13 12:45:55 -05:00 committed by GitHub
parent 0ff1547d08
commit db8294cfba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -171,7 +171,7 @@ func (worker *Worker) transferPiece(ctx context.Context, transferPiece *pb.Trans
addrLimit := transferPiece.GetAddressedOrderLimit()
pk := transferPiece.PrivateKey
originalHash, originalOrderLimit, err := worker.getHashAndLimit(ctx, reader, addrLimit.GetLimit())
originalHash, originalOrderLimit, err := worker.getHashAndLimit(ctx, reader, pieceID)
if err != nil {
worker.log.Error("failed to get piece hash and order limit.",
zap.Stringer("Satellite ID", worker.satelliteID),
@ -332,11 +332,11 @@ func (worker *Worker) Close() error {
}
// TODO This comes from piecestore.Endpoint. It should probably be an exported method so I don't have to duplicate it here.
func (worker *Worker) getHashAndLimit(ctx context.Context, pieceReader *pieces.Reader, limit *pb.OrderLimit) (pieceHash *pb.PieceHash, orderLimit *pb.OrderLimit, err error) {
func (worker *Worker) getHashAndLimit(ctx context.Context, pieceReader *pieces.Reader, pieceID storj.PieceID) (pieceHash *pb.PieceHash, orderLimit *pb.OrderLimit, err error) {
if pieceReader.StorageFormatVersion() == 0 {
// v0 stores this information in SQL
info, err := worker.store.GetV0PieceInfoDB().Get(ctx, limit.SatelliteId, limit.PieceId)
info, err := worker.store.GetV0PieceInfoDB().Get(ctx, worker.satelliteID, pieceID)
if err != nil {
worker.log.Error("error getting piece from v0 pieceinfo db", zap.Error(err))
return nil, nil, err