This commit is contained in:
Owain G. Ainsworth 2013-12-17 14:02:35 +00:00
parent 8310661c29
commit d72255bce3
2 changed files with 20 additions and 22 deletions

View file

@ -82,9 +82,9 @@ const (
// metadata we store about it.
type TxDesc struct {
Tx *btcutil.Tx // Transaction.
Added time.Time // Time when added to pool.
Height int64 // Blockheight when added to pool.
Fee int64 // Transaction fees.
Added time.Time // Time when added to pool.
Height int64 // Blockheight when added to pool.
Fee int64 // Transaction fees.
}
// txMemPool is used as a source of transactions that need to be mined into
@ -640,10 +640,10 @@ func (mp *txMemPool) addTransaction(tx *btcutil.Tx, height, fee int64) {
// Add the transaction to the pool and mark the referenced outpoints
// as spent by the pool.
mp.pool[*tx.Sha()] = &TxDesc{
Tx: tx,
Added: time.Now(),
Tx: tx,
Added: time.Now(),
Height: height,
Fee: fee,
Fee: fee,
}
for _, txIn := range tx.MsgTx().TxIn {
mp.outpoints[txIn.PreviousOutpoint] = tx

View file

@ -871,14 +871,13 @@ func handleGetPeerInfo(s *rpcServer, cmd btcjson.Cmd, walletNotification chan []
}
type mempoolDescriptor struct {
Size int `json:"size"`
Fee int64 `json:"fee"`
Time int64 `json:"time"`
Height int64 `json:"height"`
StartingPriority int `json:"startingpriority"`
CurrentPriority int `json:"currentpriority"`
Depends []string `json:"depends"`
Size int `json:"size"`
Fee int64 `json:"fee"`
Time int64 `json:"time"`
Height int64 `json:"height"`
StartingPriority int `json:"startingpriority"`
CurrentPriority int `json:"currentpriority"`
Depends []string `json:"depends"`
}
// handleGetRawMempool implements the getrawmempool command.
@ -890,12 +889,12 @@ func handleGetRawMempool(s *rpcServer, cmd btcjson.Cmd, walletNotification chan
result := make(map[string]*mempoolDescriptor, len(descs))
for _, desc := range descs {
mpd := &mempoolDescriptor{
Size: desc.Tx.MsgTx().SerializeSize(),
Fee: desc.Fee,
Time: desc.Added.Unix(),
Height: desc.Height,
Size: desc.Tx.MsgTx().SerializeSize(),
Fee: desc.Fee,
Time: desc.Added.Unix(),
Height: desc.Height,
StartingPriority: 0, // We don't mine.
CurrentPriority: 0, // We don't mine.
CurrentPriority: 0, // We don't mine.
}
for _, txIn := range desc.Tx.MsgTx().TxIn {
hash := &txIn.PreviousOutpoint.Hash
@ -908,14 +907,13 @@ func handleGetRawMempool(s *rpcServer, cmd btcjson.Cmd, walletNotification chan
result[desc.Tx.Sha().String()] = mpd
}
return result, nil
return result, nil
}
hashStrings := make([]string, len(descs))
for i := range(hashStrings) {
for i := range hashStrings {
hashStrings[i] = descs[i].Tx.Sha().String()
}
return hashStrings, nil
}