/// <summary> /// Pushes the changes into database. /// </summary> public string PushState(string prevStateRoot, string stateRoot, SingleState[] changedWallets) { DataHeader header = null; if (prevStateRoot == null) { header = DataHeader.EmptyState(); } else { header = ReadHeader(prevStateRoot); } var changes = new Dictionary <string, List <SingleState> >(); foreach (var wallet in changedWallets) { var index = GetIndexFromHash(wallet.key); if (changes.ContainsKey(index) == false) { changes[index] = new List <SingleState>(); } changes[index].Add(wallet); } foreach (var change in changes) { header.path[change.Key] = WriteStateBlob(change.Key, change.Value.ToArray()); } return(WriteHeader(stateRoot, header)); }
private DataHeader ReadHeader(string stateRoot) { var header = fdb.Read <DataHeader>($"root/{stateRoot}"); if (header == null) { return(DataHeader.EmptyState()); } return(header); }