BitShares Forum
Main => General Discussion => Topic started by: BTSdac on February 15, 2016, 03:20:12 pm
-
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
-
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!
-
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!!
-
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.
-
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.
-
@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
-
Dividend feature
Features:
Pay a dividend ...
...
"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! :)
-
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.
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.
-
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"
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:
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):
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:
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
-
Dividend feature
Features:
Pay a dividend ...
...
"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?
-
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 :)
-
+5% +5% +5%
-
Great!
But you really need to do performance testing. AFAIR performance was the main reason for using buybacks instead of proper dividends.
-
Very important function +5% +5% +5%
-
Very cool :D
-
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!
-
awesome +5% +5% +5%
-
Great job! +5% +5% +5%
-
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.
-
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.
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