BitSharp.Core.Domain.UnconfirmedTxes.UnconfirmedTxes C# (CSharp) 메소드

UnconfirmedTxes() 공개 메소드

public UnconfirmedTxes ( BitSharp.Core.Domain.Chain chain, IStorageManager storageManager ) : BitSharp.Common
chain BitSharp.Core.Domain.Chain
storageManager IStorageManager
리턴 BitSharp.Common
        public UnconfirmedTxes(Chain chain, IStorageManager storageManager)
        {
            CursorCount = 32;
            Chain = chain;

            // create a cache of cursors that are in an open snapshot transaction with the current chain state
            var success = false;
            this.cursorCache = new DisposableCache<DisposeHandle<IUnconfirmedTxesCursor>>(CursorCount);
            try
            {
                for (var i = 0; i < this.cursorCache.Capacity; i++)
                {
                    // open the cursor
                    var handle = storageManager.OpenUnconfirmedTxesCursor();
                    var cursor = handle.Item;

                    // cache the cursor
                    // this must be done before beginning the transaction as caching will rollback any transactions
                    this.cursorCache.CacheItem(handle);

                    // begin transaction to take the snapshot
                    cursor.BeginTransaction(readOnly: true);

                    // verify the chain state matches the expected chain
                    var chainTip = cursor.ChainTip;
                    if (chainTip?.Hash != chain.LastBlock?.Hash)
                        throw new ChainStateOutOfSyncException(chain.LastBlock, chainTip);
                }

                success = true;
            }
            finally
            {
                // ensure any opened cursors are cleaned up on an error
                if (!success)
                    this.cursorCache.Dispose();
            }
        }