This repository has been archived by the owner on May 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Ethash C API
Gav Wood edited this page Mar 31, 2015
·
19 revisions
This is just a documentation of the request of the C API described in this PR.
typedef int(*Callback)(unsigned);
typedef void const* ethash_light_t;
typedef void const* ethash_full_t;
typedef uint8_t ethash_seed_t[32];
ethash_light_t ethash_new_light(ethash_params const* params, ethash_seed_t seed);
void ethash_compute_light(ethash_return_value *ret, ethash_light_t light, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce);
void ethash_delete_light(ethash_light_t light);
ethash_full_t ethash_new_full(ethash_params const* params, void const* cache, const uint8_t seed[32], CallBack c);
void ethash_compute_full(ethash_return_value *ret, ethash_full_t full, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce);
void ethash_delete_full(ethash_full_t full);
non-zero return from Callback means "cancel DAG creation" - this should cause an immediate return of ethash_new_full with 0.
an object of type ethash_full_t may be tested for validity with != 0
int callback(unsigned _progress)
{
printf("\rGenerating DAG. %d%% done...", _progress);
return 0;
}
void main()
{
ethash_params p;
ethash_light_t light;
ethash_seed_t seed;
// TODO: populate p, seed, light
ethash_full_t dag = ethash_new_full(&p, cache, seed, &callback);
if (!dag)
{
printf("Failed generating DAG :-(\n");
exit(-1);
}
printf("DAG Generated OK!\n");
uint8_t headerHash[32];
// TODO: populate headerHash
uint64_t nonce = time(0);
ethash_return_value ret;
for (; !isWinner(ret); nonce++)
ethash_compute_full(&ret, dag, &p, headerHash, nonce);
printf("Got winner! nonce is %d\n", nonce);
ethash_delete_full(dag);
}
- Home
- Ethereum Whitepaper
- Ethereum Introduction
- Uses: DAOs and dapps
- Getting Ether
- FAQs
- Design Rationale
- EVM intro: Ethereum Yellow Paper, Beige Paper and Py-EVM.
- Wiki for (old) website (still a good introduction)
- Glossary
- Sharding introduction & R&D Compendium, FAQs & roadmap
- Casper Proof-of-Stake compendium and FAQs.
- Alternative blockchains, randomness, economics, and other research topics
- Hard Problems of Cryptocurrency
- Governance
- Chain Spec Format
- Inter-exchange Client Address Protocol
- URL Hint Protocol
- Network Status
- Mining
- Licensing
- Consortium Chain Development
- RLP Encoding
- Patricia Tree
- Web3 Secret Storage
- Light client protocol
- Subtleties
- Solidity Documentation
- NatSpec Format
- Contract ABI
- Bad Block Reporting
- Bad Chain Canary
0x927c0E368722206312D243417dA9797424b56434