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,10 +217,17 @@ func (endpoint *Endpoint) SettlementWithWindowFinal(stream pb.DRPCOrders_Settlem
|
|||||||
return rpcstatus.Error(rpcstatus.Unauthenticated, err.Error())
|
return rpcstatus.Error(rpcstatus.Unauthenticated, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
versionAtLeast, err := endpoint.nodeAPIVersionDB.VersionAtLeast(ctx, peer.ID, nodeapiversion.HasWindowedOrders)
|
||||||
|
if err != nil {
|
||||||
|
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)
|
err = endpoint.nodeAPIVersionDB.UpdateVersionAtLeast(ctx, peer.ID, nodeapiversion.HasWindowedOrders)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return rpcstatus.Wrap(rpcstatus.Internal, err)
|
return rpcstatus.Wrap(rpcstatus.Internal, err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log := endpoint.log.Named(peer.ID.String())
|
log := endpoint.log.Named(peer.ID.String())
|
||||||
log.Debug("SettlementWithWindow")
|
log.Debug("SettlementWithWindow")
|
||||||
|
Loading…
Reference in New Issue
Block a user