public static RpcFoundStates FindStates(this RpcClient rpcClient, UInt256 rootHash, UInt160 scriptHash, ReadOnlySpan <byte> prefix, ReadOnlySpan <byte> from = default, int?count = null) { var @params = StateAPI.MakeFindStatesParams(rootHash, scriptHash, prefix, from, count); var result = rpcClient.RpcSend(RpcClient.GetRpcName(), @params); return(RpcFoundStates.FromJson(result)); }
public RpcFoundStates FindStates(UInt256 rootHash, UInt160 scriptHash, ReadOnlyMemory <byte> prefix, ReadOnlyMemory <byte> from = default, int?count = null) { var familyName = $"{nameof(FindStates)}{rootHash}{scriptHash}"; var family = db.GetOrCreateColumnFamily(familyName); var keyLength = prefix.Length + from.Length + (count.HasValue ? sizeof(int) : 0); Span <byte> key = stackalloc byte[keyLength]; prefix.Span.CopyTo(key); if (from.Length > 0) { from.Span.CopyTo(key.Slice(prefix.Length)); } if (count.HasValue) { BinaryPrimitives.WriteInt32LittleEndian(key.Slice(prefix.Length + from.Length), count.Value); } var json = GetCachedJson(key, family, () => { var @params = StateAPI.MakeFindStatesParams(rootHash, scriptHash, prefix.Span, from.Span, count); return(rpcClient.RpcSend("findstates", @params)); }); return(RpcFoundStates.FromJson(json)); }
public async Task <RpcFoundStates> FindStatesAsync(UInt256 rootHash, UInt160 scriptHash, ReadOnlyMemory <byte> prefix, ReadOnlyMemory <byte> from = default, int?count = null) { var @params = MakeFindStatesParams(rootHash, scriptHash, prefix.Span, from.Span, count); var result = await rpcClient.RpcSendAsync(RpcClient.GetRpcName(), @params).ConfigureAwait(false); return(RpcFoundStates.FromJson(result)); }