Main Menu

Dividend feature

Started by BTSdac, February 15, 2016, 03:20:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

abit

#5
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

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.
BitShares committee member: abit
BitShares witness: in.abit

BTSdac

#4
Quote from: xeroc on February 15, 2016, 03:38:27 PM
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.
[url="//github.com"]github.com[/url] :pureland
BTS2.0 API :[url="ws://139.196.37.179:8091"]ws://139.196.37.179:8091[/url]
BTS2.0 API 数据源ws:[url="//139.196.37.179:8091"]//139.196.37.179:8091[/url]

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!!

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!

BTSdac

#1
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
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
[url="//github.com"]github.com[/url] :pureland
BTS2.0 API :[url="ws://139.196.37.179:8091"]ws://139.196.37.179:8091[/url]
BTS2.0 API 数据源ws:[url="//139.196.37.179:8091"]//139.196.37.179:8091[/url]