WitnessAnchorData only needs to store one witness per JSOutPoint.

This commit is contained in:
Simon
2016-12-07 12:05:29 -08:00
parent 2d931e905b
commit 84e8c5f921
2 changed files with 5 additions and 8 deletions

View File

@@ -331,7 +331,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
uint256 inputAnchor; uint256 inputAnchor;
std::vector<boost::optional<ZCIncrementalWitness>> vInputWitnesses; std::vector<boost::optional<ZCIncrementalWitness>> vInputWitnesses;
pwalletMain->GetNoteWitnesses(vOutPoints, vInputWitnesses, inputAnchor); pwalletMain->GetNoteWitnesses(vOutPoints, vInputWitnesses, inputAnchor);
jsopWitnessAnchorMap[ jso.ToString() ] = WitnessAnchorData{ vInputWitnesses, inputAnchor }; jsopWitnessAnchorMap[ jso.ToString() ] = WitnessAnchorData{ vInputWitnesses[0], inputAnchor };
} }
} }
@@ -587,7 +587,6 @@ bool AsyncRPCOperation_sendmany::main_impl() {
std::vector<JSOutPoint> vOutPoints; std::vector<JSOutPoint> vOutPoints;
std::vector<boost::optional<ZCIncrementalWitness>> vInputWitnesses; std::vector<boost::optional<ZCIncrementalWitness>> vInputWitnesses;
uint256 inputAnchor; uint256 inputAnchor;
WitnessAnchorData wad;
int numInputsNeeded = (jsChange>0) ? 1 : 0; int numInputsNeeded = (jsChange>0) ? 1 : 0;
while (numInputsNeeded++ < ZC_NUM_JS_INPUTS && zInputsDeque.size() > 0) { while (numInputsNeeded++ < ZC_NUM_JS_INPUTS && zInputsDeque.size() > 0) {
SendManyInputJSOP t = zInputsDeque.front(); SendManyInputJSOP t = zInputsDeque.front();
@@ -596,10 +595,8 @@ bool AsyncRPCOperation_sendmany::main_impl() {
CAmount noteFunds = std::get<2>(t); CAmount noteFunds = std::get<2>(t);
zInputsDeque.pop_front(); zInputsDeque.pop_front();
wad = jsopWitnessAnchorMap[ jso.ToString() ]; WitnessAnchorData wad = jsopWitnessAnchorMap[ jso.ToString() ];
for (auto & w : wad.witnesses) { vInputWitnesses.push_back(wad.witness);
vInputWitnesses.push_back(w);
}
if (inputAnchor.IsNull()) { if (inputAnchor.IsNull()) {
inputAnchor = wad.anchor; inputAnchor = wad.anchor;
} else if (inputAnchor != wad.anchor) { } else if (inputAnchor != wad.anchor) {

View File

@@ -42,9 +42,9 @@ struct AsyncJoinSplitInfo
CAmount vpub_new = 0; CAmount vpub_new = 0;
}; };
// A struct to help us track the witnesses and anchor for a given JSOutPoint // A struct to help us track the witness and anchor for a given JSOutPoint
struct WitnessAnchorData { struct WitnessAnchorData {
std::vector<boost::optional<ZCIncrementalWitness>> witnesses; boost::optional<ZCIncrementalWitness> witness;
uint256 anchor; uint256 anchor;
}; };