etcd/wal/walpb/record.go

30 lines
810 B
Go
Raw Normal View History

2016-05-13 06:50:04 +03:00
// Copyright 2015 The etcd Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
2014-07-28 07:58:39 +04:00
2014-09-04 03:46:42 +04:00
package walpb
2014-07-28 04:23:04 +04:00
2014-09-04 03:46:42 +04:00
import "errors"
var (
ErrCRCMismatch = errors.New("walpb: crc mismatch")
)
func (rec *Record) Validate(crc uint32) error {
2014-09-04 02:10:15 +04:00
if rec.Crc == crc {
return nil
2014-07-28 04:23:04 +04:00
}
2014-08-05 02:46:12 +04:00
rec.Reset()
2014-09-04 02:10:15 +04:00
return ErrCRCMismatch
2014-08-24 09:55:01 +04:00
}