remove storage of pkscript; don't need it.
This commit is contained in:
parent
278971936f
commit
b7a2c46ea6
@ -30,11 +30,12 @@ type TxStore struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Utxo struct { // cash money.
|
type Utxo struct { // cash money.
|
||||||
// combo of outpoint and txout which has all the info needed to spend
|
// all the info needed to spend
|
||||||
AtHeight int32 // block height where this tx was confirmed, 0 for unconf
|
AtHeight int32 // block height where this tx was confirmed, 0 for unconf
|
||||||
KeyIdx uint32 // index for private key needed to sign / spend
|
KeyIdx uint32 // index for private key needed to sign / spend
|
||||||
Op wire.OutPoint // where
|
Value int64 // higher is better
|
||||||
Txo wire.TxOut // what
|
|
||||||
|
Op wire.OutPoint // where
|
||||||
}
|
}
|
||||||
|
|
||||||
type MyAdr struct { // an address I have the private key for
|
type MyAdr struct { // an address I have the private key for
|
||||||
@ -118,7 +119,7 @@ func (t *TxStore) AbsorbTx(tx *wire.MsgTx, height int32) error {
|
|||||||
var newu Utxo
|
var newu Utxo
|
||||||
newu.AtHeight = height
|
newu.AtHeight = height
|
||||||
newu.KeyIdx = a.KeyIdx
|
newu.KeyIdx = a.KeyIdx
|
||||||
newu.Txo = *out
|
newu.Value = out.Value
|
||||||
|
|
||||||
var newop wire.OutPoint
|
var newop wire.OutPoint
|
||||||
newop.Hash = tx.TxSha()
|
newop.Hash = tx.TxSha()
|
||||||
@ -150,7 +151,7 @@ func (t *TxStore) ExpellTx(tx *wire.MsgTx, height int32) error {
|
|||||||
for i, myutxo := range t.Utxos {
|
for i, myutxo := range t.Utxos {
|
||||||
if myutxo.Op == in.PreviousOutPoint {
|
if myutxo.Op == in.PreviousOutPoint {
|
||||||
hits++
|
hits++
|
||||||
loss += myutxo.Txo.Value
|
loss += myutxo.Value
|
||||||
err := t.MarkSpent(&myutxo.Op, height, tx)
|
err := t.MarkSpent(&myutxo.Op, height, tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -171,13 +171,7 @@ func (u *Utxo) ToBytes() ([]byte, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// write 8 byte amount of money at the utxo
|
// write 8 byte amount of money at the utxo
|
||||||
err = binary.Write(&buf, binary.BigEndian, u.Txo.Value)
|
err = binary.Write(&buf, binary.BigEndian, u.Value)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// write variable length (usually like 25 byte) pkscript
|
|
||||||
_, err = buf.Write(u.Txo.PkScript)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -218,11 +212,9 @@ func UtxoFromBytes(b []byte) (Utxo, error) {
|
|||||||
return u, err
|
return u, err
|
||||||
}
|
}
|
||||||
// read 8 byte amount of money at the utxo
|
// read 8 byte amount of money at the utxo
|
||||||
err = binary.Read(buf, binary.BigEndian, &u.Txo.Value)
|
err = binary.Read(buf, binary.BigEndian, &u.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return u, err
|
return u, err
|
||||||
}
|
}
|
||||||
// read variable length (usually like 25 byte) pkscript
|
|
||||||
u.Txo.PkScript = buf.Bytes()
|
|
||||||
return u, nil
|
return u, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user