mirror of
https://github.com/minio/minio.git
synced 2024-12-26 07:05:55 -05:00
Merge pull request #256 from fkautz/pr_out_fragment_now_implements_new_version
This commit is contained in:
commit
237921338a
@ -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
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -54,13 +51,10 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type DonutFrameHeader struct {
|
type DonutFrameHeader struct {
|
||||||
MagicMINI uint32
|
MagicMINI uint32
|
||||||
VersionMajor uint16
|
Version uint32
|
||||||
VersionMinor uint16
|
Reserved uint64
|
||||||
VersionPatch uint16
|
DataLength uint64
|
||||||
VersionReserved uint16
|
|
||||||
Reserved uint64
|
|
||||||
DataLength uint64
|
|
||||||
}
|
}
|
||||||
type Crc32c uint32
|
type Crc32c uint32
|
||||||
type Sha512 [sha512.Size]byte
|
type Sha512 [sha512.Size]byte
|
||||||
@ -77,13 +71,10 @@ type Data bytes.Buffer
|
|||||||
func WriteFrame(target io.Writer, reader io.Reader, length uint64) error {
|
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,
|
Reserved: 0,
|
||||||
VersionPatch: 0,
|
DataLength: length,
|
||||||
VersionReserved: 0,
|
|
||||||
Reserved: 0,
|
|
||||||
DataLength: length,
|
|
||||||
}
|
}
|
||||||
var headerBytes bytes.Buffer
|
var headerBytes bytes.Buffer
|
||||||
binary.Write(&headerBytes, binary.LittleEndian, header)
|
binary.Write(&headerBytes, binary.LittleEndian, header)
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user