<commit_before>package skipservice

/*
The skipservice.go defines what to do for each API-call. This part of the service
runs on the node.
*/

import (
	"encoding/json"
	"errors"
	"sync"
	"time"

	"github.com/nblp/decenarch"
	skipchain "gopkg.in/dedis/cothority.v1/skipchain"

	"gopkg.in/dedis/onet.v1"
	"gopkg.in/dedis/onet.v1/log"
	"gopkg.in/dedis/onet.v1/network"
)

// Used for tests
var templateID onet.ServiceID

func init() {
	var err error
	templateID, err = onet.RegisterNewService(decenarch.SkipServiceName, newService)
	log.ErrFatal(err)
	network.RegisterMessage(&skipstorage{})
}

// Service is our template-service
type SkipService struct {
	// We need to embed the ServiceProcessor, so that incoming messages
	// are correctly handled.
	*onet.ServiceProcessor

	skipstorage *skipstorage
	stopsignal  bool

	data     []decenarch.Webstore
	dataChan chan decenarch.Webstore
}

// skipstorageID reflects the data we're storing - we could store more
// than one structure.
const skipstorageID = "main"

// skipMin is the number of minutes between each block creation
const skipMin = 2

type skipstorage struct {
	sync.Mutex
	LastSkipBlockID skipchain.SkipBlockID
	Skipchain       []*skipchain.SkipBlock
}

// SkipRootStartRequest TODO documentation
func (s *SkipService) SkipRootStartRequest(req *decenarch.SkipRootStartRequest) (*decenarch.SkipRootStartResponse, onet.ClientError) {
	log.Lvl1("SkipRootStartRequest execution")
	skipclient := skipchain.NewClient()
	// here we assume the skipchain will be forwarded to other member of the roster
	skipblock, err := skipclient.CreateGenesis(
		req.Roster,
		2,
		2,
		skipchain.VerificationStandard,
		nil,
		nil)
	if err != nil {<commit_msg>add required todo<commit_after>package skipservice

/*
The skipservice.go defines what to do for each API-call. This part of the service
runs on the node.
*/

import (
	"encoding/json"
	"errors"
	"sync"
	"time"

	"github.com/nblp/decenarch"
	skipchain "gopkg.in/dedis/cothority.v1/skipchain"

	"gopkg.in/dedis/onet.v1"
	"gopkg.in/dedis/onet.v1/log"
	"gopkg.in/dedis/onet.v1/network"
)

// Used for tests
var templateID onet.ServiceID

func init() {
	var err error
	templateID, err = onet.RegisterNewService(decenarch.SkipServiceName, newService)
	log.ErrFatal(err)
	network.RegisterMessage(&skipstorage{})
}

// Service is our template-service
type SkipService struct {
	// We need to embed the ServiceProcessor, so that incoming messages
	// are correctly handled.
	*onet.ServiceProcessor

	skipstorage *skipstorage
	stopsignal  bool

	data     []decenarch.Webstore
	dataChan chan decenarch.Webstore
}

// skipstorageID reflects the data we're storing - we could store more
// than one structure.
const skipstorageID = "main"

// skipMin is the number of minutes between each block creation
// TODO put back to 10
const skipMin = 2

type skipstorage struct {
	sync.Mutex
	LastSkipBlockID skipchain.SkipBlockID
	Skipchain       []*skipchain.SkipBlock
}

// SkipRootStartRequest TODO documentation
func (s *SkipService) SkipRootStartRequest(req *decenarch.SkipRootStartRequest) (*decenarch.SkipRootStartResponse, onet.ClientError) {
	log.Lvl1("SkipRootStartRequest execution")
	skipclient := skipchain.NewClient()
	// here we assume the skipchain will be forwarded to other member of the roster
	skipblock, err := skipclient.CreateGenesis(
		req.Roster,
		2,
		2,
		skipchain.VerificationStandard,
		nil,
		nil)
	if err != nil {
{'fraction_non_alphanumeric': 0.09395973154362416, 'fraction_numerical': 0.005252407353370295, 'mean_word_length': 4.331259720062208, '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': '4302503', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1125, 'n_words': 317}