Bitcoin Forum
May 24, 2024, 03:31:14 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 [34] 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 »
661  Alternate cryptocurrencies / Announcements (Altcoins) / Re: Nxt :: descendant of Bitcoin - Updated Information on: January 03, 2014, 02:24:14 PM
75. it is 75 million. In only one of the accounts.
And if everyone who hold their Nxt in dgex tries to withdraw... Dgex will get 75M * 1.4%.
662  Alternate cryptocurrencies / Altcoin Discussion / Re: Nxt source code flaw reports on: January 03, 2014, 02:18:56 PM
Edit: I can't explain why, coz I can leak info about a flaw accidentally, sorry.
Let me guess, we need to add amount -= transaction.amount when transaction.senderPublicKey is equals to publicKey?
I mean loop in Account.getEffectiveBalance() method.

It can be wrong assumption because I still doesn't understand well what is effective balance Smiley
663  Alternate cryptocurrencies / Altcoin Discussion / Re: Nxt source code analysis (QA) on: January 03, 2014, 01:58:52 PM
I didn't know that, are you sure? From the java source of ConcurrentHashMap, which Nxt.peers already is in 0.4.9e:
You are right, values backed by the map.
Hmm, I remember the times when values() return copy of map. Or my memory is very bad...
664  Alternate cryptocurrencies / Altcoin Discussion / Re: Nxt source code analysis (QA) on: January 03, 2014, 01:53:15 PM
Just make sure you don't give him/them the whole 0.4.9e code in this topic!   Wink
I have no time to be full-time Nxt core developer Sad
665  Alternate cryptocurrencies / Altcoin Discussion / Re: Nxt source code flaw reports on: January 03, 2014, 01:52:35 PM
6821 lines java class?. THAT is more than a fatal flaw.

Looking at the code is giving me a headache. Angry
It's not a problem with any modern IDE. Just use code folding.
666  Alternate cryptocurrencies / Altcoin Discussion / Re: Nxt source code analysis (QA) on: January 03, 2014, 01:49:14 PM
I hope you already remove "double copy"
Code:
peers = ((HashMap<String, Peer>)Nxt.peers.clone()).values();
from thread, which is start every second Smiley
667  Alternate cryptocurrencies / Altcoin Discussion / Re: Nxt source code analysis (QA) on: January 03, 2014, 01:47:19 PM
My replacement of the same lines in getAnyPeer, already in 0.4.9e:
Code:
            List<Peer> selectedPeers = new ArrayList<Peer>();

            for (Peer peer : Nxt.peers.values()) {

                if (peer.blacklistingTime <= 0 && peer.state == state && peer.announcedAddress.length() > 0
                        && (!applyPullThreshold || !enableHallmarkProtection || peer.getWeight() >= pullThreshold)) {

                    selectedPeers.add(peer);

                }

            }

AFAIR, HashMap.values() make a copy, while HashMap.entrySet() definitely not.
So my variant is even better. You sync in peers anyway, so it is safe.
668  Alternate cryptocurrencies / Altcoin Discussion / Re: Nxt source code analysis (QA) on: January 03, 2014, 01:44:49 PM
This proves u r not BCNext. Ur and his logic r completely different!
I am from generation "640k is enough" Smiley So I dislike such memory copies.
669  Alternate cryptocurrencies / Altcoin Discussion / Re: Nxt source code analysis (QA) on: January 03, 2014, 01:42:34 PM
Keep digging, I am still a step ahead. Smiley
Two step ahead (0.4.8 and 0.4.9), and I hope you start to do third step already Smiley
670  Alternate cryptocurrencies / Altcoin Discussion / Re: Nxt source code flaw reports on: January 03, 2014, 01:39:58 PM
Three is only one file which is a 6812 lies Nxt.java.
It is not a news for those who tries to decompile it since first version Smiley
671  Alternate cryptocurrencies / Altcoin Discussion / Re: Nxt source code analysis (QA) on: January 03, 2014, 01:38:15 PM
Relax, I am also using IntelliJ. And the above has been fixed in 0.4.9e.

I have fixed, I hope, the synchronization issues related to Blocks and Transactions in 0.4.9e. The synchronization in Accounts is on my TODO list for the next version.

Good news!
Okey, let me find something really interesting...
672  Alternate cryptocurrencies / Altcoin Discussion / Re: Nxt source code analysis (QA) on: January 03, 2014, 01:37:00 PM
Okey, let me rewrite something Smiley

Code:
        static Peer getAnyPeer(int state, boolean applyPullThreshold) {

            synchronized (peers) {

                Collection<Peer> peers = ((HashMap<String, Peer>)Nxt.peers.clone()).values();
                Iterator<Peer> iterator = peers.iterator();
                while (iterator.hasNext()) {

                    Peer peer = iterator.next();
                    if (peer.blacklistingTime > 0 || peer.state != state || peer.announcedAddress.length() == 0 || (applyPullThreshold && enableHallmarkProtection && peer.getWeight() < pullThreshold)) {

                        iterator.remove();

                    }

                }

                if (peers.size() > 0) {

                    Peer[] selectedPeers = peers.toArray(new Peer[0]);
...

For memory usage I prefer to code like this:

Code:
                List<Peer> selectedPeers = new ArrayList<>();
                for (Map.Entry<String, Peer> entry : peers.entrySet()) {
                    Peer peer = entry.getValue();
                    if (peer.blacklistingTime <= 0 && peer.state == state && peer.announcedAddress.length() != 0 && ((!applyPullThreshold || !enableHallmarkProtection || peer.getWeight() >= pullThreshold))) {
                        selectedPeers.add(peer);
                    }
                }

And even more, List selectedPeers can be reused, if used only in this method.
673  Alternate cryptocurrencies / Altcoin Discussion / Re: Nxt source code analysis (QA) on: January 03, 2014, 01:22:21 PM
One more thanks to IDEA: line 6533, peer can be null. At least there's check for null above and below, but not here.
674  Alternate cryptocurrencies / Altcoin Discussion / Re: Nxt source code analysis (QA) on: January 03, 2014, 01:14:05 PM
Small suggestion on usage of Collection.toArray().
I see a lot of calls like
Code:
peers.toArray(new Peer[0])
1. It is completely useless and equal to simple toArray() call.
2. It is better in terms of speed and memory usage to code like this:
Code:
peers.toArray(new Peer[peers.size()])
675  Alternate cryptocurrencies / Altcoin Discussion / Re: Nxt source code flaw reports on: January 03, 2014, 01:03:29 PM
Do you accept any suggestions here, or flaws only?
What if I found some potentially bad code?

Only flaws, feel free to create another thread for suggestions and post link here.

Source code analysis (QA).

Feel free everyone to post you suggestions there.
676  Alternate cryptocurrencies / Altcoin Discussion / Nxt source code analysis (QA) on: January 03, 2014, 01:01:42 PM
While lurking for injected bugs, I found that some parts of Nxt code makes my eyes bleed. With hope that I have enough programming skills (probably better, than my runglish Smiley ), I'm starting this thread. Not for bounty, but for better quality (but donations welcome, as usual Smiley ).

First of all, thanks to IntelliJ IDEA code analysis, I see a lot of syncronized with potentially wrong usage.
Static variables like peers, blocks, accounts, users are not final. They are initialized at start, so it is not a big flaw right now, but who knows about future.
When I look more deeply in syncronizations, I see a lot of places, where author get content of such global collection and then sync on it, but not sync on collection itself. Example:
Code:
Block.analyse() method:

Account generatorAccount = accounts.get(Account.getId(generatorPublicKey));
synchronized (generatorAccount) {
    generatorAccount.setBalance(generatorAccount.balance + totalFee * 100L);
    generatorAccount.setUnconfirmedBalance(generatorAccount.unconfirmedBalance + totalFee * 100L);
}
While in some places such usage may be safe, I think it's very bad practice anyway.

More to come...
677  Alternate cryptocurrencies / Altcoin Discussion / Re: Nxt source code flaw reports on: January 03, 2014, 12:31:09 PM
Do you accept any suggestions here, or flaws only?
What if I found some potentially bad code?
678  Alternate cryptocurrencies / Announcements (Altcoins) / Re: Nxt :: descendant of Bitcoin - Updated Information on: January 03, 2014, 12:24:47 PM
Hey devs, I need thread where I will start to complain to sources? Cheesy Not for bounty, but for pleasure.
679  Alternate cryptocurrencies / Announcements (Altcoins) / Re: Nxt :: descendant of Bitcoin - Updated Information on: January 03, 2014, 12:01:52 PM
I did my two week audition, I guess I failed.
Maybe you're coming too early with your ideas.
680  Alternate cryptocurrencies / Announcements (Altcoins) / Re: Nxt :: descendant of Bitcoin - Updated Information on: January 03, 2014, 11:53:22 AM
Unfortunately due to the lack of support from the founders, with the exception of aldrin, I am forced to say goodbye.
James, you definitely need to start separate thread with your ideas. This thread is a flood of everything about Nxt, from deep techinfo to asking for donations.
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 [34] 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 »
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!