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)
- `yarn build` cannot replace version of dependency libraries in worktree due to non-existent version.
- Implement `Publish` method for `Gossip`
- @planetarium/account: Provide `equals()` methods for `Address` & `PublicKey`
- Check `Transaction<T>.GenesisHash` for a genesis `Block<T>` HOT 1
- @planetarium/tx: Provide decoding functions besides encoding functions HOT 1
- Fix `ValidatingActionRenderer.Validate()`
- Codebase cleanup based on new assumption that `BlockChain<T>.Tip` is well defined HOT 1
- Refactor `BlockChain<T>.Append()` to reduce parameters.
- Make `ConsensusContext` not to asynchronous
- `planet key change-passphrase`
- @planetarium/cli fails to install with recent Node.js versions on Windows HOT 2
- Refactoring Proposal for IFeeCalculator
- `ExplorerQuery.ListBlocks()` may fails, while `BlockChain<T>.Append()` executing. HOT 2
- Lazy validator that has been skipped `PreCommit` step cannot commit to `Block`
- Improve `MerkleTrie.Commit()` performance
- [TBD] Fee Collect
- [TBD] IAccount
- [TBD] DPoS
- THE-NB-001
- Introduce `Evidence` HOT 3
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.