<commit_before>package main

import (
	"fmt"
	"github.com/ethereum/eth-go/ethchain"
	"github.com/ethereum/eth-go/ethpub"
	"github.com/ethereum/eth-go/ethreact"
	"github.com/ethereum/eth-go/ethutil"
	"github.com/go-qml/qml"
)

type AppContainer interface {
	Create() error
	Destroy()

	Window() *qml.Window
	Engine() *qml.Engine

	NewBlock(*ethchain.Block)
	ObjectChanged(*ethchain.StateObject)
	StorageChanged(*ethchain.StorageState)
	NewWatcher(chan bool)
}

type ExtApplication struct {
	*ethpub.PEthereum

	blockChan       chan ethreact.Event
	changeChan      chan ethreact.Event
	quitChan        chan bool
	watcherQuitChan chan bool

	container        AppContainer
	lib              *UiLib
	registeredEvents []string
}

func NewExtApplication(container AppContainer, lib *UiLib) *ExtApplication {
	app := &ExtApplication{
		ethpub.NewPEthereum(lib.eth),
		make(chan ethreact.Event, 100),
		make(chan ethreact.Event, 100),
		make(chan bool),
		make(chan bool),
		container,
		lib,
		nil,
	}

	return app
}

func (app *ExtApplication) run() {
	// Set the "eth" api on to the containers context
	context := app.container.Engine().Context()
	context.SetVar("eth", app)
	context.SetVar("ui", app.lib)

	err := app.container.Create()
	if err != nil {
		fmt.Println(err)

		return
	}

	// Call the main loop
	go app.mainLoop()

	// Subscribe to events<commit_msg>use logger instead of fmt for error in ext_app<commit_after>package main

import (
	"github.com/ethereum/eth-go/ethchain"
	"github.com/ethereum/eth-go/ethpub"
	"github.com/ethereum/eth-go/ethreact"
	"github.com/ethereum/eth-go/ethutil"
	"github.com/go-qml/qml"
)

type AppContainer interface {
	Create() error
	Destroy()

	Window() *qml.Window
	Engine() *qml.Engine

	NewBlock(*ethchain.Block)
	ObjectChanged(*ethchain.StateObject)
	StorageChanged(*ethchain.StorageState)
	NewWatcher(chan bool)
}

type ExtApplication struct {
	*ethpub.PEthereum

	blockChan       chan ethreact.Event
	changeChan      chan ethreact.Event
	quitChan        chan bool
	watcherQuitChan chan bool

	container        AppContainer
	lib              *UiLib
	registeredEvents []string
}

func NewExtApplication(container AppContainer, lib *UiLib) *ExtApplication {
	app := &ExtApplication{
		ethpub.NewPEthereum(lib.eth),
		make(chan ethreact.Event, 100),
		make(chan ethreact.Event, 100),
		make(chan bool),
		make(chan bool),
		container,
		lib,
		nil,
	}

	return app
}

func (app *ExtApplication) run() {
	// Set the "eth" api on to the containers context
	context := app.container.Engine().Context()
	context.SetVar("eth", app)
	context.SetVar("ui", app.lib)

	err := app.container.Create()
	if err != nil {
		logger.Errorln(err)
		return
	}

	// Call the main loop
	go app.mainLoop()

	// Subscribe to events
{'fraction_non_alphanumeric': 0.12008733624454149, 'fraction_numerical': 0.004366812227074236, 'mean_word_length': 3.8228070175438598, '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': '4358979', 'n_tokens_mistral': 1025, 'n_tokens_neox': 951, 'n_words': 216}