public async Task UpdateBalance(UInt160 hash, UInt256 assetId, Fixed8 delta) { var account = await Get(hash) ?? new Account(hash); if (account.Balances.ContainsKey(assetId)) { account.Balances[assetId] += delta; } else { account.Balances[assetId] = delta; } await _repository.AddAccount(account); if (assetId.Equals(_genesisAssets.BuildGoverningTokenRegisterTransaction().Hash) && account.Votes?.Length > 0) { foreach (var pubKey in account.Votes) { await UpdateValidatorVote(pubKey, delta); } } // TODO #382: Check if we need to store validatorCount because existing implementation has it // validators_count.GetAndChange().Votes[account.Votes.Length - 1] += output.Value; }
public Block Build() { if (_genesisBlock != null) { return(_genesisBlock); } var governingToken = _genesisAssetsBuilder.BuildGoverningTokenRegisterTransaction(); var utilityToken = _genesisAssetsBuilder.BuildUtilityTokenRegisterTransaction(); var genesisMinerTransaction = _genesisAssetsBuilder.BuildGenesisMinerTransaction(); var genesisIssueTransaction = _genesisAssetsBuilder.BuildGenesisIssueTransaction(); var genesisWitness = _genesisAssetsBuilder.BuildGenesisWitness(); var genesisTimestamp = new DateTime(2016, 7, 15, 15, 8, 21, DateTimeKind.Utc).ToTimestamp(); ulong genesisConsensusData = 2083236893; var nextConsensusAddress = _genesisAssetsBuilder.BuildGenesisNextConsensusAddress(); _genesisBlock = new Block { PreviousBlockHash = UInt256.Zero, Timestamp = genesisTimestamp, Index = 0, ConsensusData = genesisConsensusData, NextConsensus = nextConsensusAddress, Witness = genesisWitness, Transactions = new Transaction[] { //First transaction is always a miner transaction genesisMinerTransaction, //Creates NEO governingToken, //Creates GAS utilityToken, //Send all NEO to seed contract genesisIssueTransaction } }; _blockSigner.Sign(_genesisBlock); return(_genesisBlock); }