Skip to content
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

loadHistory(fromBlock=0) #2

Open
coinop-logan opened this issue Feb 15, 2018 · 1 comment
Open

loadHistory(fromBlock=0) #2

coinop-logan opened this issue Feb 15, 2018 · 1 comment

Comments

@coinop-logan
Copy link
Member

No description provided.

@coinop-logan
Copy link
Member Author

This function will read the logs of the BurnChatManager contract, starting from some blocknumber (default to 0), effectively "replaying" the history of the contract to generate a list of messages, each with some metadata.

See the 5 events in BurnChatManage.sol.

NewMessage indicates a user has posted a message, and the message has been added to the contract's activeMessages.

MessageSmoked and MessageFinalized signal the end of the message's "active" life.
Thereafter, the message's messageID will point to a null object in the contract's activeMessages.
MessageSmoked indicates the message's entire balance has been burned.
MessageFinalized indicates that the user called finalizeMessage after finalizeInterval time,
and the balance left on the message has returned to that user.

MessageBurned and MessageTipped can only happen for active messages, and affect the balance of the message.
MessageBurned indicates another user has burned their own ether to burn some of the message's balance; the ratio of initiatingBurn to resultingBurn is determined by the burnRatio of the message. If this causes the balance to reach 0, the message is "smoked" (with event MessageSmoked).
MessageTipped is simply a transfer of ether from a user to the message. (This means a message may return more to the poster than they originally deposited, if the message can last long enough for the poster to call finalizeMessage.

The API must do a lot of the heavy lifting to read this history and build a list of messages and their associated metadata.

For every NewMessage, start a message object.
Ignore any other event referring to a messageID not being tracked (there will be some if fromBlock is set after any messages have been posted).

For each event referring to a messageID we do have, track the following metadata for each message:

  • from (address)
  • balance (wei amount)
  • burnFactor (float, derived by NewMessage's burnFactor/1000; see line 7 of the contract)
  • finalizeTime (timestamp)
  • postTime (timestamp) (this could be tricky. Events don't contain a reference to block time directly.)
  • initialDeposit (wei amount)
  • initialBurn (wei amount)
  • totalBurnedByOthers (wei amount, increased with each MessageBurned event) (better name? Technically the poster can burn their own message. Should be differentiated from initialBurn, somehow)
  • totalTipped (wei amount, increased with each MessageTipped event)
  • state (active, smoked, or finalized)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant