Can anyone point me out, what should I do if I want some other libp2p protocol to use a BitSwap ledger of two nodes (the score and the “debt”) as the basis for decision of communication? And also to use that the other way around, i.e.: to make my additional protocol routines able to alter the BitSwap ledger score and “debt” (on both nodes) upon the results of communication?
I guess, I have the following three options:
to extend the current BitSwap decision strategy engine with appropriate methods to access and alter the Ledger;
to go a level higher and try to use a custom decision strategy engine (probably, the one based on the current implementation);
to go even higher and implement a custom block exchange protocol that will be backward compatible with BitSwap.
In all cases I speak about the go-bitswap implementation.
I’d go with the first or second option. Ideally, you’d eventually find a clean way to expose these methods and submit a patch but I’d start by forking and experimenting a bit.
I was beginning to figure out an interface for the second option — the ability to use a custom engine with the current BitSwap protocol, but then saw it’s probably a wrong idea. As far as I understand the very idea of peer-to-peer ledgers, the peers must keep their ledgers mutually synchronized which assumes the use of the same decision logic, isn’t it? (Currently, I can’t see any ledger match functions at runtime, however that is a part of the testing suite.) If so, then there is actually only the third option really available: to map each decision logic to a separate protocol (that could be backward compatible to BitSwap though).
Hi. Only the comment I’d made to the PR: https://github.com/ipfs/go-bitswap/pull/430 . There aren’t much changes and no new decision engine at all: only the possibility to plug-in some custom one.