Skip to content

Commit

Permalink
Remove write lock option from the xsvm API
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph committed Oct 9, 2023
1 parent 6d53e51 commit 1ed1f59
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 6 additions & 1 deletion vms/example/xsvm/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ func (s *server) IssueTx(r *http.Request, args *IssueTxArgs, reply *IssueTxReply
}

ctx := r.Context()
if err := s.builder.AddTx(ctx, newTx); err != nil {
s.ctx.Lock.Lock()
err = s.builder.AddTx(ctx, newTx)
s.ctx.Lock.Unlock()
if err != nil {
return err
}

Expand All @@ -150,7 +153,9 @@ type LastAcceptedReply struct {
}

func (s *server) LastAccepted(_ *http.Request, _ *struct{}, reply *LastAcceptedReply) error {
s.ctx.Lock.RLock()
reply.BlockID = s.chain.LastAccepted()
s.ctx.Lock.RUnlock()
blkBytes, err := state.GetBlock(s.state, reply.BlockID)
if err != nil {
return err
Expand Down
7 changes: 2 additions & 5 deletions vms/example/xsvm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,12 @@ func (vm *VM) CreateHandlers(_ context.Context) (map[string]*common.HTTPHandler,
vm.chain,
vm.builder,
)
if err := server.RegisterService(api, Name); err != nil {
return nil, err
}
return map[string]*common.HTTPHandler{
"": {
LockOptions: common.WriteLock,
LockOptions: common.NoLock,
Handler: server,
},
}, nil
}, server.RegisterService(api, Name)
}

func (*VM) HealthCheck(context.Context) (interface{}, error) {
Expand Down

0 comments on commit 1ed1f59

Please sign in to comment.