Beispiel #1
0
        public EntryItem AddEntry(byte[] dataEntry, byte [][] ExtIDs = null)
        {
            if (EcAddress == null)
            {
                throw new Exception("No EcAddress provided - read only");
            }

            Action <EntryItem> action = (process) => {
                try
                {
                    process.Commit = new CommitEntry(FactomD);
                    var commitStatus = process.Commit.Run(ChainID, dataEntry, EcAddress, ExtIDs);

                    if (commitStatus) //commit success?
                    {
                        process.Status = EntryItem.State.CommitOK;
                        process.TxId   = process.Commit?.Result?.result?.Txid ?? null;
                        process.Reveal = new RevealEntry(FactomD);
                        if (process.Reveal.Run(process.Commit.Entry))
                        {
                            process.Status    = EntryItem.State.RevealOK;
                            process.EntryHash = process.Reveal?.Result?.result?.Entryhash;
                        }
                        else  //Reveal failed
                        {
                            var error = JsonConvert.DeserializeObject <APIError>(process.Reveal.JsonReply);
                            process.ApiError = error;
                            process.Status   = EntryItem.State.RevealFail;
                        }
                    }
                    else //Commit failed
                    {
                        var error = JsonConvert.DeserializeObject <APIError>(process.Commit.JsonReply);
                        process.ApiError = error;
                        process.Status   = EntryItem.State.CommitFail;
                    }
                }
                catch (Exception ex)
                {
                    var error = new APIError(ex);
                    process.ApiError = error;
                    process.Status   = EntryItem.State.Exception;
                }
            };


            var queueItem = new EntryItem(this, action, Blocking);

            lock (queueLock)
            {
                EntryQueue.Add(queueItem);
            }
            RunQueue();
            return(queueItem);
        }
Beispiel #2
0
 internal void SetQueueItemStatusChange(EntryItem queueItemEntry, EntryItem.State state)
 {
     QueueItemStatusChange?.Invoke(queueItemEntry, state);
 }