Exemple #1
0
        protected override ICachedSource <byte[], byte[]> Create(byte[] key, ICachedSource <byte[], byte[]> srcCache)
        {
            AccountState  accountState = this.parentRepo.accountStateCache.Get(key);
            IPatriciaTrie storageTrie  = this.parentRepo.GetTrieWithSameCache(accountState?.StateRoot);

            return(new StorageCache(storageTrie));
        }
        public StateRepositoryRoot(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);

            this.SetupAsNew();
        }
Exemple #3
0
        /// <inheritdoc />
        public ISource <byte[], byte[]> Get(byte[] key)
        {
            if (this.cache.ContainsKey(key))
            {
                return(this.cache[key]);
            }

            AccountState  accountState = this.repo.accountStateCache.Get(key);
            IPatriciaTrie storageTrie  = this.repo.GetTrieWithSameCache(accountState?.StateRoot);
            var           newCache     = new StorageCache(storageTrie);

            this.cache[key] = newCache;
            return(newCache);
        }
Exemple #4
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);
        }
 public StorageCache(IPatriciaTrie trie) : base(new SourceCodec <byte[], byte[], byte[], byte[]>(trie, new Serializers.NoSerializer <byte[]>(), new Serializers.NoSerializer <byte[]>()), WriteCache <byte[]> .CacheType.SIMPLE)
 {
     this.trie = trie;
 }
Exemple #6
0
 public StorageCache(IPatriciaTrie trie) : base(trie, WriteCache <byte[]> .CacheType.SIMPLE)
 {
     this.trie = trie;
 }