1

I just want to be clear how dose the js command run. I trace the code when I type admin.peers in geth console. Then I found that it runs in jsre.go:

// Evaluate executes code and pretty prints the result to the specified output
// stream.
func (self *JSRE) Evaluate(code string, w io.Writer) error {
    var fail error

    self.Do(func(vm *otto.Otto) {
        val, err := vm.Run(code)
        if err != nil {
            prettyError(vm, err, w)
        } else {
            prettyPrint(vm, val, w)
        }
        fmt.Fprintln(w)
    })
    return fail
}

may be val, err := vm.Run(code) could get the result of the command. But how does the otto JavaScript parser and interpreter connect the exact ethereum code ? how does the vm.Run(code) get the result? thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.