ethersphere / bee

Bee is a Swarm client implemented in Go. It’s the basic building block for the Swarm network: a private; decentralized; and self-sustaining network for permissionless publishing and access to your (application) data.
https://www.ethswarm.org
BSD 3-Clause "New" or "Revised" License
1.46k stars 338 forks source link

request: bee dev - realistic TTL values #2816

Closed vojtechsimetka closed 2 years ago

vojtechsimetka commented 2 years ago

Summary

In bee dev mode, I would like to see realistic TTL values for postage stamps. Right now it always returns -1. Instead TTL could just be a difference between time bought and request time + amount to /stamps endpoint. The time bought could be stored in blockNumber.

Motivation

In the current form bee dev makes code that works with stamps a bit challenging. E.g. in gateway-proxy we want to purchase new postage stamps when stamps become full or expire. I can imagine other applications (like bee-dashboard or apps uploading to your own node) wanting this functionality (to test code that checks if stamp is usable before uploading).

Implementation

blockNum should return timestamp when the stamp was bought (in seconds) and batchTTL should return either positive difference between blockNum - currentTimestamp + amount or -1 (also in seconds) .

Drawbacks

Adds complexity to dev mode code.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days.

tmm360 commented 2 years ago

.

agazso commented 2 years ago

Would it make sense to assume block time to be one second and calculate the TTL based on that? @acud

acud commented 2 years ago

would it be ok if we just adjust the API to return some answer which is >0? there's some hardcoded values there that probably make the ttl calculation break. it would make our life easier to just somehow make sure that some reasonable output is guaranteed, rather than having configurable values

vojtechsimetka commented 2 years ago

would work for me