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

View file

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