un-expose hooks copy
This commit is contained in:
parent
de48d559ea
commit
9cae376df4
|
@ -207,8 +207,10 @@ type Hooks struct {
|
|||
OnBlockHashRead BlockHashReadHook
|
||||
}
|
||||
|
||||
// Copy creates a new Hooks instance with all implemented hooks copied from the original.
|
||||
func (h *Hooks) Copy() *Hooks {
|
||||
// copy creates a new Hooks instance with all implemented hooks copied from the original.
|
||||
// Note: it is not a deep copy. If a hook has been implemented as a closure and acts on
|
||||
// a mutable state, the copied hook will still act on the same state.
|
||||
func (h *Hooks) copy() *Hooks {
|
||||
copied := &Hooks{}
|
||||
srcValue := reflect.ValueOf(h).Elem()
|
||||
dstValue := reflect.ValueOf(copied).Elem()
|
||||
|
|
|
@ -62,7 +62,7 @@ func WrapWithJournal(hooks *Hooks) (*Hooks, error) {
|
|||
}
|
||||
|
||||
// Create a new Hooks instance and copy all hooks
|
||||
wrapped := hooks.Copy()
|
||||
wrapped := hooks.copy()
|
||||
// Create journal
|
||||
j := &journal{entries: make([]entry, 0), hooks: hooks}
|
||||
// Scope hooks need to be re-implemented.
|
||||
|
|
|
@ -179,7 +179,7 @@ func TestAllHooksCalled(t *testing.T) {
|
|||
continue
|
||||
}
|
||||
// Skip non-hooks, i.e. Copy
|
||||
if field.Name == "Copy" {
|
||||
if field.Name == "copy" {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue