Remove CWalletTx::vfSpent

Use the spent outpoint multimap to figure out which wallet transaction
outputs are unspent, instead of a vfSpent array that is saved
to disk.
This commit is contained in:
Gavin Andresen
2014-02-15 16:38:28 -05:00
parent a16ad1c0f4
commit 93a18a3650
15 changed files with 356 additions and 362 deletions

View File

@@ -8,6 +8,8 @@ if [ $# -lt 1 ]; then
exit 1
fi
set -f
BITCOIND=${1}/bitcoind
CLI=${1}/bitcoin-cli
@@ -19,40 +21,40 @@ if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
D=$(mktemp -d test.XXXXX)
D1=${D}/node1
CreateDataDir $D1 port=11000 rpcport=11001
CreateDataDir "$D1" port=11000 rpcport=11001
B1ARGS="-datadir=$D1"
$BITCOIND $B1ARGS &
B1PID=$!
D2=${D}/node2
CreateDataDir $D2 port=11010 rpcport=11011 connect=127.0.0.1:11000
CreateDataDir "$D2" port=11010 rpcport=11011 connect=127.0.0.1:11000
B2ARGS="-datadir=$D2"
$BITCOIND $B2ARGS &
B2PID=$!
D3=${D}/node3
CreateDataDir $D3 port=11020 rpcport=11021 connect=127.0.0.1:11000
CreateDataDir "$D3" port=11020 rpcport=11021 connect=127.0.0.1:11000
B3ARGS="-datadir=$D3"
$BITCOIND $BITCOINDARGS $B3ARGS &
B3PID=$!
trap "kill -9 $B1PID $B2PID $B3PID; rm -rf $D" EXIT
# Wait until all three nodes are at the same block number
function WaitBlocks {
while :
do
sleep 1
BLOCKS1=$( GetBlocks $B1ARGS )
BLOCKS2=$( GetBlocks $B2ARGS )
BLOCKS3=$( GetBlocks $B3ARGS )
if (( $BLOCKS1 == $BLOCKS2 && $BLOCKS2 == $BLOCKS3 ))
declare -i BLOCKS1=$( GetBlocks $B1ARGS )
declare -i BLOCKS2=$( GetBlocks $B2ARGS )
declare -i BLOCKS3=$( GetBlocks $B3ARGS )
if (( BLOCKS1 == BLOCKS2 && BLOCKS2 == BLOCKS3 ))
then
break
fi
done
}
echo "Generating test blockchain..."
# 1 block, 50 XBT each == 50 XBT
$CLI $B1ARGS setgenerate true 1
WaitBlocks
@@ -60,8 +62,8 @@ WaitBlocks
$CLI $B2ARGS setgenerate true 101
WaitBlocks
CheckBalance $B1ARGS 50
CheckBalance $B2ARGS 50
CheckBalance "$B1ARGS" 50
CheckBalance "$B2ARGS" 50
# Send 21 XBT from 1 to 3. Second
# transaction will be child of first, and
@@ -80,25 +82,25 @@ WaitBlocks
# B1 should end up with 100 XBT in block rewards plus fees,
# minus the 21 XBT sent to B3:
CheckBalance $B1ARGS "100-21"
CheckBalance $B3ARGS "21"
CheckBalance "$B1ARGS" "100-21"
CheckBalance "$B3ARGS" "21"
# B1 should have two unspent outputs; create a couple
# of raw transactions to send them to B3, submit them through
# B2, and make sure both B1 and B3 pick them up properly:
RAW1=$(CreateTxn1 $B1ARGS 1 $(Address $B3ARGS "from1" ) )
RAW2=$(CreateTxn1 $B1ARGS 2 $(Address $B3ARGS "from1" ) )
RAWTXID1=$(SendRawTxn $B2ARGS $RAW1)
RAWTXID2=$(SendRawTxn $B2ARGS $RAW2)
RAWTXID1=$(SendRawTxn "$B2ARGS" $RAW1)
RAWTXID2=$(SendRawTxn "$B2ARGS" $RAW2)
# Have B2 mine a block to confirm transactions:
$CLI $B2ARGS setgenerate true 1
WaitBlocks
# Check balances after confirmation
CheckBalance $B1ARGS 0
CheckBalance $B3ARGS 100
CheckBalance $B3ARGS "100-21" "from1"
CheckBalance "$B1ARGS" 0
CheckBalance "$B3ARGS" 100
CheckBalance "$B3ARGS" "100-21" "from1"
$CLI $B3ARGS stop > /dev/null 2>&1
wait $B3PID
@@ -108,6 +110,5 @@ $CLI $B1ARGS stop > /dev/null 2>&1
wait $B1PID
echo "Tests successful, cleaning up"
trap "" EXIT
rm -rf $D
exit 0