satellite/orders: query for node first before upsert/replace
the very common case is that the node api version is indeed at least the requested version, so query for that first to avoid write traffic. Change-Id: Ib047d93078205bc07fee75d1f635503b792307f0
This commit is contained in:
parent
70efbd9837
commit
8a6efa1f58
@ -217,9 +217,16 @@ func (endpoint *Endpoint) SettlementWithWindowFinal(stream pb.DRPCOrders_Settlem
|
||||
return rpcstatus.Error(rpcstatus.Unauthenticated, err.Error())
|
||||
}
|
||||
|
||||
err = endpoint.nodeAPIVersionDB.UpdateVersionAtLeast(ctx, peer.ID, nodeapiversion.HasWindowedOrders)
|
||||
versionAtLeast, err := endpoint.nodeAPIVersionDB.VersionAtLeast(ctx, peer.ID, nodeapiversion.HasWindowedOrders)
|
||||
if err != nil {
|
||||
return rpcstatus.Wrap(rpcstatus.Internal, err)
|
||||
endpoint.log.Info("could not query if node version was new enough", zap.Error(err))
|
||||
versionAtLeast = false
|
||||
}
|
||||
if !versionAtLeast {
|
||||
err = endpoint.nodeAPIVersionDB.UpdateVersionAtLeast(ctx, peer.ID, nodeapiversion.HasWindowedOrders)
|
||||
if err != nil {
|
||||
return rpcstatus.Wrap(rpcstatus.Internal, err)
|
||||
}
|
||||
}
|
||||
|
||||
log := endpoint.log.Named(peer.ID.String())
|
||||
|
Loading…
Reference in New Issue
Block a user