Change OnIpldGet
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
399c171f03
commit
610ed0dc13
@ -65,7 +65,7 @@ type Pricelist interface {
|
|||||||
OnMethodInvocation(value abi.TokenAmount, methodNum abi.MethodNum) GasCharge
|
OnMethodInvocation(value abi.TokenAmount, methodNum abi.MethodNum) GasCharge
|
||||||
|
|
||||||
// OnIpldGet returns the gas used for storing an object
|
// OnIpldGet returns the gas used for storing an object
|
||||||
OnIpldGet(dataSize int) GasCharge
|
OnIpldGet() GasCharge
|
||||||
// OnIpldPut returns the gas used for storing an object
|
// OnIpldPut returns the gas used for storing an object
|
||||||
OnIpldPut(dataSize int) GasCharge
|
OnIpldPut(dataSize int) GasCharge
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ func (pl *pricelistV0) OnMethodInvocation(value abi.TokenAmount, methodNum abi.M
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OnIpldGet returns the gas used for storing an object
|
// OnIpldGet returns the gas used for storing an object
|
||||||
func (pl *pricelistV0) OnIpldGet(dataSize int) GasCharge {
|
func (pl *pricelistV0) OnIpldGet() GasCharge {
|
||||||
return newGasCharge("OnIpldGet", pl.ipldGetBase, 0)
|
return newGasCharge("OnIpldGet", pl.ipldGetBase, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,12 +71,12 @@ type gasChargingBlocks struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (bs *gasChargingBlocks) Get(c cid.Cid) (block.Block, error) {
|
func (bs *gasChargingBlocks) Get(c cid.Cid) (block.Block, error) {
|
||||||
bs.chargeGas(newGasCharge("OnIpldGetStart", 0, 0))
|
bs.chargeGas(bs.pricelist.OnIpldGet())
|
||||||
blk, err := bs.under.Get(c)
|
blk, err := bs.under.Get(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, aerrors.Escalate(err, "failed to get block from blockstore")
|
return nil, aerrors.Escalate(err, "failed to get block from blockstore")
|
||||||
}
|
}
|
||||||
bs.chargeGas(bs.pricelist.OnIpldGet(len(blk.RawData())))
|
bs.chargeGas(newGasCharge("OnIpldGetEnd", 0, 0).WithExtra(len(blk.RawData())))
|
||||||
bs.chargeGas(gasOnActorExec)
|
bs.chargeGas(gasOnActorExec)
|
||||||
|
|
||||||
return blk, nil
|
return blk, nil
|
||||||
|
@ -405,16 +405,19 @@ func getExtras(ex interface{}) (*string, *float64) {
|
|||||||
func tallyGasCharges(charges map[string]*stats, et types.ExecutionTrace) {
|
func tallyGasCharges(charges map[string]*stats, et types.ExecutionTrace) {
|
||||||
for i, gc := range et.GasCharges {
|
for i, gc := range et.GasCharges {
|
||||||
name := gc.Name
|
name := gc.Name
|
||||||
if name == "OnIpldGetStart" {
|
if name == "OnIpldGetEnd" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
tt := float64(gc.TimeTaken.Nanoseconds())
|
tt := float64(gc.TimeTaken.Nanoseconds())
|
||||||
if name == "OnIpldGet" {
|
if name == "OnIpldGet" {
|
||||||
prev := et.GasCharges[i-1]
|
next := &types.GasTrace{}
|
||||||
if prev.Name != "OnIpldGetStart" {
|
if i+1 < len(et.GasCharges) {
|
||||||
log.Warn("OnIpldGet without OnIpldGetStart")
|
next = et.GasCharges[i+1]
|
||||||
}
|
}
|
||||||
tt += float64(prev.TimeTaken.Nanoseconds())
|
if next.Name != "OnIpldGetEnd" {
|
||||||
|
log.Warn("OnIpldGet without OnIpldGetEnd")
|
||||||
|
}
|
||||||
|
tt += float64(next.TimeTaken.Nanoseconds())
|
||||||
}
|
}
|
||||||
eType, eSize := getExtras(gc.Extra)
|
eType, eSize := getExtras(gc.Extra)
|
||||||
if eType != nil {
|
if eType != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user