Ejemplo n.º 1
0
        public UInt256 GetValue(UInt160 contract, UInt256 key)
        {
            var value = _state.Get(
                EntryPrefix.StorageByHash.BuildPrefix(contract).Concat(key.ToBytes()).ToArray()
                );

            return(value is null ? UInt256Utils.Zero : value.ToUInt256());
        }
Ejemplo n.º 2
0
        public Money GetBalance(UInt160 owner)
        {
            var key     = EntryPrefix.BalanceByOwnerAndAsset.BuildPrefix(owner);
            var value   = _state.Get(key);
            var balance = value?.ToUInt256() ?? UInt256Utils.Zero;

            return(new Money(balance));
        }
Ejemplo n.º 3
0
        public EventObject GetEventByTransactionHashAndIndex(UInt256 transactionHash, uint eventIndex)
        {
            var prefix = EntryPrefix.EventByTransactionHashAndIndex.BuildPrefix(transactionHash, eventIndex);
            var raw    = _state.Get(prefix);

            prefix = EntryPrefix.EventTopicsByTransactionHashAndIndex.BuildPrefix(transactionHash, eventIndex);
            var topics = _state.Get(prefix);

            return(new EventObject(
                       raw is null ? null : Event.Parser.ParseFrom(raw),
                       topics is null ? null : topics.ByteArrayToTransactionHashList().ToList()
                       ));
        }
Ejemplo n.º 4
0
        public ConsensusState GetConsensusState()
        {
            var raw = _state.Get(EntryPrefix.ConsensusState.BuildPrefix()) ??
                      throw new ConsensusStateNotPresentException();

            return(ConsensusState.FromBytes(raw));
        }
Ejemplo n.º 5
0
        public ulong GetTotalTransactionCount(UInt160 from)
        {
            var raw = _state.Get(EntryPrefix.TransactionCountByFrom.BuildPrefix(from));

            return(raw?.AsReadOnlySpan().ToUInt64() ?? 0u);
        }
Ejemplo n.º 6
0
        public Contract?GetContractByHash(UInt160 contractHash)
        {
            var value = _state.Get(EntryPrefix.ContractByHash.BuildPrefix(contractHash));

            return(value != null?Contract.FromBytes(value) : null);
        }
Ejemplo n.º 7
0
        public ulong GetTotalBlockHeight()
        {
            var raw = _state.Get(EntryPrefix.BlockHeight.BuildPrefix());

            return(raw?.AsReadOnlySpan().ToUInt64() ?? 0u);
        }