Author Topic: Dividend feature  (Read 4478 times)

0 Members and 1 Guest are viewing this topic.

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4664
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
Good job  +5%, finally you published something out.

I'd recommend that you run a performance test for example on following code:
https://github.com/pureland/bitshares-2/blob/baaa44d920bd010a5344c164ae61ea76ffff3323/libraries/chain/db_balance.cpp#L44-L56
Code: [Select]
vector<pair<account_id_type, share_type>> database::get_balance(asset_id_type asset_id) const
{
vector<pair<account_id_type, share_type>> results;
pair<account_id_type, share_type> result;
auto& index = get_index_type<account_balance_index>().indices().get<by_asset>();
for (auto itr = index.find(asset_id); itr != index.end() && itr->asset_type == asset_id; itr++)
{
result.first = itr->owner;
result.second = itr->balance;
results.push_back(result);
}
return results;
}

IMO std::vector will kill performance.
« Last Edit: February 15, 2016, 03:49:04 pm by abit »
BitShares committee member: abit
BitShares witness: in.abit

Offline BTSdac

  • Hero Member
  • *****
  • Posts: 1219
    • View Profile
  • BitShares: K1
now .. this is very useful for sharedrops and alike:
https://github.com/pureland/bitshares-2/commit/106b195838943801871ed9e74c0a9f6269738bc8

could you add a cli-wallet call to get the owners and their balances for a given asset? that would be awesome!

We need a worker for this, so we can pay CNX to properly review this code!!
I was not a coder ,  I learning code after I investing bts ,  I find code is a language between people and computer ,
so I am not very similar with github.
it is my first feature on bts ,I would try to perfect it ,
after that I will develop more features that I think kill feature.
« Last Edit: February 15, 2016, 03:46:37 pm by BTSdac »
github.com :pureland
BTS2.0 API :ws://139.196.37.179:8091
BTS2.0 API 数据源ws://139.196.37.179:8091

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
now .. this is very useful for sharedrops and alike:
https://github.com/pureland/bitshares-2/commit/106b195838943801871ed9e74c0a9f6269738bc8

could you add a cli-wallet call to get the owners and their balances for a given asset? that would be awesome!

We need a worker for this, so we can pay CNX to properly review this code!!

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
wow .. awesome progress these days ...

One thing though: could you please fork from github.com/cryptonomex/graphene instead of bitshares? That would make it way easier for me to run code like this on the testnet!

Offline BTSdac

  • Hero Member
  • *****
  • Posts: 1219
    • View Profile
  • BitShares: K1
Dividend feature

Features:
Pay a dividend (of course ,dividend also is a specific asset on chain)to holder of a specific asset.
below is the output of opreation
Code: [Select]
dividend k1 DVD BTS 10000  188 0 testing 1
{
  "ref_block_num": 924,
  "ref_block_prefix": 480314239,
  "expiration": "2016-02-15T15:18:20",
  "operations": [[
      45,{
        "fee": {
          "amount": 20007812,
          "asset_id": "1.3.0"
        },
        "isser": "1.2.11",
        "shares_asset": "1.3.1",
        "dividend_asset": "1.3.0",
        "min_shares": 10000,
        "value_per_shares": 188,
        "block_no": 0,
        "describtion": "testing",
        "extensions": []
      }
    ]
  ],
  "extensions": [],
  "signatures": [
    "1f1782d8f8b74eb711764731855a457aefcdee04d31048915445575871a4e2782a66f6da6e10d68c15245fc6a84b976fc4bf21a36d8177e4ae2c2d90ba6eef0664"
  ]
}

Code is here:
https://github.com/pureland/bitshares-2/commits/bitshares
the code have bug , because I am not similar with github ,the code on github is not same as my local 
performance testing :
dividend to 1000 accounts take less than 1s in local testing
and dividend to 10000 accounts take about 3s
« Last Edit: February 17, 2016, 06:57:38 am by BTSdac »
github.com :pureland
BTS2.0 API :ws://139.196.37.179:8091
BTS2.0 API 数据源ws://139.196.37.179:8091