Example #1
0
 public Blockchain(IStore store)
 {
     Store        = store;
     Blocks       = new BlockSet <T>(store);
     Transactions = new TransactionSet <T>(store);
     Addresses    = new AddressTransactionSet <T>(store);
 }
Example #2
0
 public AddressTransactionSetTest()
 {
     _fx  = new FileStoreFixture();
     _set = new AddressTransactionSet <BaseAction>(
         _fx.Store, _fx.StoreNamespace
         );
 }
Example #3
0
        public BlockChain(IBlockPolicy <T> policy, IStore store, Guid id)
        {
            _id          = id;
            Policy       = policy;
            Store        = store;
            Blocks       = new BlockSet <T>(store, _id.ToString());
            Transactions = new TransactionSet <T>(store, _id.ToString());
            Addresses    = new AddressTransactionSet <T>(store, _id.ToString());

            Store.InitNamespace(_id.ToString());
        }
Example #4
0
        public BlockChain(IBlockPolicy <T> policy, IStore store, Guid id)
        {
            Id           = id;
            Policy       = policy;
            Store        = store;
            Blocks       = new BlockSet <T>(store, Id.ToString());
            Transactions = new TransactionSet <T>(store, Id.ToString());
            Addresses    = new AddressTransactionSet <T>(store, Id.ToString());

            _rwlock = new ReaderWriterLockSlim(
                LockRecursionPolicy.SupportsRecursion);
        }
Example #5
0
        // FIXME it's very dangerous because replacing Id means
        // ALL blocks (referenced by MineBlock(), etc.) will be changed.
        // we need to add a synchronization mechanism to handle this correctly.
        internal void Swap(BlockChain <T> other)
        {
            try
            {
                _rwlock.EnterWriteLock();

                Id           = other.Id;
                Blocks       = new BlockSet <T>(Store, Id.ToString());
                Transactions = new TransactionSet <T>(Store, Id.ToString());
                Addresses    = new AddressTransactionSet <T>(Store, Id.ToString());
            }
            finally
            {
                _rwlock.ExitWriteLock();
            }
        }