Narrowing the redownloads of reactions down.
This commit is contained in:
@@ -61,7 +61,7 @@ abstract class NostrDataSource(val debugName: String) {
|
|||||||
if (type == Relay.StateType.EOSE && subscriptionId != null && subscriptionId in subscriptions.keys) {
|
if (type == Relay.StateType.EOSE && subscriptionId != null && subscriptionId in subscriptions.keys) {
|
||||||
// updates a per subscripton since date
|
// updates a per subscripton since date
|
||||||
subscriptions[subscriptionId]?.updateEOSE(
|
subscriptions[subscriptionId]?.updateEOSE(
|
||||||
TimeUtils.fiveMinutesAgo(), // in case people's clock is slighly off.
|
TimeUtils.oneMinuteAgo(), // in case people's clock is slighly off.
|
||||||
relay.url
|
relay.url
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,6 +156,15 @@ object NostrSingleEventDataSource : NostrDataSource("SingleEventFeed") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addressesToWatch.forEach {
|
||||||
|
val eose = it.lastReactionsDownloadTime[relayUrl]
|
||||||
|
if (eose == null) {
|
||||||
|
it.lastReactionsDownloadTime = it.lastReactionsDownloadTime + Pair(relayUrl, EOSETime(time))
|
||||||
|
} else {
|
||||||
|
eose.time = time
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Many relays operate with limits in the amount of filters.
|
// Many relays operate with limits in the amount of filters.
|
||||||
// As information comes, the filters will be rotated to get more data.
|
// As information comes, the filters will be rotated to get more data.
|
||||||
invalidateFilters()
|
invalidateFilters()
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ object OnlineChecker {
|
|||||||
return checkOnlineCache.get(url).online
|
return checkOnlineCache.get(url).online
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.d("OnlineChecker", "isOnline $url")
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
val request = Request.Builder()
|
val request = Request.Builder()
|
||||||
.header("User-Agent", "Amethyst/${BuildConfig.VERSION_NAME}")
|
.header("User-Agent", "Amethyst/${BuildConfig.VERSION_NAME}")
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ class Relay(
|
|||||||
"EVENT" -> {
|
"EVENT" -> {
|
||||||
val event = Event.fromJson(msgArray.get(2))
|
val event = Event.fromJson(msgArray.get(2))
|
||||||
|
|
||||||
// Log.w("Relay", "Relay onEVENT $url, $channel")
|
Log.w("Relay", "Relay onEVENT $url, $channel ${msgArray.get(2)}")
|
||||||
listeners.forEach {
|
listeners.forEach {
|
||||||
it.onEvent(this@Relay, channel, event)
|
it.onEvent(this@Relay, channel, event)
|
||||||
if (afterEOSE) {
|
if (afterEOSE) {
|
||||||
@@ -276,7 +276,7 @@ class Relay(
|
|||||||
if (filters.isNotEmpty()) {
|
if (filters.isNotEmpty()) {
|
||||||
val request =
|
val request =
|
||||||
"""["REQ","$requestId",${filters.take(10).joinToString(",") { it.filter.toJson(url) }}]"""
|
"""["REQ","$requestId",${filters.take(10).joinToString(",") { it.filter.toJson(url) }}]"""
|
||||||
// println("FILTERSSENT $url $request")
|
Log.d("Relay", "onFilterSent $url $requestId $request")
|
||||||
socket?.send(request)
|
socket?.send(request)
|
||||||
eventUploadCounterInBytes += request.bytesUsedInMemory()
|
eventUploadCounterInBytes += request.bytesUsedInMemory()
|
||||||
afterEOSE = false
|
afterEOSE = false
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ object TimeUtils {
|
|||||||
const val oneWeek = 7 * oneDay
|
const val oneWeek = 7 * oneDay
|
||||||
|
|
||||||
fun now() = System.currentTimeMillis() / 1000
|
fun now() = System.currentTimeMillis() / 1000
|
||||||
|
fun oneMinuteAgo() = now() - oneMinute
|
||||||
fun fiveMinutesAgo() = now() - fiveMinutes
|
fun fiveMinutesAgo() = now() - fiveMinutes
|
||||||
fun oneHourAgo() = now() - oneHour
|
fun oneHourAgo() = now() - oneHour
|
||||||
fun oneHourAhead() = now() + oneHour
|
fun oneHourAhead() = now() + oneHour
|
||||||
|
|||||||
Reference in New Issue
Block a user