Author Topic: Understand the Bitshares-core code  (Read 1920 times)

0 Members and 1 Guest are viewing this topic.

Offline pc

  • Hero Member
  • *****
  • Posts: 1530
    • View Profile
    • Bitcoin - Perspektive oder Risiko?
  • BitShares: cyrano
Good questions.

You might want to start looking at database::_apply_transaction (in db_block.cpp). Like all core code, this is in the libraries/chain module.
A few levels deeper you will see that for every blockchain operation there is an evaluator. Evaluators are grouped together in files, e. g. market_evaluator.cpp contains all evaluators for market-related operations.

It's a bit difficult to follow the execution paths. because some of the logic is hidden in static_variant objects that use the visitor pattern to find the relevant code for the specific object inside the static_variant. I'd suggest to skip over the static_variant stuff when reading the code, it's a bit tricky to understand.

Being a C programmer turned Java programmer turned C++ programmer myself, I'd like to warn you about a few traps. C++ reads almost like Java, but there are a few significant differences:

* Destructors are important in C++
* By default, methods are called by-value, not by-reference.
* Method lookup works differently in C++, in particular wrt overloaded methods.
Bitcoin - Perspektive oder Risiko? ISBN 978-3-8442-6568-2 http://bitcoin.quisquis.de

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Look for 'limit_order_create_operation' it has a validator, an evaluator and an apply-er that tells you what is going on.

Offline Victor118

Hello, I am a Java / Javascript developer.
I would like to understand the code of Bitshares core.
Is there any documentation?
When I look at the code I do not understand, obviously I have to learn C ++ (it's in progress).

I would like to understand where is the code that determines the code to execute according to the type of transaction?

For example:
 what is the called method sequence when a limit order creation transaction is transferred to the blockchain?
What code is executed when a witness add new price feed for a smart asset and the margin call logic ?
...etc
Sorry for my bad English and these noob questions !!