func (blockchain *blockchain) addPersistenceChangesForNewBlock(ctx context.Context, block *protos.Block, stateHash []byte, writeBatch *gorocksdb.WriteBatch) (uint64, error) { block = blockchain.buildBlock(block, stateHash) if block.NonHashData == nil { block.NonHashData = &protos.NonHashData{LocalLedgerCommitTimestamp: util.CreateUtcTimestamp()} } else { block.NonHashData.LocalLedgerCommitTimestamp = util.CreateUtcTimestamp() } blockNumber := blockchain.size blockHash, err := block.GetHash() if err != nil { return 0, err } blockBytes, blockBytesErr := block.Bytes() if blockBytesErr != nil { return 0, blockBytesErr } writeBatch.PutCF(db.GetDBHandle().BlockchainCF, encodeBlockNumberDBKey(blockNumber), blockBytes) writeBatch.PutCF(db.GetDBHandle().BlockchainCF, blockCountKey, encodeUint64(blockNumber+1)) if blockchain.indexer.isSynchronous() { blockchain.indexer.createIndexesSync(block, blockNumber, blockHash, writeBatch) } blockchain.lastProcessedBlock = &lastProcessedBlock{block, blockNumber, blockHash} return blockNumber, nil }