From 378d314b259b72f26b66d109b9fc93bb16bb49fe Mon Sep 17 00:00:00 2001 From: bluewebgeek Date: Wed, 13 Jun 2018 15:50:34 +0800 Subject: [PATCH] Add comments to ethsh.go to clarify mmp package usage. --- consensus/ethash/ethash.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/consensus/ethash/ethash.go b/consensus/ethash/ethash.go index ac049f9c36..23a251062a 100644 --- a/consensus/ethash/ethash.go +++ b/consensus/ethash/ethash.go @@ -64,6 +64,7 @@ func isLittleEndian() bool { } // memoryMap tries to memory map a file of uint32s for read only access. +// mmap is a portable memory map package which would enable direct access for memory mapping files func memoryMap(path string) (*os.File, mmap.MMap, []uint32, error) { file, err := os.OpenFile(path, os.O_RDONLY, 0644) if err != nil { @@ -346,7 +347,8 @@ func (d *dataset) generate(dir string, limit int, test bool) { }) } -// finalizer closes any file handlers and memory maps open. +// finalizer closes any file handlers and use Unmap() to deletes the memory mapped region, +// flushes any remaining changes. func (d *dataset) finalizer() { if d.mmap != nil { d.mmap.Unmap()