diff --git a/core/block/meta/pubsub.go b/core/block/meta/pubsub.go index e54db16a2..cd1cbcdc7 100644 --- a/core/block/meta/pubsub.go +++ b/core/block/meta/pubsub.go @@ -367,9 +367,9 @@ func (c *collector) close() { } func copyMeta(m Meta) Meta { - var d *types.Struct + d := m.Details if d != nil { - d = pbtypes.CopyStruct(m.SmartBlockMeta.Details) + d = pbtypes.CopyStruct(m.Details) } return Meta{ BlockId: diff --git a/util/pbtypes/copy.go b/util/pbtypes/copy.go index 91a29b476..536b0fbab 100644 --- a/util/pbtypes/copy.go +++ b/util/pbtypes/copy.go @@ -13,11 +13,6 @@ var bytesPool = &sync.Pool{ }, } -type Type interface { - Size() int - MarshalToSizedBuffer(data []byte) (int, error) -} - func CopyBlock(in *model.Block) (out *model.Block) { buf := bytesPool.Get().([]byte) size := in.Size() diff --git a/util/pbtypes/copy_test.go b/util/pbtypes/copy_test.go new file mode 100644 index 000000000..8dbd2987a --- /dev/null +++ b/util/pbtypes/copy_test.go @@ -0,0 +1,19 @@ +package pbtypes + +import ( + "testing" + + "github.com/gogo/protobuf/types" + "github.com/stretchr/testify/assert" +) + +func TestCopyStruct(t *testing.T) { + s := &types.Struct{ + Fields: map[string]*types.Value{ + "string": String("string"), + "bool": Bool(true), + }, + } + c := CopyStruct(s) + assert.True(t, s.Equal(c)) +}