Bitcoin Forum
December 09, 2016, 02:11:41 AM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: [PULL] Modularizing bitcoin: CWallet class  (Read 1286 times)
Pieter Wuille
Legendary
*
qt
Offline Offline

Activity: 1036


View Profile WWW
May 23, 2011, 12:39:55 PM
 #1

Hello all,

I've been working on restructuring the bitcoin source code a bit. A first step was splitting off all wallet-handling into a separate class CWallet, so that eventually eg. multiple loaded wallets at the same time are possible, less global variables are needed and in general the dependencies inside the code are improved.

I ended up changing somewhat more than expected, as really a lot of code depended on access to those globals.

A summary:
  • A new class CKeyStore manages private keys, and script.cpp depends on access to CKeyStore.
  • A new class CWallet extends CKeyStore, and contains all former wallet-specific globals; CWallet depends on script.cpp, not the other way around.
  • Wallet-specific functions in CTransaction (GetDebit, GetCredit, GetChange, IsMine, IsFromMe), are moved to CWallet, taking their former 'this' argument as an explicit parameter
  • CWalletTx objects know which CWallet they belong to, for convenience, so they have their own direct (and caching) GetDebit/... functions.
  • Some code was moved between CWalletDB, CWallet and main.
  • Main.cpp keeps a set of all 'registered' wallets, which should be informed about updates to the block chain, and does not have any notion about any 'main' wallet. Function in main.cpp that require a wallet (such as GenerateCoins), take an explicit CWallet* argument.
  • The actual CWallet instance used by the application is defined in init.cpp as "CWallet* pwalletMain". rpc.cpp and ui.cpp use this variable.

The code is here: https://github.com/sipa/bitcoin/tree/walletclass/src

Note that the branch is not yet rebased against the current master, is a work in progress and may have bugs. There should not be any changes to the actual program logic, but segfaults or performance degradations are definitely possible.

Comments are welcome.

aka sipa, core dev team

Tips and donations: 1KwDYMJMS4xq3ZEWYfdBRwYG2fHwhZsipa
1481249501
Hero Member
*
Offline Offline

Posts: 1481249501

View Profile Personal Message (Offline)

Ignore
1481249501
Reply with quote  #2

1481249501
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481249501
Hero Member
*
Offline Offline

Posts: 1481249501

View Profile Personal Message (Offline)

Ignore
1481249501
Reply with quote  #2

1481249501
Report to moderator
1481249501
Hero Member
*
Offline Offline

Posts: 1481249501

View Profile Personal Message (Offline)

Ignore
1481249501
Reply with quote  #2

1481249501
Report to moderator
1481249501
Hero Member
*
Offline Offline

Posts: 1481249501

View Profile Personal Message (Offline)

Ignore
1481249501
Reply with quote  #2

1481249501
Report to moderator
Pieter Wuille
Legendary
*
qt
Offline Offline

Activity: 1036


View Profile WWW
June 01, 2011, 09:28:34 PM
 #2

Pull request is up: https://github.com/bitcoin/bitcoin/pull/288

It seems stable now, i've received and sent (realnet) transactions with it without problems. Feel free to test Smiley

aka sipa, core dev team

Tips and donations: 1KwDYMJMS4xq3ZEWYfdBRwYG2fHwhZsipa
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!