Skip to content
Snippets Groups Projects
Unverified Commit 894ce4d8 authored by Silas Davis's avatar Silas Davis
Browse files

Don't store Tx in state for every event (for now)


Signed-off-by: default avatarSilas Davis <silas@monax.io>
parent 5e387c31
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,27 @@ func (ev *Event) Key() Key {
return ev.Header.Key()
}
// Performs a shallow copy of Event
func (ev *Event) Copy() *Event {
h := *ev.Header
evCopy := Event{
Header: &h,
}
if ev.Tx != nil {
tx := *ev.Tx
evCopy.Tx = &tx
}
if ev.Call != nil {
call := *ev.Call
evCopy.Call = &call
}
if ev.Log != nil {
log := *ev.Log
evCopy.Log = &log
}
return &evCopy
}
func (ev *Event) Encode() ([]byte, error) {
return cdc.MarshalBinary(ev)
}
......
......@@ -321,6 +321,12 @@ func (ws *writeState) Publish(ctx context.Context, msg interface{}, tags event.T
ws.state.eventKeyHighWatermark, exeEvent)
}
ws.state.eventKeyHighWatermark = key
if exeEvent.Tx != nil {
// Don't serialise the tx (for now) we should normalise and store against tx hash
exeEvent = exeEvent.Copy()
// The header still contains the tx hash
exeEvent.Tx.Tx = nil
}
bs, err := exeEvent.Encode()
if err != nil {
return err
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment