Author Topic: Dividend feature  (Read 4477 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.
thank you  +5%
I would change a way ,
like a multiple transfer ,  a transfer send to many user
it would take more spare of chain ,but small cpu time
consider account id take 8B, and shares also take 8B,  it mean increase a receiver of a transfer , it just increase 16B  ,
if a transfer send to 10,000 accounts , it is just increase 160KB apace , it is not too much .
if want to reduce the space more ,
1.2^32 is a big value , and now there are only about 100k account ,so in a multiple transfer ,use 4B to record account_id, and also use the small apace to record shares
2.set two parameters
   account_id_length  and share_length
   to define how many bytes acount_id take and how many bytes shares take , it would reduce to 8B for one receiver increasing in  multiple transfer.
So you have thought about data transfer and data storage. That's good.
But that's not enough, we also need to think about CPU and memory.

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!
if it is a worker on bts chain , I think it is reasonable that fork from github.com/bitshares.

Looking forward to seeing your worker proposal :D
BitShares committee member: abit
BitShares witness: in.abit

Offline BTSdac

  • Hero Member
  • *****
  • Posts: 1219
    • View Profile
  • BitShares: K1
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!
if it is a worker on bts chain , I think it is reasonable that fork from github.com/bitshares.
github.com :pureland
BTS2.0 API :ws://139.196.37.179:8091
BTS2.0 API 数据源ws://139.196.37.179:8091

Offline dirnet

  • Full Member
  • ***
  • Posts: 105
    • View Profile
Great job!  +5% +5% +5%

Offline sudo

  • Hero Member
  • *****
  • Posts: 2255
    • View Profile
  • BitShares: ags

Offline merivercap

  • Hero Member
  • *****
  • Posts: 661
    • View Profile
    • BitCash
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.

Wow that's an inspiring story @BTSdac !

Seems like a very useful feature to have as well.  Great job!
BitCash - http://www.bitcash.org 
Beta: bitCash Wallet / p2p Gateway: (https://m.bitcash.org)
Beta: bitCash Trade (https://trade.bitcash.org)

Offline CLains

  • Hero Member
  • *****
  • Posts: 2606
    • View Profile
  • BitShares: clains

Offline Musewhale

  • Hero Member
  • *****
  • Posts: 2881
  • 丑,实在是太丑了 !
    • View Profile
Very important function  +5% +5% +5%
MUSE witness:mygoodfriend     vote for me

Offline pc

  • Hero Member
  • *****
  • Posts: 1530
    • View Profile
    • Bitcoin - Perspektive oder Risiko?
  • BitShares: cyrano
Great!

But you really need to do performance testing. AFAIR performance was the main reason for using buybacks instead of proper dividends.
Bitcoin - Perspektive oder Risiko? ISBN 978-3-8442-6568-2 http://bitcoin.quisquis.de

Offline cylonmaker2053

  • Hero Member
  • *****
  • Posts: 1004
  • Saving the world one block at a time
    • View Profile
  • BitShares: cylonmaker2053

Offline kenCode

  • Hero Member
  • *****
  • Posts: 2283
    • View Profile
    • Agorise
Well, as long as the uia issuer doesn't get in trouble for being a bank (which is 1 reason why we need to start onboarding banks) then yes. I'll have our denmark company start issuing dividend bearing uias for tons of different projects i have sitting here with no funding yet. The network effect if issuing something like that could take it viral.
 
Sorry for the highjack, back to the OP :)
kenCode - Decentraliser @ Agorise
Matrix/Keybase/Hive/Commun/Github: @Agorise
www.PalmPay.chat

Offline lil_jay890

  • Hero Member
  • *****
  • Posts: 1197
    • View Profile
Dividend feature

Features:
Pay a dividend ...
Code: [Select]

...
        "describtion": "testing",
...
Code is here:
https://github.com/pureland/bitshares-2/commits/bitshares

WOOOOHOOOO!! :)  +5% +5% +5% +5% +5%
side note: i think a spelling error above.. description (not describtion)
 
GREAT WORK BTSdac! :)

A dividend is something I would like to see for tokens like OPENPOS and OBITS instead of a buyback.  Ken, would this be possible for you to implement on OPENPOS if the feature becomes available?

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Let me give you a quick crash course about how to SQUASH commits
together for nicer/smaller and fewer commits:

1) git log --pretty=format:"%h%x09%an%x09%s"
Code: [Select]
a790119 pureland        fix precision bug
baaa44d pureland        update cli_wallet
106b195 pureland        add dividend operation...  and fix bug
9ec1126 pureland        boost unit testing
a6e1589 pureland        add dividend operation...
59d64d7 pureland        add dividend operation...
91109b9 pureland        add head file
20ed738 pureland        add dividend operation
77fae12 pureland        delete seed node
a316cae pureland        add ignore dir
ec517cc pureland        Merge remote-tracking branch 'upstream/bitshares' into bitshares
e4082b5 valzav  bump gui version
ee8e587 valzav  gui_version
062ae3f Daniel Larimer  validate fixes
c1c37df Daniel Larimer  HARDFORK - auto canceled orders still pay fee
405f81e Daniel Larimer  HARDFORK: fix for hung cancel order
d9db27d Daniel Larimer  extra debug info
dfb45fb valzav  add gui version file
c1bd61e pureland        Update application.cpp
12d9f84 pureland        delete nodes
5c132da valzav  2.0.160120 gui release tag
7c1c7e8 Daniel Larimer  removing log
16b59e0 Daniel Larimer  adding seed node
dca5c95 Daniel Larimer  potential fix for hung chain
...
 

2. Now we pick the commit hash (first row) of the commit where we want
to stop. Here we want to put everthing together that is above e4082b5.
(This commit will not be part of the squashing)

3. We use the interactive rebase:
git rebase -i e4082b5

4. A text editor opens with the following content:

Code: [Select]
pick 12d9f84 delete nodes
pick c1bd61e Update application.cpp
pick a316cae add ignore dir
pick 77fae12 delete seed node
pick 20ed738 add dividend operation
pick 91109b9 add head file
pick 59d64d7 add dividend operation...
pick a6e1589 add dividend operation...
pick 9ec1126 boost unit testing
pick 106b195 add dividend operation...  and fix bug
pick baaa44d update cli_wallet
pick a790119 fix precision bug
If we saved the file now, nothing would change, but we want to squash
all of those commits together, so we replace every "pick" with a
"squash" (except for the very first one):

Code: [Select]
pick 12d9f84 delete nodes
squash c1bd61e Update application.cpp
squash a316cae add ignore dir
squash 77fae12 delete seed node
squash 20ed738 add dividend operation
squash 91109b9 add head file
squash 59d64d7 add dividend operation...
squash a6e1589 add dividend operation...
squash 9ec1126 boost unit testing
squash 106b195 add dividend operation...  and fix bug
squash baaa44d update cli_wallet
squash a790119 fix precision bug

After saving the file. You will be asked to add a commit message.
It is prefilled with all the commit messages you had in the squassed
commits.

Put whatever message you prefer or leave it as is. Save the file and you
will get a git history that looks like this:

Code: [Select]
69ad1f1 pureland        Squashed together some commits
e4082b5 valzav  bump gui version
ee8e587 valzav  gui_version
062ae3f Daniel Larimer  validate fixes
c1c37df Daniel Larimer  HARDFORK - auto canceled orders still pay fee
405f81e Daniel Larimer  HARDFORK: fix for hung cancel order
d9db27d Daniel Larimer  extra debug info
dfb45fb valzav  add gui version file
5c132da valzav  2.0.160120 gui release tag


That way, you could have the whole feature in a single commit which
makes it way easier to include it into other chains, such as the
testnet.

Cheers

« Last Edit: February 15, 2016, 04:22:40 pm by xeroc »

Offline BTSdac

  • Hero Member
  • *****
  • Posts: 1219
    • View Profile
  • BitShares: K1
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.
thank you  +5%
I would change a way ,
like a multiple transfer ,  a transfer send to many user
it would take more spare of chain ,but small cpu time
consider account id take 8B, and shares also take 8B,  it mean increase a receiver of a transfer , it just increase 16B  ,
if a transfer send to 10,000 accounts , it is just increase 160KB apace , it is not too much .
if want to reduce the space more ,
1.2^32 is a big value , and now there are only about 100k account ,so in a multiple transfer ,use 4B to record account_id, and also use the small apace to record shares
2.set two parameters
   account_id_length  and share_length
   to define how many bytes acount_id take and how many bytes shares take , it would reduce to 8B for one receiver increasing in  multiple transfer.
github.com :pureland
BTS2.0 API :ws://139.196.37.179:8091
BTS2.0 API 数据源ws://139.196.37.179:8091

Offline kenCode

  • Hero Member
  • *****
  • Posts: 2283
    • View Profile
    • Agorise
Dividend feature

Features:
Pay a dividend ...
Code: [Select]

...
        "describtion": "testing",
...
Code is here:
https://github.com/pureland/bitshares-2/commits/bitshares

WOOOOHOOOO!! :)  +5% +5% +5% +5% +5%
side note: i think a spelling error above.. description (not describtion)
 
GREAT WORK BTSdac! :)
kenCode - Decentraliser @ Agorise
Matrix/Keybase/Hive/Commun/Github: @Agorise
www.PalmPay.chat

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
@abit @BTSdac
you both should take a look at this:
http://nvie.com/posts/a-successful-git-branching-model/
it is a very useful branching model that has been used in graphene for quite some time.

If you also want to use it take a look at `git-flow`: https://github.com/nvie/gitflow