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.
|
// 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) {
|
func memoryMap(path string) (*os.File, mmap.MMap, []uint32, error) {
|
||||||
file, err := os.OpenFile(path, os.O_RDONLY, 0644)
|
file, err := os.OpenFile(path, os.O_RDONLY, 0644)
|
||||||
if err != nil {
|
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() {
|
func (d *dataset) finalizer() {
|
||||||
if d.mmap != nil {
|
if d.mmap != nil {
|
||||||
d.mmap.Unmap()
|
d.mmap.Unmap()
|
||||||
|
|
|
||||||
|
|
@ -60,11 +60,11 @@ type Config struct {
|
||||||
Preload []string // Absolute paths to JavaScript files to preload
|
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
|
// JavaScript console attached to a running node via an external or in-process RPC
|
||||||
// client.
|
// client.
|
||||||
type Console struct {
|
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
|
jsre *jsre.JSRE // JavaScript runtime environment running the interpreter
|
||||||
prompt string // Input prompt prefix string
|
prompt string // Input prompt prefix string
|
||||||
prompter UserPrompter // Input prompter to allow interactive user feedback
|
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
|
// New initializes a JavaScript interpreted runtime environment and sets defaults
|
||||||
// with the config struct.
|
// with the config struct.
|
||||||
func New(config Config) (*Console, error) {
|
func New(config Config) (*Console, error) {
|
||||||
// Handle unset config values gracefully
|
// Handle unset config values with default value
|
||||||
if config.Prompter == nil {
|
if config.Prompter == nil {
|
||||||
config.Prompter = Stdin
|
config.Prompter = Stdin
|
||||||
}
|
}
|
||||||
|
|
@ -84,7 +84,7 @@ func New(config Config) (*Console, error) {
|
||||||
config.Prompt = DefaultPrompt
|
config.Prompt = DefaultPrompt
|
||||||
}
|
}
|
||||||
if config.Printer == nil {
|
if config.Printer == nil {
|
||||||
config.Printer = colorable.NewColorableStdout()
|
config.Printer = colorable.NewColorableStdout() // colorful standard output
|
||||||
}
|
}
|
||||||
// Initialize the console and return
|
// Initialize the console and return
|
||||||
console := &Console{
|
console := &Console{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue