This commit is contained in:
Caesar Chad 2018-06-13 08:56:07 +00:00 committed by GitHub
commit c70aa6cb94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View file

@ -64,6 +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
func memoryMap(path string) (*os.File, mmap.MMap, []uint32, error) {
file, err := os.OpenFile(path, os.O_RDONLY, 0644)
if err != nil {
@ -346,7 +348,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()

View file

@ -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
@ -76,7 +76,7 @@ type Console struct {
// New initializes a JavaScript interpreted runtime environment and sets defaults
// with the config 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
}
@ -84,7 +84,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{