diff --git a/nats-streaming-server.go b/nats-streaming-server.go index 4c682071..5edb296a 100644 --- a/nats-streaming-server.go +++ b/nats-streaming-server.go @@ -133,7 +133,7 @@ func parseFlags() (*stand.Options, *natsd.Options) { flag.Int64Var(&stanOpts.FileStoreOpts.CompactMinFileSize, "file_compact_min_size", stores.DefaultFileStoreOptions.CompactMinFileSize, "Minimum file size for compaction") flag.IntVar(&stanOpts.FileStoreOpts.BufferSize, "file_buffer_size", stores.DefaultFileStoreOptions.BufferSize, "File buffer size (in bytes)") flag.BoolVar(&stanOpts.FileStoreOpts.DoCRC, "file_crc", stores.DefaultFileStoreOptions.DoCRC, "Enable file CRC-32 checksum") - flag.IntVar(&stanOpts.FileStoreOpts.CRCPolynomial, "file_crc_poly", stores.DefaultFileStoreOptions.CRCPolynomial, "Polynomial used to make the table used for CRC-32 checksum") + flag.Int64Var(&stanOpts.FileStoreOpts.CRCPolynomial, "file_crc_poly", stores.DefaultFileStoreOptions.CRCPolynomial, "Polynomial used to make the table used for CRC-32 checksum") flag.IntVar(&stanOpts.IOBatchSize, "io_batch_size", stand.DefaultIOBatchSize, "# of message to batch in flushing io") flag.Int64Var(&stanOpts.IOSleepTime, "io_sleep_time", stand.DefaultIOSleepTime, "duration the server waits for more messages (in micro-seconds, 0 to disable)") // NATS options diff --git a/stores/filestore.go b/stores/filestore.go index fe3c85d4..11e96ed7 100644 --- a/stores/filestore.go +++ b/stores/filestore.go @@ -74,7 +74,7 @@ type FileStoreOptions struct { DoCRC bool // CRCPoly is a polynomial used to make the table used in CRC computation. - CRCPolynomial int + CRCPolynomial int64 } // DefaultFileStoreOptions defines the default options for a File Store. @@ -85,7 +85,7 @@ var DefaultFileStoreOptions = FileStoreOptions{ CompactFragmentation: 50, CompactMinFileSize: 1024 * 1024, DoCRC: true, - CRCPolynomial: crc32.IEEE, + CRCPolynomial: int64(crc32.IEEE), } // BufferSize is a FileStore option that sets the size of the buffer used @@ -148,7 +148,7 @@ func DoCRC(enableCRC bool) FileStoreOption { // CRCPolynomial is a FileStore option that defines the polynomial to use to create // the table used for CRC-32 Checksum. // See https://golang.org/pkg/hash/crc32/#MakeTable -func CRCPolynomial(polynomial int) FileStoreOption { +func CRCPolynomial(polynomial int64) FileStoreOption { return func(o *FileStoreOptions) error { o.CRCPolynomial = polynomial return nil @@ -412,7 +412,7 @@ func NewFileStore(rootDir string, limits *ChannelLimits, options ...FileStoreOpt // Convert the compact interval in time.Duration fs.compactItvl = time.Duration(fs.opts.CompactInterval) * time.Second // Create the table using polynomial in options - if fs.opts.CRCPolynomial == crc32.IEEE { + if fs.opts.CRCPolynomial == int64(crc32.IEEE) { fs.crcTable = crc32.IEEETable } else { fs.crcTable = crc32.MakeTable(uint32(fs.opts.CRCPolynomial)) diff --git a/stores/filestore_test.go b/stores/filestore_test.go index 4c72f90c..51d092ae 100644 --- a/stores/filestore_test.go +++ b/stores/filestore_test.go @@ -222,7 +222,7 @@ func TestFSOptions(t *testing.T) { CompactInterval: 60, CompactMinFileSize: 1024 * 1024, DoCRC: false, - CRCPolynomial: crc32.Castagnoli, + CRCPolynomial: int64(crc32.Castagnoli), } // Create the file with custom options fs, _, err := NewFileStore(defaultDataStore, &testDefaultChannelLimits, @@ -232,7 +232,7 @@ func TestFSOptions(t *testing.T) { CompactInterval(expected.CompactInterval), CompactMinFileSize(expected.CompactMinFileSize), DoCRC(expected.DoCRC), - CRCPolynomial(int(expected.CRCPolynomial))) + CRCPolynomial(expected.CRCPolynomial)) if err != nil { t.Fatalf("Unexpected error on file store create: %v", err) }