From da2156f95564b17d99f3bda71e8a0467ca6a140c Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Tue, 1 Oct 2019 16:38:33 +0300 Subject: [PATCH] vm: add batched RegisterInteropFuncs --- pkg/vm/vm.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index 310e18b6f..6ecfbd9e4 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -80,6 +80,15 @@ func (v *VM) RegisterInteropFunc(name string, f InteropFunc, price int) { v.interop[name] = InteropFuncPrice{f, price} } +// RegisterInteropFuncs will register all interop functions passed in a map in +// the VM. Effectively it's a batched version of RegisterInteropFunc. +func (v *VM) RegisterInteropFuncs(interops map[string]InteropFuncPrice) { + // We allow reregistration here. + for name, funPrice := range interops { + v.interop[name] = funPrice + } +} + // Estack will return the evaluation stack so interop hooks can utilize this. func (v *VM) Estack() *Stack { return v.estack