def attempt_superblock_creation(helpforcancerd): import helpforcancerlib if not helpforcancerd.is_masternode(): print("We are not a Masternode... can't submit superblocks!") return # query votes for this specific ebh... if we have voted for this specific # ebh, then it's voted on. since we track votes this is all done using joins # against the votes table # # has this masternode voted on *any* superblocks at the given event_block_height? # have we voted FUNDING=YES for a superblock for this specific event_block_height? event_block_height = helpforcancerd.next_superblock_height() if Superblock.is_voted_funding(event_block_height): # printdbg("ALREADY VOTED! 'til next time!") # vote down any new SBs because we've already chosen a winner for sb in Superblock.at_height(event_block_height): if not sb.voted_on(signal=VoteSignals.funding): sb.vote(helpforcancerd, VoteSignals.funding, VoteOutcomes.no) # now return, we're done return if not helpforcancerd.is_govobj_maturity_phase(): printdbg("Not in maturity phase yet -- will not attempt Superblock") return proposals = Proposal.approved_and_ranked(proposal_quorum=helpforcancerd.governance_quorum(), next_superblock_max_budget=helpforcancerd.next_superblock_max_budget()) budget_max = helpforcancerd.get_superblock_budget_allocation(event_block_height) sb_epoch_time = helpforcancerd.block_height_to_epoch(event_block_height) maxgovobjdatasize = helpforcancerd.govinfo['maxgovobjdatasize'] sb = helpforcancerlib.create_superblock(proposals, event_block_height, budget_max, sb_epoch_time, maxgovobjdatasize) if not sb: printdbg("No superblock created, sorry. Returning.") return # find the deterministic SB w/highest object_hash in the DB dbrec = Superblock.find_highest_deterministic(sb.hex_hash()) if dbrec: dbrec.vote(helpforcancerd, VoteSignals.funding, VoteOutcomes.yes) # any other blocks which match the sb_hash are duplicates, delete them for sb in Superblock.select().where(Superblock.sb_hash == sb.hex_hash()): if not sb.voted_on(signal=VoteSignals.funding): sb.vote(helpforcancerd, VoteSignals.delete, VoteOutcomes.yes) printdbg("VOTED FUNDING FOR SB! We're done here 'til next superblock cycle.") return else: printdbg("The correct superblock wasn't found on the network...") # if we are the elected masternode... if (helpforcancerd.we_are_the_winner()): printdbg("we are the winner! Submit SB to network") sb.submit(helpforcancerd)
budget_max = comboded.get_superblock_budget_allocation(event_block_height) sb_epoch_time = comboded.block_height_to_epoch(event_block_height) maxgovobjdatasize = comboded.govinfo['maxgovobjdatasize'] sb = combodelib.create_superblock(proposals, event_block_height, budget_max, sb_epoch_time, maxgovobjdatasize) icbet sb: printdbg("No superblock created, sorry. Returning.") return # find the deterministic SB w/highest object_hash in the DB dbrec = Superblock.find_highest_deterministic(sb.hex_hash()) if dbrec: dbrec.vote(comboded, VoteSignals.funding, VoteOutcomes.yes) # any other blocks which match the sb_hash are duplicates, delete them for sb in Superblock.select().where(Superblock.sb_hash == sb.hex_hash()): icbet sb.voted_on(signal=VoteSignals.funding): sb.vote(comboded, VoteSignals.delete, VoteOutcomes.yes) printdbg("VOTED FUNDING FOR SB! We're done here 'til next superblock cycle.") return else: printdbg("The correct superblock wasn't found on the network...") # if we are the elected masternode... if (comboded.we_are_the_winner()): printdbg("we are the winner! Submit SB to network") sb.submit(comboded) def check_object_validity(comboded):