Persist transactions (#51)

* added account_state + changed ECPoint to PublicKey

* account state persist

* in depth test for existing accounts.

* implemented GetTransaction.

* added enrollment TX

* added persist of accounts and unspent coins

* bumped version -> 0.32.0
This commit is contained in:
Anthony De Meulemeester 2018-03-21 17:11:04 +01:00 committed by GitHub
parent a67728628e
commit 52fa41a12a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 930 additions and 66 deletions

View file

@ -6,6 +6,7 @@ import (
"sort"
"github.com/CityOfZion/neo-go/pkg/core/storage"
"github.com/CityOfZion/neo-go/pkg/core/transaction"
"github.com/CityOfZion/neo-go/pkg/util"
)
@ -65,6 +66,22 @@ func storeAsBlock(batch storage.Batch, block *Block, sysFee uint32) error {
return nil
}
// storeAsTransaction stores the given TX as DataTransaction.
func storeAsTransaction(batch storage.Batch, tx *transaction.Transaction, index uint32) error {
key := storage.AppendPrefix(storage.DataTransaction, tx.Hash().BytesReverse())
buf := new(bytes.Buffer)
if err := tx.EncodeBinary(buf); err != nil {
return err
}
dest := make([]byte, buf.Len()+4)
binary.LittleEndian.PutUint32(dest[:4], index)
copy(dest[4:], buf.Bytes())
batch.Put(key, dest)
return nil
}
// readStoredHeaderHashes returns a sorted list of header hashes
// retrieved from the given Store.
func readStoredHeaderHashes(store storage.Store) ([]util.Uint256, error) {