/
IWorldState.cs
53 lines (50 loc) · 1.86 KB
/
IWorldState.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using Libplanet.Crypto;
using Libplanet.Store.Trie;
namespace Libplanet.Action.State
{
/// <summary>
/// An interface to fetch world states.
/// <para>It is like a readonly map which is virtually initialized such
/// that every possible <see cref="Address"/> exists and
/// is mapped to <see langword="null"/>. That means that:</para>
/// <list type="bullet">
/// <item>
/// <description>it does not have length,</description>
/// </item>
/// <item>
/// <description>its index getter never throws
/// <see cref="KeyNotFoundException"/>,
/// but returns <see langword="null"/> instead, and</description>
/// </item>
/// <item>
/// <description>filling an <see cref="Address"/> with
/// <see langword="null"/> state cannot be distinguished from
/// the <see cref="Address"/> having never been set to
/// any state.</description>
/// </item>
/// </list>
/// </summary>
public interface IWorldState
{
/// <summary>
/// The <see cref="ITrie"/> of the <see cref="IWorldState"/>.
/// </summary>
public ITrie Trie { get; }
/// <summary>
/// Whether <see cref="IWorldState"/> is in legacy state or not.
/// </summary>
bool Legacy { get; }
/// <summary>
/// Gets the <see cref="IAccountState"/> of the given <paramref name="address"/>.
/// </summary>
/// <param name="address">The <see cref="Address"/> referring
/// the world to get its state.</param>
/// <returns>The <see cref="IAccountState"/> of the given <paramref name="address"/>.
/// If it has never been set to any state it returns <see langword="null"/>
/// instead.</returns>
[Pure]
IAccountState GetAccountState(Address address);
}
}