-
Notifications
You must be signed in to change notification settings - Fork 0
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
Logs rewrite #98
base: master
Are you sure you want to change the base?
Logs rewrite #98
Conversation
…ink about architecture before finalizing
…hat dont have the same id
@@ -1,6 +1,6 @@ | |||
let obj = require('./build/contracts/ProjectLibrary.json') | |||
|
|||
const ProjectLibraryAddress = obj.networks['5777'].address | |||
const ProjectLibraryAddress = Object.keys(obj.networks).sort()[Object.keys(obj.networks).length - 1].address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about making network id an environment var?
VoteRecord: { | ||
voter: (vote) => User.findOne({account: vote.voter}).then(user => user), | ||
task: (vote) => Task.findById(vote.task).then(voteRecord => voteRecord) | ||
votes: (user) => Vote.find({voter: user.id}).then(votes => votes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fun fact, you don't need the code after then then
unless it's tranforming the result in some way. You can just write Vote.find({voter: user.id})
}}, {upsert: true}) | ||
if (!vote) console.error('vote not added successfully') | ||
} catch (err) { | ||
console.error('Error Adding Vote') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder if you want to rethrow here, so it bubbles up to what gets returned by graphql? What does this mutation return?
await new Token({ userId: user.id, amount: amountMinted, ether: totalCost }).save() | ||
const network = await Network.findOneAndUpdate({}, | ||
{ | ||
lastBlock: event.blockNumber, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we guaranteed to have finished processing the block here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't remember how events filtering works too well
module.exports = function () { | ||
const HyphaTokenContract = new web3.eth.Contract(HyphaTokenABI, HyphaTokenAddress) | ||
|
||
HyphaTokenContract.events.LogMint({fromBlock: netStatus.lastBlock}).on('data', async event => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Building some redundancy in here would be nice, like fromBlock: netStatus.lastBlock-100
- at some point you may need to be sure your node isn't on a fork too, and lag a few blocks behind
logIndex: String | ||
}) | ||
|
||
processedTxsSchema.index({transactionHash: 1, logIndex: 1}, {unique: true}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to go through the app code, see what other params you query by, and add indexes for them
Beginning to rewrite the logs to use consistent patterns and have greater resiliency