libplanet icon indicating copy to clipboard operation
libplanet copied to clipboard

Replace `UserContext` with .NET DI

Open longfin opened this issue 3 years ago • 2 comments

Looking at BlockType<T>.PreviousBlock, it asks to set IStore or BlockChain<T> via UserContext on Libplanet.Explorer. However, this is something .NET DI can accomplish well enough. thus I suggest replacing it with DI like as below...

        public BlockType(IStore store)
        {
            Field<BlockType<T>>(
                "PreviousBlock",
                resolve: ctx =>
                {
                    if (!(ctx.Source.PreviousHash is BlockHash h))
                    {
                        return null;
                    }

                    HashAlgorithmGetter hashAlgorithmGetter = _ => HashAlgorithmType.Of<SHA256>();
                    return store.GetBlock<T>(hashAlgorithmGetter, h);
                });

            Name = "Block";
        }

longfin avatar May 06 '22 06:05 longfin

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

stale[bot] avatar Jul 31 '22 01:07 stale[bot]

👀

xet-a avatar Jul 31 '22 02:07 xet-a