Merge pull request #256 from fkautz/pr_out_fragment_now_implements_new_version

This commit is contained in:
Frederick F. Kautz IV 2015-03-05 20:56:13 -08:00
commit 237921338a
2 changed files with 16 additions and 40 deletions

View File

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

View File

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