-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
changes to the chain to match mauve's logic (mvp) #22
Milestone
Comments
const chainAPI = { registerHoster, registerEncoder, publishData }
function registerHoster (payload) {
const hosterID = saveHoster(payload)
const hostingEvents = calculateAsHoster(hosterID, payload)
emitHostingEvents(hostingEvents)
}
function publishData (payload) {
const feedID = saveHoster(payload)
const hostingEvents = calculateAsPublisher(feedID, payload)
emitHostingEvents(hostingEvents)
}
function registerEncoder (payload) {
const encoderID = saveEncoder(payload)
const hostingEvents = calculateAsEncoder(encoderID, payload)
emitHostingEvents(hostingEvents)
}
/************************************************************************/
// INTERNAL
const underemployed_hosters = []
const unemployed_encoders = []
const waiting_feeds = []
function emitHostingEvents (hostingEvents) {
if (!hostingEvents.length) return
for (const [feedID, encoderID, hosterID] in hostingEvents) {
emit(['NewPin', feedID, encoderID, hosterID])
}
}
function calculateAsEncoder(encoderID, payload) {
const events = []
const len = Math.min(waiting_feeds.length, underemployed_hosters.length)
for (var i = 0; i < len; i++) {
events.push([waiting_feeds[i], encoderID, underemployed_hosters[i]])
}
return events
}
function calculateAsHoster(hosterID, payload) {
const events = []
const len = Math.min(waiting_feeds.length, unemployed_encoders.length)
for (var i = 0; i < len; i++) {
events.push([waiting_feeds[i], , unemployed_encoders[i], hosterID])
}
return events
}
function calculateAsPublisher(feedID, payload) {
const events = []
const len = Math.min(unemployed_encoders.length, underemployed_hosters.length)
for (var i = 0; i < len; i++) {
events.push([feedID, unemployed_encoders[i], underemployed_hosters[i]])
}
return events
} |
my goal is to simplify the storage of challenges held by hosters from multiple storage values, to:
(or, use DoubleMap, so we can iterate over exclusively hosters to find all archives they host)
where
the goal of which would be that we can drastically reduce the storage lookups when challenging a hoster |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem:
Solution?
The text was updated successfully, but these errors were encountered: