public static BondAttachment GetBondAttachment(ChainType chainType) { BondAttachment bt = BondAttachment.None; switch (chainType) { case ChainType.AlignedLeft: bt = BondAttachment.ObjectHandleL; break; case ChainType.AlignedCenterVertical: bt = BondAttachment.ObjectCenter; break; case ChainType.AlignedRight: bt = BondAttachment.ObjectHandleR; break; case ChainType.AlignedTop: bt = BondAttachment.ObjectHandleT; break; case ChainType.AlignedCenterHorizontal: bt = BondAttachment.ObjectCenter; break; case ChainType.AlignedBottom: bt = BondAttachment.ObjectHandleB; break; case ChainType.DistributedHorizontal: bt = BondAttachment.ObjectHandleL; break; case ChainType.DistributedVertical: bt = BondAttachment.ObjectHandleT; break; } return bt; }
public bool GetChainType(string chainTypeName, out ChainType chainType) { if (chainTypeName == _dataChainName) { chainType = ChainType.Data; return(true); } if (chainTypeName == _coreChainName) { chainType = ChainType.Core; return(true); } if (chainTypeName == _serviceChainName) { chainType = ChainType.Service; return(true); } if (chainTypeName == _maintainChainName) { chainType = ChainType.Maintain; return(true); } throw new Exception($"ChainType {chainTypeName} not found."); }
public BTCPayNetworkProvider(ChainType chainType) { _NBXplorerNetworkProvider = new NBXplorerNetworkProvider(chainType); ChainType = chainType; InitBitcoin(); InitLitecoin(); }
protected TransactionDownloadHandler(long accountId, ChainType chainType, int chainId, uint chainIndex) { AccountId = accountId; ChainType = chainType; ChainId = chainId; ChainIndex = chainIndex; }
private static IValidatorRule Parse(ChainType rule, Dictionary <string, object> objectStorage) { return(new ChainRule( GetBucket(rule.RootBucketReference, objectStorage), GetBucket(rule.IntermediateBucketReference, objectStorage), rule.Policy.ToArray())); }
public ChainObject Spawn(ChainType type, Vector3 position) { var prefab = typeMap[type]; var quaternion = Quaternion.identity; return(Instantiate(prefab, position, quaternion)); }
private ICollection<IPointToLaceProvider> Execute(ICollection<IPointToLaceRequest> request, ChainType chain) { try { Init(request.First().Request.RequestId); _logCommand.LogBegin(request); _dataProviderChain = new CreateSourceChain(); _logCommand.LogEntryPointRequest(request, DataProviderNoRecordState.Billable); _bootstrap = new Initialize(new Collection<IPointToLaceProvider>(), request, _bus, _dataProviderChain); _bootstrap.Execute(chain); LogResponse(request); CreateTransaction(request, _bootstrap.DataProviderResponses.State()); _logCommand.LogEnd(_bootstrap.DataProviderResponses ?? EmptyResponse); return _bootstrap.DataProviderResponses ?? EmptyResponse; } catch (Exception ex) { _logCommand.LogFault(ex.Message, request); _logCommand.LogEnd(request); Log.ErrorFormat("Error occurred receiving request {0}", ex, request.ObjectToJson()); LogResponse(request); CreateTransaction(request, DataProviderResponseState.TechnicalError); return EmptyResponse; } }
public Chain(int aNumPlayer) { mNumPlayer = aNumPlayer; mChainGUID = mNbChain; mType = (ChainType)(mChainGUID % 3); mNbChain++; }
public NodeBlockDataMessage(ChainType chainType, long blockId, int chainId, uint chainIndex) : this() { ChainType = chainType; BlockId = blockId; ChainId = chainId; ChainIndex = chainIndex; }
public LastBlockInfo(Unpacker unpacker) { ChainType = (ChainType)unpacker.UnpackByte(); unpacker.Unpack(out ChainId); unpacker.Unpack(out ChainIndex); unpacker.Unpack(out LastBlockId); unpacker.Unpack(out LastTransactionId); }
public NetworkPeerStorage(string baseDirectory, ChainType chainType) : base(Path.Combine(baseDirectory, "KnownAddresses"), keyEncoder: key => NetworkEncoder.EncodeNetworkAddressKey(key), keyDecoder: key => NetworkEncoder.DecodeNetworkAddressKey(key), valueEncoder: value => NetworkEncoder.EncodeNetworkAddressWithTime(value), valueDecoder: value => NetworkEncoder.DecodeNetworkAddressWithTime(value)) { }
ChainSyncItem GetChainSyncItem(int chainId, uint chainIndex, ChainType chainType) { lock (_lock) { _chainSyncItems.TryGetValue(new Tuple <int, uint, ChainType>(chainId, chainIndex, chainType), out var chainItem); return(chainItem); } }
public LastBlockInfo(ChainType chainType, int chainId, uint chainIndex, long lastBlockId, long lastTransactionId) { ChainType = chainType; ChainId = chainId; ChainIndex = chainIndex; LastBlockId = lastBlockId; LastTransactionId = lastTransactionId; }
public BlockDiscStorage(Base.Storage storage, ChainType chainType, int chainId, uint chainIndex, long sliceIndex, bool readOnly) : base(storage, Path.Combine(BlockStorage.GetBlockStoragePath(chainType, chainId, chainIndex), sliceIndex.ToString()), 256, 32, DiscStorageFlags.AppendOnly | DiscStorageFlags.DynamicBlockSize | (readOnly ? DiscStorageFlags.Readonly : DiscStorageFlags.None)) { SliceIndex = sliceIndex; if (UserDataUnpacker.UnpackBool()) { UserDataUnpacker.UnpackUshort(); } }
public static void CreateRequiredDirectories(Base.Storage storage, ChainType chainType, int chainId, uint chainIndex) { var path = GetTransactionStoragePath(chainType, chainId, chainIndex); if (!storage.CreateDirectory(path)) { throw new Exception($"Could not create directory {path}."); } }
protected CouncilMessage(CouncilMessageTypes messageType, ChainType chainType, int chainId, uint chainIndex, short issuer, Key issuerKey) : base((ushort)messageType) { ChainType = chainType; ChainId = chainId; ChainIndex = chainIndex; Issuer = issuer; _signKey = issuerKey; }
public MetaDiscStorage(Base.Storage storage, ChainType chainType, int chainId, uint chainIndex, string name, int blockSize, DiscStorageFlags flags, int userDataSize = 20) : base(storage, Path.Combine(Chain.GetChainMetaDirectory(chainType, chainId, chainIndex), name), blockSize, userDataSize, flags) { if (UserDataUnpacker.UnpackBool()) { LastBlockId = UserDataUnpacker.UnpackLong(); LastTransactionId = UserDataUnpacker.UnpackLong(); MetaUnpack(); } }
public void Align(uint[] instanceIds, ChainType chainType, Vex.Point target, List <Bond> addedBonds, List <Bond> previousBonds) { BondAttachment bt = chainType.GetAttachment(); BondType bondType = chainType.IsAligned() ? BondType.Anchor : BondType.Spring; Bond b; Bond prev = null; for (int i = 0; i < instanceIds.Length - 1; i++) { uint id = instanceIds[i]; if (chainType.IsDistributed()) { if (i > 0) { RemoveCollidingBond(id, bt, previousBonds, BondType.Anchor); } if (i < instanceIds.Length - 1) { BondAttachment btOpp = chainType.GetOppositeAttachment(); RemoveCollidingBond(id, btOpp, previousBonds, BondType.Anchor); } } else { RemoveCollidingBond(id, bt, previousBonds, BondType.Anchor); } b = new Bond(id, bt, bondType); b.ChainType = chainType; b.TargetLocation = target; AddBond(b); addedBonds.Add(b); b.Previous = prev; if (prev != null) { prev.Next = b; } prev = b; } int lastIndex = instanceIds.Length - 1; uint lastId = instanceIds[lastIndex]; RemoveCollidingBond(lastId, bt, previousBonds, BondType.Anchor); b = new Bond(lastId, bt, bondType); b.ChainType = chainType; b.TargetLocation = target; AddBond(b); addedBonds.Add(b); b.Previous = prev; prev.Next = b; }
public EsentStorageModule(string baseDirectory, ChainType rulesType, long? cacheSizeMinBytes = null, long? cacheSizeMaxBytes = null, string[] blockTxesStorageLocations = null) { this.baseDirectory = baseDirectory; this.blockTxesStorageLocations = blockTxesStorageLocations; this.dataDirectory = Path.Combine(baseDirectory, "Data", rulesType.ToString()); this.peersDirectory = Path.Combine(baseDirectory, "Peers", rulesType.ToString()); this.chainType = rulesType; this.cacheSizeMinBytes = cacheSizeMinBytes; this.cacheSizeMaxBytes = cacheSizeMaxBytes; }
public NBXplorerNetworkProvider(ChainType chainType) { InitBitcoin(chainType); InitLitecoin(chainType); ChainType = chainType; foreach (var chain in _Networks.Values) { chain.DerivationStrategyFactory = new DerivationStrategy.DerivationStrategyFactory(chain.NBitcoinNetwork); } }
public EsentStorageModule(string baseDirectory, ChainType rulesType, long?cacheSizeMinBytes = null, long?cacheSizeMaxBytes = null, string[] blockTxesStorageLocations = null) { this.baseDirectory = baseDirectory; this.blockTxesStorageLocations = blockTxesStorageLocations; this.dataDirectory = Path.Combine(baseDirectory, "Data", rulesType.ToString()); this.peersDirectory = Path.Combine(baseDirectory, "Peers", rulesType.ToString()); this.chainType = rulesType; this.cacheSizeMinBytes = cacheSizeMinBytes; this.cacheSizeMaxBytes = cacheSizeMaxBytes; }
public Block(string color, int left, int top, int view, ChainType chainType, int fontSize, double scale) { Color = color; Left = left; Top = top; View = view; ChainType = chainType; FontSize = fontSize; Scale = scale; }
/// <summary> /// First method to add a chain to factom. Spends the entry credits, must wait 10seconds and call /// RevealChain() to finalize the commit. /// </summary> /// <param name="c">Chain to be added</param> /// <param name="name">Name of Entry Credit wallet</param> /// <returns>ChainID of chain added, do not lose this!</returns> public static byte[] CommitChain(ChainType c, string name) { var byteList = new List<byte>(); //1 byte version byteList.Add(0); // 6 byte milliTimestamp (truncated unix time) byteList.AddRange(Times.MilliTime()); var entry = c.FirstEntry; // 32 Byte ChainID Hash //byte[] chainIDHash = Encoding.ASCII.GetBytes(c.ChainId); var chainIDHash = c.ChainId; chainIDHash = SHA256.Create().ComputeHash(chainIDHash); chainIDHash = SHA256.Create().ComputeHash(chainIDHash); byteList.AddRange(chainIDHash); // 32 byte Weld; sha256(sha256(EntryHash + ChainID)) var cid = c.ChainId; var s = Entries.HashEntry(c.FirstEntry); var weld = new byte[cid.Length + s.Length]; s.CopyTo(weld, 0); cid.CopyTo(weld, s.Length); weld = SHA256.Create().ComputeHash(weld); weld = SHA256.Create().ComputeHash(weld); byteList.AddRange(weld); // 32 byte Entry Hash of the First Entry byteList.AddRange(Entries.HashEntry(c.FirstEntry)); // 1 byte number of Entry Credits to pay var cost = (sbyte) (Entry.EntryCost(entry) + 10); // TODO: check errors byteList.Add(BitConverter.GetBytes(cost)[0]); var com = new WalletCommit(); com.Message = Arrays.ByteArrayToHex(byteList.ToArray()); var json = JsonConvert.SerializeObject(com); var req = new RestRequest("/commit-chain/" + name, Method.POST); req.RequestFormat = DataFormat.Json; req.AddParameter("application/json", json, ParameterType.RequestBody); req.AddUrlSegment("name", name); var resp = StaticValues.clientD.Execute(req); Console.WriteLine("CommitChain Resp = " + resp.StatusCode); // TODO: Remove Console.WriteLine("Message= " + com.Message); // TODO: Remove if (resp.StatusCode != HttpStatusCode.OK) { throw new FactomChainException("Chain Commit Failed. Message: " + resp.ErrorMessage); } return Entries.ChainIdOfFirstEntry(c.FirstEntry); }
public void LoadArgs(IConfiguration conf) { ChainType = DefaultConfiguration.GetChainType(conf); var defaultSettings = BTCPayDefaultSettings.GetDefaultSettings(ChainType); DataDir = conf.GetOrDefault <string>("datadir", defaultSettings.DefaultDataDirectory); Logs.Configuration.LogInformation("Network: " + ChainType.ToString()); var supportedChains = conf.GetOrDefault <string>("chains", "btc") .Split(',', StringSplitOptions.RemoveEmptyEntries) .Select(t => t.ToUpperInvariant()); NetworkProvider = new BTCPayNetworkProvider(ChainType).Filter(supportedChains.ToArray()); foreach (var chain in supportedChains) { if (NetworkProvider.GetNetwork(chain) == null) { throw new ConfigException($"Invalid chains \"{chain}\""); } } var validChains = new List <string>(); foreach (var net in NetworkProvider.GetAll()) { NBXplorerConnectionSetting setting = new NBXplorerConnectionSetting(); setting.CryptoCode = net.CryptoCode; setting.ExplorerUri = conf.GetOrDefault <Uri>($"{net.CryptoCode}.explorer.url", net.NBXplorerNetwork.DefaultSettings.DefaultUrl); setting.CookieFile = conf.GetOrDefault <string>($"{net.CryptoCode}.explorer.cookiefile", net.NBXplorerNetwork.DefaultSettings.DefaultCookieFile); NBXplorerConnectionSettings.Add(setting); var lightning = conf.GetOrDefault <string>($"{net.CryptoCode}.lightning", string.Empty); if (lightning.Length != 0) { if (!LightningConnectionString.TryParse(lightning, out var connectionString, out var error)) { throw new ConfigException($"Invalid setting {net.CryptoCode}.lightning, you need to pass either " + $"the absolute path to the unix socket of a running CLightning instance (eg. /root/.lightning/lightning-rpc), " + $"or the url to a charge server with crendetials (eg. https://apitoken@API_TOKEN_SECRET:charge.example.com/)"); } InternalLightningByCryptoCode.Add(net.CryptoCode, connectionString); } } Logs.Configuration.LogInformation("Supported chains: " + String.Join(',', supportedChains.ToArray())); PostgresConnectionString = conf.GetOrDefault <string>("postgres", null); BundleJsCss = conf.GetOrDefault <bool>("bundlejscss", true); ExternalUrl = conf.GetOrDefault <Uri>("externalurl", null); var old = conf.GetOrDefault <Uri>("internallightningnode", null); if (old != null) { throw new ConfigException($"internallightningnode should not be used anymore, use btclightning instead"); } }
private void InitBitcoin(ChainType chainType) { Add(new NBXplorerNetwork() { CryptoCode = "BTC", MinRPCVersion = 150000, NBitcoinNetwork = chainType == ChainType.Main ? Network.Main : chainType == ChainType.Test ? Network.TestNet : chainType == ChainType.Regtest ? Network.RegTest : throw new NotSupportedException(chainType.ToString()), DefaultSettings = NBXplorerDefaultSettings.GetDefaultSettings(chainType) });
//public UsageIdentifier[] FindAllUsagesOfDefinition(uint definitionId) //{ // List<UsageIdentifier> result = new List<UsageIdentifier>(); // foreach (uint key in items.Keys) // { // if (items[key] is DesignTimeline) // { // DesignTimeline dt = (DesignTimeline)items[key]; // foreach (uint instId in dt.InstanceIds) // { // if (items[instId].DefinitionId == definitionId) // { // result.Add(new UsageIdentifier(dt.InstanceHash, instId)); // } // } // } // } // return result.ToArray(); //} public void SortIndexesByLocation(List<uint> ids, ChainType chainType) { if (chainType.IsHorizontal()) { ids.Sort((a, b) => this[a].StrokeBounds.Left.CompareTo(this[b].StrokeBounds.Left)); } else { ids.Sort((a, b) => this[a].StrokeBounds.Top.CompareTo(this[b].StrokeBounds.Top)); } }
public static BlockProvider CreateForRules(ChainType chainType) { switch (chainType) { case ChainType.MainNet: return new MainnetBlockProvider(); case ChainType.TestNet3: return new TestNet3BlockProvider(); default: return null; } }
private void InitLitecoin(ChainType chainType) { NBXplorer.Altcoins.Litecoin.Networks.EnsureRegistered(); Add(new NBXplorerNetwork() { CryptoCode = "LTC", MinRPCVersion = 140200, NBitcoinNetwork = chainType == ChainType.Main ? NBXplorer.Altcoins.Litecoin.Networks.Mainnet: chainType == ChainType.Test ? NBXplorer.Altcoins.Litecoin.Networks.Testnet : chainType == ChainType.Regtest ? NBXplorer.Altcoins.Litecoin.Networks.Regtest : throw new NotSupportedException(chainType.ToString()), DefaultSettings = NBXplorerDefaultSettings.GetDefaultSettings(chainType) });
public LocalClient(ChainType type, IKernel kernel, CoreDaemon coreDaemon, INetworkPeerStorage networkPeerStorage) { this.shutdownToken = new CancellationTokenSource(); this.type = type; this.kernel = kernel; this.coreDaemon = coreDaemon; this.chainParams = coreDaemon.ChainParams; this.coreStorage = coreDaemon.CoreStorage; this.networkPeerStorage = networkPeerStorage; this.messageRateMeasure = new RateMeasure(); this.headersRequestWorker = new HeadersRequestWorker( new WorkerConfig(initialNotify: true, minIdleTime: TimeSpan.FromMilliseconds(50), maxIdleTime: TimeSpan.FromSeconds(5)), this, this.coreDaemon); this.blockRequestWorker = new BlockRequestWorker( new WorkerConfig(initialNotify: true, minIdleTime: TimeSpan.FromMilliseconds(50), maxIdleTime: TimeSpan.FromSeconds(30)), this, this.coreDaemon); this.peerWorker = new PeerWorker( new WorkerConfig(initialNotify: true, minIdleTime: TimeSpan.FromSeconds(1), maxIdleTime: TimeSpan.FromSeconds(1)), this, this.coreDaemon, this.headersRequestWorker); this.listenWorker = new ListenWorker(this, this.peerWorker); this.statsWorker = new WorkerMethod("LocalClient.StatsWorker", StatsWorker, true, TimeSpan.FromSeconds(5), TimeSpan.FromMinutes(5)); this.peerWorker.PeerHandshakeCompleted += HandlePeerHandshakeCompleted; this.peerWorker.PeerDisconnected += HandlePeerDisconnected; this.blockRequestWorker.OnBlockFlushed += HandleBlockFlushed; switch (this.Type) { case ChainType.MainNet: Messaging.Port = 8333; Messaging.Magic = Messaging.MAGIC_MAIN; break; case ChainType.TestNet3: Messaging.Port = 18333; Messaging.Magic = Messaging.MAGIC_TESTNET3; break; case ChainType.Regtest: Messaging.Port = 18444; Messaging.Magic = Messaging.MAGIC_COMPARISON_TOOL; break; } }
public void SetConfig(int chainid, ChainType chainType, ServerDefine server) { _serverDefine = server; _chainId = chainid; _chainType = chainType; if (!string.IsNullOrEmpty(server.Ws)) { _binaryWriter = new BinaryWriter(_memoryStream); Task.Run(WsRun); } }
protected Block(ChainType chainType, ushort protocolVersion, long blockId, int chainId, uint chainIndex, short issuer, int revision, long timestamp, Hash previousBlockHash) { ChainType = chainType; ProtocolVersion = protocolVersion; BlockId = blockId; ChainId = chainId; ChainIndex = chainIndex; Issuer = issuer; Revision = revision; Timestamp = timestamp; PreviousBlockHash = previousBlockHash; }
public VoteMembers GetVoteMembers(ChainType chainType, int chainId, uint chainIndex, long timestamp) { var chainInfo = GetChainInfo(chainId); if (chainInfo != null) { var keyFlags = Block.GetRequiredChainVoteKeyFlags(chainType); var keys = chainInfo.GetValidChainKeysWithFlags(chainIndex, timestamp, keyFlags); return(new VoteMembers(keys, chainId, chainType)); } return(null); }
public void AddDocumentUnitChain(DocumentUnit documentUnit, Guid chainId, ChainType chainType, IIdentityContext identity, string archiveName, string documentName = null, string label = null) { documentUnit.DocumentUnitChains.Add(new DocumentUnitChain() { ArchiveName = archiveName, ChainType = chainType, DocumentName = chainType == ChainType.MainChain ? documentName : null, IdArchiveChain = chainId, RegistrationDate = DateTimeOffset.UtcNow, RegistrationUser = identity.User, DocumentLabel = label }); }
public async Task <Download <BlockData> > DownloadBlockData(ChainType chainType, int chainId, uint chainIndex, long blockId) { try { var chainTypeName = chainType.ToString().ToLower(); var blockRawData = await DownloadBinary($"static/{chainTypeName}chain/{chainId}/{chainIndex}/block/{blockId}/blockdata/result.data"); return(new Download <BlockData>(BlockData.Restore(blockRawData))); } catch (Exception exception) { return(Download <BlockData> .HandleException(exception)); } }
public List <INodeChecker> FindCheckerByChainType(ChainType chainType) { List <INodeChecker> node = new List <INodeChecker>(); foreach (var nodeChecker in _checkers) { if (nodeChecker.IsOnline() && nodeChecker.GetChainType() == chainType) { node.Add(nodeChecker); } } return(node); }
public Simulator(ChainType chainType) { // initialize kernel this.kernel = new StandardKernel(); // add logging module this.kernel.Load(new ConsoleLoggingModule()); // log startup this.logger = LogManager.GetCurrentClassLogger(); this.logger.Info($"Starting up: {DateTime.Now}"); this.random = new Random(); this.blockProvider = TestBlockProvider.CreateForRules(chainType); // add storage module this.kernel.Load(new MemoryStorageModule()); // add rules module this.kernel.Load(new RulesModule(chainType)); // by default, don't run scripts in unit tests var rules = this.kernel.Get<ICoreRules>(); rules.IgnoreScripts = true; // initialize the blockchain daemon this.kernel.Bind<CoreDaemon>().ToSelf().InSingletonScope(); this.coreDaemon = this.kernel.Get<CoreDaemon>(); this.coreStorage = this.coreDaemon.CoreStorage; // start the blockchain daemon this.coreDaemon.Start(); // wait for initial work this.coreDaemon.WaitForUpdate(); // verify initial state Assert.AreEqual(0, this.coreDaemon.TargetChainHeight); Assert.AreEqual(rules.ChainParams.GenesisBlock.Hash, this.coreDaemon.TargetChain.LastBlock.Hash); Assert.AreEqual(rules.ChainParams.GenesisBlock.Hash, this.coreDaemon.CurrentChain.LastBlock.Hash); }
public LevelDbStorageModule(string baseDirectory, ChainType rulesType, ulong? blocksCacheSize = null, ulong? blocksWriteCacheSize = null, ulong? blockTxesCacheSize = null, ulong? blockTxesWriteCacheSize = null, ulong? chainStateCacheSize = null, ulong? chainStateWriteCacheSize = null, string[] blockTxesStorageLocations = null) { this.baseDirectory = baseDirectory; this.blockTxesStorageLocations = blockTxesStorageLocations; dataDirectory = Path.Combine(baseDirectory, "Data", rulesType.ToString()); peersDirectory = Path.Combine(baseDirectory, "Peers", rulesType.ToString()); chainType = rulesType; this.blocksCacheSize = blocksCacheSize; this.blocksWriteCacheSize = blocksWriteCacheSize; this.blockTxesCacheSize = blockTxesCacheSize ?? (ulong)128.MEBIBYTE(); this.blockTxesWriteCacheSize = blockTxesWriteCacheSize ?? (ulong)32.MEBIBYTE(); this.chainStateCacheSize = chainStateCacheSize ?? (ulong)512.MEBIBYTE(); this.chainStateWriteCacheSize = chainStateWriteCacheSize ?? (ulong)128.MEBIBYTE(); }
public void Execute(ChainType chain) { _buildSourceChain.Build(chain)(_request, _bus, DataProviderResponses, _request.First().Request.RequestId); }
public Chain(ChainType type) { _animals = new List<Animal>(); ChainType = type; }
public Action<ICollection<IPointToLaceRequest>, IAdvancedBus, ICollection<IPointToLaceProvider>, Guid> Build(ChainType chain) { return Chains.First(w => w.Key == chain).Value; }
public RulesModule(ChainType chainType) { this.chainType = chainType; }
/// <summary> /// Creates a new Chain /// </summary> /// <param name="entry">First entry in chain</param> /// <returns></returns> public static ChainType NewChain(DataStructs.EntryData entry) { var c = new ChainType(); c.FirstEntry = entry; var chainHash = new List<byte>(); if (entry.ExtIDs != null) { foreach (var extId in entry.ExtIDs) { var h = SHA256.Create().ComputeHash(extId); chainHash.AddRange(h); } } c.ChainId = SHA256.Create().ComputeHash(chainHash.ToArray()); c.FirstEntry.ChainId = c.ChainId; return c; }
/// <summary> /// Second step in committing a new chain. Only run this if CommitChain was successful. /// </summary> /// <param name="c">Chain to be added</param> /// <returns>Boolean true/false for success/failure</returns> public static bool RevealChain(ChainType c) { var r = new Reveal(); var b = Entries.MarshalBinary(c.FirstEntry); r.Entry = Arrays.ByteArrayToHex(b); var json = JsonConvert.SerializeObject(r); var byteJson = Encoding.ASCII.GetBytes(json); var req = new RestRequest("/reveal-chain/", Method.POST); req.RequestFormat = DataFormat.Json; req.AddParameter("application/json", json, ParameterType.RequestBody); var resp = StaticValues.clientWallet.Execute(req); Console.WriteLine("RevealChain Resp = " + resp.StatusCode); //TODO: Remove if (resp.StatusCode != HttpStatusCode.OK) { throw new FactomChainException("Chain Reveal Failed. Message: " + resp.ErrorMessage); } return true; }