mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-04 19:02:28 +00:00
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:
parent
a67728628e
commit
52fa41a12a
26 changed files with 930 additions and 66 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue