Merge pull request #256 from fkautz/pr_out_fragment_now_implements_new_version

master
Frederick F. Kautz IV 10 years ago
commit 237921338a
  1. 21
      pkg/storage/donut/fragment/fragment_v1/fragment.go
  2. 23
      pkg/storage/donut/fragment/fragment_v1/fragment_test.go

@ -30,20 +30,17 @@ import (
DONUT v1 Spec
**********************
BlockStart [4]byte // Magic="MINI"=1229867341
VersionMajor uint16
VersionMinor uint16
VersionPatch uint16
VersionReserved uint16
BlockStart uint32 // Magic="MINI"=1229867341
VersionMajor uint32
Reserved uint64
DataLen uint64
HeaderCrc32c uint32
BlockData [4]byte // Magic="DATA"=1096040772
BlockData uint32 // Magic="DATA"=1096040772
Data io.Reader // matches length
HeaderCrc32c uint32
DataSha512 [64]byte
BlockLen uint64 // length of entire frame, inclusive of MINI and INIM
BlockEnd [4]byte // Magic="INIM"=1296649801
BlockEnd uint32 // Magic="INIM"=1296649801
*/
@ -55,10 +52,7 @@ var (
type DonutFrameHeader struct {
MagicMINI uint32
VersionMajor uint16
VersionMinor uint16
VersionPatch uint16
VersionReserved uint16
Version uint32
Reserved uint64
DataLength uint64
}
@ -78,10 +72,7 @@ func WriteFrame(target io.Writer, reader io.Reader, length uint64) error {
// write header
header := DonutFrameHeader{
MagicMINI: MagicMINI,
VersionMajor: 1,
VersionMinor: 0,
VersionPatch: 0,
VersionReserved: 0,
Version: 1,
Reserved: 0,
DataLength: length,
}

@ -45,7 +45,7 @@ func (s *MySuite) TestSingleWrite(c *C) {
testBufferLength := uint64(testBuffer.Len())
// we test our crc here too
headerBytes := testBuffer.Bytes()[0:28]
headerBytes := testBuffer.Bytes()[:24]
expectedCrc := crc32c.Sum32(headerBytes)
// magic mini
@ -54,24 +54,9 @@ func (s *MySuite) TestSingleWrite(c *C) {
c.Assert(magicMini, DeepEquals, []byte{'M', 'I', 'N', 'I'})
// major version
majorVersion := make([]byte, 2)
testBuffer.Read(majorVersion)
c.Assert(binary.LittleEndian.Uint16(majorVersion), DeepEquals, uint16(1))
// minor version
minorVersion := make([]byte, 2)
testBuffer.Read(minorVersion)
c.Assert(binary.LittleEndian.Uint16(minorVersion), DeepEquals, uint16(0))
// patch version
patchVersion := make([]byte, 2)
testBuffer.Read(patchVersion)
c.Assert(binary.LittleEndian.Uint16(patchVersion), DeepEquals, uint16(0))
// reserved version
reservedVersion := make([]byte, 2)
testBuffer.Read(reservedVersion)
c.Assert(binary.LittleEndian.Uint16(reservedVersion), DeepEquals, uint16(0))
version := make([]byte, 4)
testBuffer.Read(version)
c.Assert(binary.LittleEndian.Uint32(version), DeepEquals, uint32(1))
// reserved
reserved := make([]byte, 8)

Loading…
Cancel
Save