From 378d314b259b72f26b66d109b9fc93bb16bb49fe Mon Sep 17 00:00:00 2001 From: bluewebgeek Date: Wed, 13 Jun 2018 15:50:34 +0800 Subject: [PATCH 1/3] 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() From 318008331f32b12e0deae6149fe8ac7e944ae891 Mon Sep 17 00:00:00 2001 From: bluewebgeek Date: Wed, 13 Jun 2018 16:05:41 +0800 Subject: [PATCH 2/3] Add comments for mmap package usage --- consensus/ethash/ethash.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/consensus/ethash/ethash.go b/consensus/ethash/ethash.go index 23a251062a..701f6c51ea 100644 --- a/consensus/ethash/ethash.go +++ b/consensus/ethash/ethash.go @@ -64,7 +64,8 @@ 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 +// 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 { From 44e790e014c922f8c68d94cdae213347f22f6d7f Mon Sep 17 00:00:00 2001 From: bluewebgeek Date: Wed, 13 Jun 2018 16:51:51 +0800 Subject: [PATCH 3/3] Correct comments typo --- console/console.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/console/console.go b/console/console.go index b280d4e65d..13e6e745e2 100644 --- a/console/console.go +++ b/console/console.go @@ -60,11 +60,11 @@ type Config struct { Preload []string // Absolute paths to JavaScript files to preload } -// Console is a JavaScript interpreted runtime environment. It is a fully fleged +// Console is a JavaScript interpreted runtime environment. It is a fully fledged // JavaScript console attached to a running node via an external or in-process RPC // client. type Console struct { - client *rpc.Client // RPC client to execute Ethereum requests through + client *rpc.Client // RPC client to execute Ethereum requests through rpc jsre *jsre.JSRE // JavaScript runtime environment running the interpreter prompt string // Input prompt prefix string prompter UserPrompter // Input prompter to allow interactive user feedback @@ -74,7 +74,7 @@ type Console struct { } func New(config Config) (*Console, error) { - // Handle unset config values gracefully + // Handle unset config values with default value if config.Prompter == nil { config.Prompter = Stdin } @@ -82,7 +82,7 @@ func New(config Config) (*Console, error) { config.Prompt = DefaultPrompt } if config.Printer == nil { - config.Printer = colorable.NewColorableStdout() + config.Printer = colorable.NewColorableStdout() // colorful standard output } // Initialize the console and return console := &Console{