Comments (2)
I guess #517 closes this issue.
from libplanet.
At first I thought to add the interface like below.
Task<Block<T>> Blockchain.MineBlockAsync(Address rewardBenficiary);
IEnumerator Blockchain.MineBlock(Address rewardBeneficiary, out Block<T> block);
// or
IEnumerator Blockchain.MineBlock(Address rewardBeneficiary, Action<Block<T>> onMined);
But there is some points to think about... (If I know something wrong, please comment.)
- In Unity, we can use
async
/await
. but there is no support likeMonoBehaviour.StopCoroutine()
. IEnumerator Blockchain.MineBlock()
fits Unity's coroutine idiom perfectly. but making concurrency in this way seems to be Unity's style, not usual .NET style.- Nevertheless, if implemented in libplanet.net, we need to use Unity-dependent feature like
WaitForSeconds
.
- Nevertheless, if implemented in libplanet.net, we need to use Unity-dependent feature like
We can still add an async
/ await
style API, but it does not come up with any good utility right now.
Instead I suggest workaround for Unity like below
public IEnumerator Mine(Address address)
{
while (true)
{
var task = Task.Run(() => blocks.MineBlock(address));
yield return new WaitUntil(() => task.IsCompleted);
Debug.Log($"mined {task.Result.Index}");
}
}
private void Awake()
{
StartCoroutine(Mine(UserAddress));
}
cc
from libplanet.
Related Issues (20)
- Refactor/remove `BaseIndex<K, V>` class.
- ðŠĶ -> ð Revive check CHANGES.md
- âïļ Split `CHANGES.md` to each major version.
- ðĪ Libplanet.Explorer GraphQL schema checks in CI
- ð Report problem of Libplanet.Explorer GraphQL schema changes HOT 5
- Settings are automatically added to settings.json when using vscode HOT 3
- ð Move `Currency` related methods from `IAccount` to `IWorld`
- Introduce VRF on Libplanet main branch
- âïļ Seperate Libplanet.Renderer
- Do not allow negative balance
- ð Remove `PreEvaluationBlock` HOT 3
- `ConsensusContext.HandleMessage()` creates context with earlier validator set HOT 1
- Remove redundant `Initialize()` on `TestUtils`
- Upgrade `BouncyCastle.Cryptography` to 2.3.1
- Partially deprecate PoW `Block` handling HOT 2
- Fix `Currency` and `ValidatorSet` related GQL queries
- Remove `Nonce`
- Remove `IActionContext` typed parameter from `IWorld.TransferAsset()`
- Upgrade `LiteDB` to a secure version
- Fix `ConsensusContext.CreateContext()`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
ð Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ððð
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google âĪïļ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libplanet.