<commit_before>// SPDX-License-Identifier: ISC
// Copyright (c) 2014-2019 Bitmark Inc.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package reservoir

import (
	"bytes"
	"encoding/binary"
	"fmt"
	"os"

	"github.com/bitmark-inc/bitmarkd/asset"
	"github.com/bitmark-inc/bitmarkd/fault"
	"github.com/bitmark-inc/bitmarkd/mode"
	"github.com/bitmark-inc/bitmarkd/pay"
	"github.com/bitmark-inc/bitmarkd/storage"
	"github.com/bitmark-inc/bitmarkd/transactionrecord"
	"github.com/bitmark-inc/logger"
)

type tagType byte

// record types in cache file
const (
	taggedBOF         tagType = iota
	taggedEOF         tagType = iota
	taggedTransaction tagType = iota
	taggedProof       tagType = iota
)

// the BOF tag to chec file version
// exact match is required
var bofData = []byte("bitmark-cache v1.0")

// Handles - storage handles used when restore from cache file
type Handles struct {
	Assets            storage.Handle
	BlockOwnerPayment storage.Handle
	Transaction       storage.Handle
	OwnerTx           storage.Handle
	OwnerData         storage.Handle
	Share             storage.Handle
	ShareQuantity     storage.Handle
}

// LoadFromFile - load transactions from file
// called later when system is able to handle the tx and proofs
func LoadFromFile(handles Handles) error {
	Disable()
	defer Enable()

	log := globalData.log

	log.Info("starting…")

	f, err := os.Open(globalData.filename)
	if nil != err {
		return err
	}<commit_msg>[reservoir] fix spelling<commit_after>// SPDX-License-Identifier: ISC
// Copyright (c) 2014-2019 Bitmark Inc.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package reservoir

import (
	"bytes"
	"encoding/binary"
	"fmt"
	"os"

	"github.com/bitmark-inc/bitmarkd/asset"
	"github.com/bitmark-inc/bitmarkd/fault"
	"github.com/bitmark-inc/bitmarkd/mode"
	"github.com/bitmark-inc/bitmarkd/pay"
	"github.com/bitmark-inc/bitmarkd/storage"
	"github.com/bitmark-inc/bitmarkd/transactionrecord"
	"github.com/bitmark-inc/logger"
)

type tagType byte

// record types in cache file
const (
	taggedBOF         tagType = iota
	taggedEOF         tagType = iota
	taggedTransaction tagType = iota
	taggedProof       tagType = iota
)

// the BOF tag to check file version
// exact match is required
var bofData = []byte("bitmark-cache v1.0")

// Handles - storage handles used when restore from cache file
type Handles struct {
	Assets            storage.Handle
	BlockOwnerPayment storage.Handle
	Transaction       storage.Handle
	OwnerTx           storage.Handle
	OwnerData         storage.Handle
	Share             storage.Handle
	ShareQuantity     storage.Handle
}

// LoadFromFile - load transactions from file
// called later when system is able to handle the tx and proofs
func LoadFromFile(handles Handles) error {
	Disable()
	defer Enable()

	log := globalData.log

	log.Info("starting…")

	f, err := os.Open(globalData.filename)
	if nil != err {
		return err
	}
{'fraction_non_alphanumeric': 0.09612817089452604, 'fraction_numerical': 0.006675567423230975, 'mean_word_length': 3.2033660589060307, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1640958', 'n_tokens_mistral': 999, 'n_tokens_neox': 953, 'n_words': 278}