Bitcoin Forum
May 14, 2024, 03:19:12 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Github code  (Read 353 times)
turboblade (OP)
Member
**
Offline Offline

Activity: 115
Merit: 10


View Profile
December 09, 2017, 12:26:02 AM
 #1

Perhaps this is too simplistic for this board, though hopefully you can help me. I'm currently trying to interpret general crypto code, as a basic coder. Is it agreed that bitcoin code is inherently very inefficient. To me it appears much code is duplicated unnecessarily. Ultimately, to me, bitcoin's code is still pre-beta, with minimal comments and few modules.

Can someone please advise which .cpp file states which hashing algorithm, the coin is using. ie what differs between sha265 hashed coin's code vs an equihash.

Take bitcoin gold for example. How does their wallet know how to interpret both equihash and sha265, depending on which block is being interrogated.
Bitgoin gold has significantly more lines of code than bitcoin. Is this purely to allow the blockchain to cope with two completely different hashes?

I can recall older coins changing algorithm over the years, though most did a 1 to 1 swap at an exchange. To me that is cheating. Obviously it cant be done eg Bitgoin gold, though is an algorithm change mid blockchain difficult to implement?
If you see garbage posts (off-topic, trolling, spam, no point, etc.), use the "report to moderator" links. All reports are investigated, though you will rarely be contacted about your reports.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715656752
Hero Member
*
Offline Offline

Posts: 1715656752

View Profile Personal Message (Offline)

Ignore
1715656752
Reply with quote  #2

1715656752
Report to moderator
1715656752
Hero Member
*
Offline Offline

Posts: 1715656752

View Profile Personal Message (Offline)

Ignore
1715656752
Reply with quote  #2

1715656752
Report to moderator
1715656752
Hero Member
*
Offline Offline

Posts: 1715656752

View Profile Personal Message (Offline)

Ignore
1715656752
Reply with quote  #2

1715656752
Report to moderator
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6637


Just writing some code


View Profile WWW
December 28, 2017, 06:12:22 AM
 #2

Is it agreed that bitcoin code is inherently very inefficient.
No, it is not agreed. Firstly, there is no "bitcoin code". There are multiple implementation of the Bitcoin consensus rules. If you are referring to Bitcoin Core, it can sometimes be inefficient but there is nothing inherent about consensus implementations for Bitcoin being inherently inefficient.

To me it appears much code is duplicated unnecessarily.
Bitcoin Core certainly has code duplication, but it is much better than it was in the past and it has become much more efficient.

Ultimately, to me, bitcoin's code is still pre-beta, with minimal comments and few modules.
Bitcoin Core may still be like that, but that is only one implementation.

Can someone please advise which .cpp file states which hashing algorithm, the coin is using. ie what differs between sha265 hashed coin's code vs an equihash.
There is not one place that specifies a hash function that is used; rather every time the hash function is used, the function itself is directly called. It's not like there are some UsePoWHash or UseConsensusHash functions.

The files that you are looking for are probably src/chainparams.cpp, src/validation.cpp, and the files under src/consensus/. However many other source files include consensus related things.

Take bitcoin gold for example. How does their wallet know how to interpret both equihash and sha265, depending on which block is being interrogated.
Presumably there is a swtich. Simply an if statement; if after activation height, use equihash, else use sha256d.

Bitgoin gold has significantly more lines of code than bitcoin. Is this purely to allow the blockchain to cope with two completely different hashes?
Yes.

I can recall older coins changing algorithm over the years, though most did a 1 to 1 swap at an exchange. To me that is cheating. Obviously it cant be done eg Bitgoin gold, though is an algorithm change mid blockchain difficult to implement?
Not necessarily.

washi
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
December 29, 2017, 09:27:30 PM
 #3

Try looking at the Go implementation, it is well commented and "clean":

https://github.com/btcsuite/btcd
Nicor
Newbie
*
Offline Offline

Activity: 9
Merit: 0


View Profile
December 29, 2017, 11:33:53 PM
 #4

its a trade off.

Do you want faster code or more compact executable?

In this app i would not have cared about size, but about speed.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!