From c3b3b14872a306f4927f1feccb9ee7ff823c4134 Mon Sep 17 00:00:00 2001 From: bb-2 <43212522+bb-2@users.noreply.github.com> Date: Tue, 5 May 2020 08:10:22 -0400 Subject: [PATCH] Moving the cache put statements in SetStatus and SetIDs to be after the error checking --- vms/spdagvm/state.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vms/spdagvm/state.go b/vms/spdagvm/state.go index 74c12c9..0f02c03 100644 --- a/vms/spdagvm/state.go +++ b/vms/spdagvm/state.go @@ -130,8 +130,6 @@ func (s *state) SetStatus(id ids.ID, status choices.Status) error { return s.vm.db.Delete(id.Bytes()) } - s.c.Put(id, status) - p := wrappers.Packer{Bytes: make([]byte, 4)} p.PackInt(uint32(status)) @@ -143,6 +141,8 @@ func (s *state) SetStatus(id ids.ID, status choices.Status) error { if p.Errored() { return p.Err } + + s.c.Put(id, status) return s.vm.db.Put(id.Bytes(), p.Bytes) } @@ -186,8 +186,6 @@ func (s *state) SetIDs(id ids.ID, idSlice []ids.ID) error { return s.vm.db.Delete(id.Bytes()) } - s.c.Put(id, idSlice) - size := wrappers.IntLen + hashing.HashLen*len(idSlice) p := wrappers.Packer{Bytes: make([]byte, size)} @@ -203,5 +201,7 @@ func (s *state) SetIDs(id ids.ID, idSlice []ids.ID) error { if p.Errored() { return p.Err } + + s.c.Put(id, idSlice) return s.vm.db.Put(id.Bytes(), p.Bytes) }