/// <summary>
        /// Creates brand new caches, just like starting from scratch.
        /// Useful when creating a new StateRepositoryRoot or trying to sync to another known state and wanting to abandon all "in-progress" data.
        /// </summary>
        private void SetupAsNew()
        {
            SourceCodec <byte[], AccountState, byte[], byte[]> accountStateCodec = new SourceCodec <byte[], AccountState, byte[], byte[]>(this.stateTrie, new Serializers.NoSerializer <byte[]>(), Serializers.AccountSerializer);
            WriteCache <AccountState> accountStateCache = new WriteCache <AccountState>(accountStateCodec, WriteCache <AccountState> .CacheType.SIMPLE);

            var storageCaches = new RootStorageCaches(this);
            ISource <byte[], byte[]> codeCache    = new WriteCache <byte[]>(stateDS, WriteCache <byte[]> .CacheType.COUNTING);
            ISource <byte[], byte[]> unspentCache = new WriteCache <byte[]>(stateDS, WriteCache <byte[]> .CacheType.SIMPLE);
            SourceCodec <byte[], ContractUnspentOutput, byte[], byte[]> unspentCacheCodec = new SourceCodec <byte[], ContractUnspentOutput, byte[], byte[]>(unspentCache, new Serializers.NoSerializer <byte[]>(), Serializers.ContractOutputSerializer);

            this.Init(accountStateCache, codeCache, storageCaches, unspentCacheCodec);
        }
示例#2
0
        public ContractStateRoot(ISource <byte[], byte[]> stateDS, byte[] stateRoot)
        {
            this.stateDS   = stateDS;
            this.trieCache = new WriteCache <byte[]>(stateDS, WriteCache <byte[]> .CacheType.COUNTING);
            this.stateTrie = new PatriciaTrie(stateRoot, this.trieCache);

            SourceCodec <byte[], AccountState, byte[], byte[]> accountStateCodec = new SourceCodec <byte[], AccountState, byte[], byte[]>(this.stateTrie, new Serializers.NoSerializer <byte[]>(), Serializers.AccountSerializer);
            ReadWriteCache <AccountState> accountStateCache = new ReadWriteCache <AccountState>(accountStateCodec, WriteCache <AccountState> .CacheType.SIMPLE);

            MultiCacheBase <ICachedSource <byte[], byte[]> > storageCache = new MultiStorageCache(this);
            ISource <byte[], byte[]> codeCache    = new WriteCache <byte[]>(stateDS, WriteCache <byte[]> .CacheType.COUNTING);
            ISource <byte[], byte[]> unspentCache = new WriteCache <byte[]>(stateDS, WriteCache <byte[]> .CacheType.SIMPLE);
            SourceCodec <byte[], ContractUnspentOutput, byte[], byte[]> unspentCacheCodec = new SourceCodec <byte[], ContractUnspentOutput, byte[], byte[]>(unspentCache, new Serializers.NoSerializer <byte[]>(), Serializers.VinSerializer);

            this.Init(accountStateCache, codeCache, storageCache, unspentCacheCodec);
        }