Skip to content
This repository was archived by the owner on Aug 2, 2021. It is now read-only.

Swarm swap accounting phase 1 #962

Closed
wants to merge 30 commits into from
Closed

Swarm swap accounting phase 1 #962

wants to merge 30 commits into from

Conversation

holisticode
Copy link
Contributor

This PR introduces the first phase of swap accounting for swarm message exchange.

This current implementation only does the accounting part, no cryptoeconomic features are implemented yet (price negotiation, claim settling, etc.). This means this implementation just keeps track of how many units are exchanged between nodes and maintains a balance with them.

The currently only accounted protocol is swarm's streaming protocol (swarm/network/stream). The prices defined in that protocol are totally arbitrary and will require monitoring, simulations and analysis before they can be seriously taken into account.

Basic design:

p2p/protocols/accounting.go defines the basic interfaces:

Balance defines the actual accounting interface. It only has an Add function. This function will be called with a peer instance and an amount. If the amount is negative, then the local node is being debited, if it is positive, the local node is being credited.

Prices is an interface that defines how prices are being expected. Every accounted protocol should provide an implementation, and return a Price structure for every message for which it requires accounting. This struct contains a Value int64 field; negative means receiver pays, positive means the sender pays for the message.

An accounted protocol needs to provide a Hook inside its Spec, where it defines its messages. The Hook contains a Balance and a Prices interfaces, which allows the messaging infrastructure to transparently do the accounting.

@holisticode
Copy link
Contributor Author

Closed as it's being split into 4 different PRs:

@frncmx frncmx deleted the sw3-p2p branch January 22, 2019 09:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant