MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / isProviderReqMatch

Function isProviderReqMatch

blockproducer/metastate.go:770–803  ·  view source on GitHub ↗
(po *types.ProviderProfile, req *types.CreateDatabase)

Source from the content-addressed store, hash-verified

768}
769
770func isProviderReqMatch(po *types.ProviderProfile, req *types.CreateDatabase) (match bool, err error) {
771 if po.GasPrice > req.GasPrice {
772 err = errors.New("gas price mismatch")
773 log.WithError(err).Debugf("miner's gas price: %d, user's gas price: %d",
774 po.GasPrice, req.GasPrice)
775 return
776 }
777 if req.ResourceMeta.LoadAvgPerCPU > 0.0 && po.LoadAvgPerCPU > req.ResourceMeta.LoadAvgPerCPU {
778 err = errors.New("load average mismatch")
779 log.WithError(err).Debugf("miner's LoadAvgPerCPU: %f, user's LoadAvgPerCPU: %f",
780 po.LoadAvgPerCPU, req.ResourceMeta.LoadAvgPerCPU)
781 return
782 }
783 if po.Memory < req.ResourceMeta.Memory {
784 err = errors.New("memory mismatch")
785 log.WithError(err).Debugf("miner's memory: %d, user's memory: %d",
786 po.Memory, req.ResourceMeta.Memory)
787 return
788 }
789 if po.Space < req.ResourceMeta.Space {
790 err = errors.New("disk space mismatch")
791 log.WithError(err).Debugf("miner's disk space: %d, user's disk space: %d",
792 po.Space, req.ResourceMeta.Space)
793 return
794 }
795 if po.TokenType != req.TokenType {
796 err = errors.New("token type mismatch")
797 log.WithError(err).Debugf("miner's token type: %s, user's token type: %s",
798 po.TokenType, req.TokenType)
799 return
800 }
801
802 return true, nil
803}
804
805func (s *metaState) updatePermission(tx *types.UpdatePermission) (err error) {
806 log.WithFields(log.Fields{

Callers 1

filterAndAppendMinerFunction · 0.85

Calls 3

WithErrorFunction · 0.92
DebugfMethod · 0.80
NewMethod · 0.65

Tested by

no test coverage detected