Conversation
…ink about architecture before finalizing
…hat dont have the same id
| 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.
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.
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.
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.
Are we guaranteed to have finished processing the block here?
There was a problem hiding this comment.
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.
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.
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