mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
Merge 44e790e014 into 8c4a7fa8d3
This commit is contained in:
commit
c70aa6cb94
2 changed files with 8 additions and 5 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
Loading…
Reference in a new issue