pull down to refresh

The relay interface at https://github.com/fiatjaf/snow/blob/master/src/main/scala/Relay.scala is not very functional. It works, but I don't know how to close a relay connection and I am not sure about how to properly structure the responses in terms of Cats-Effect and fs2.
The goal of this bounty is for you to refactor that and deliver a nice API with nice tests that show how it works.
100,000 sats bounty
fiatjaf8's bounties
To properly close a relay connection, you can use the close method provided by the java.nio.channels.SocketChannel class.
To structure the responses using Cats-Effect and fs2, you can use fs2.Stream to represent a stream of responses. Each response can be wrapped in a cats.effect.IO computation to ensure that the response is evaluated in a purely functional context.
When writing tests for the refactored code, it's important to verify the behavior of the API in different scenarios, including success, error, and timeout cases. You can use the cats.effect.IO and fs2.Stream combinators to test the behavior of the API in a purely functional context.
reply
Bounties work great for the bounty issuer.
They don't always work so great for the bounty hunter. There could be two (or more) people working on solving this. Assuming one person provides a solution before any other valid solutions arrive, the bounty will be paid to the first hunter, and nothing is paid to the other(s) who may already have put in efforts towards this in hopes of obtaining the bounty award. The second solution provided might have been of better design and/or quality (thus why it took longer to complete), but a bounty is generally where the first to solve is the winner and the winner takes all.
On the flip side, hiring a freelancer (e.g., on Microlancer or Microlancer Services) might result in the deliverable taking longer, or it could run into the risk of non-completion (due to incompetence of the freelancer, or other issues).
But there's today few gigs / task work relative to the number of those with talent who are willing and able, so the bounty approach is likely the approach I too might choose in order to farm out the work for something like what OP is in need of.
reply
Hm... an inherent problem with bounties in general. If the other people have their solutions posted in the replies, at least on stacker news it's easy for anyone to reward their favourite responses.
Clean bounties with no modifications have their perks though, their simplicity is valuable and has stood the test of time. Any modified version I think ought to be an optional setting.
One optional setting could be; "Top three bounty with some kind of distribution equal or 50/30/20 for instance" Then the top three bounty system could require the OP to select & rank three replies in order to do the bounty payout. Maybe a setup like that could even encourage more people to help?
Always interesting to explore new ideas and functions :) Game Theory problems are fun.
reply
At the end of the day the simple approach is probably the best
reply
I agree with this.
reply
Replit tried to solve this with their bounties by opening them up to an application process first. One bounty, one hunter at a time. That seems effective to me.
reply
The downside of that is you don't get the benefit of parallel attempts. Another option could be the splitting of the reward to the best few, the lions share going to the best quality option. And all of these attempts would also prove the capabilities of the competitor, which could help in selecting a full time position for them, especially if the attempts being published of the multiple winners is part of the protocol.
Designing game theory systems that minimise downsides for all participants are the best puzzles. I live for it.
reply
With our model he can pay the bounty to multiple people if he chooses. Or a partial bounty to runner ups.
It doesn't eliminate all problems though. As you say, tradeoffs with all approaches, which is why we don't specify it ourselves.
Replit chooses a lock-in approach AFAIK, ie a chosen one is selected to work on it. A bounty hunter could say that in their bounty if they wanted.
reply