Beispiel #1
0
bool Data::isInitialized() const
{
  // if sinks to data have no connections, 
  // then nothing is feeding into them
  if (sinks().size() == 0) {
    return true; // no sinks so it is required to be init
  }
  if (sinks()[0]->isConnected()) {
    return false;
  }
  return true;
}
Beispiel #2
0
ProgramStrings Print::flatten() const
{
  if (isVisited()){
    return ProgramStrings();
  }
  
  setVisited(true);
 
  ProgramStrings prog;
  
  foreach(Sink *sink, sinks()){
    Data* sinkData = sink->sourceData();
    //ps += sinkData->flatten();
    prog = prog + sinkData->flatten();
  }
Beispiel #3
0
std::shared_ptr<spdlog::logger> getLogger(std::string const& name)
{
  auto logger = spdlog::get(name);
  if(!logger) {
    auto default_logger = spdlog::get("");
    if(!default_logger) {
      throw std::logic_error("no default logger");
    }
    auto const& sinks = default_logger->sinks();
    logger = std::make_shared<spdlog::logger>(name, sinks.begin(), sinks.end());
    spdlog::register_logger(logger);
    logger->set_level(default_logger->level());
  }
  return logger;
}
Beispiel #4
0
void SecretShareFile(int threshold, int nShares, const char *filename, const char *seed)
{
	assert(nShares<=1000);
	RandomPool rng;
	rng.IncorporateEntropy((byte *)seed, strlen(seed));
	ChannelSwitch *channelSwitch;
	string data = "ABCDABCD";
	//FileSource source(filename, false, new SecretSharing(rng, threshold, nShares, channelSwitch = new ChannelSwitch));
	ArraySource source((byte *)data.c_str(), data.length() + 4, false, new SecretSharing(rng, threshold, nShares, channelSwitch = new ChannelSwitch));
	std::vector<string> buf(nShares);
	/*SecretSharing *sss = new SecretSharing(rng, threshold, nShares, channelSwitch = new ChannelSwitch);
	string pt = "abcd";
	const unsigned char *c = (const unsigned char*) pt.c_str();
	sss->Put(c, 5, true);
	sss->MessageEnd(-1, true);
	bool mesgs = sss->AnyMessages();
	cout<<mesgs<<endl;
	lword max_ret = sss->MaxRetrievable();
	cout<<max_ret<<endl;
	*/
	vector_member_ptrs<FileSink> fileSinks(nShares);
	vector_member_ptrs<ArraySink> sinks(nShares);
	string channel;
	for (int i=0; i<nShares; i++)
	{
		char extension[5] = ".000";
		extension[1]='0'+byte(i/100);
		extension[2]='0'+byte((i/10)%10);
		extension[3]='0'+byte(i%10);
		fileSinks[i].reset(new FileSink((string(filename)+extension).c_str()));
		sinks[i].reset(new ArraySink((byte *) buf.at(i).c_str(), buf.at(i).length()));
		channel = WordToString<word32>(i);
		//cout<<channel.data()<<endl;
		//fileSinks[i]->Put((byte *)channel.data(), 4);
		sinks[i]->Put((byte *) channel.data(), 4);
		//channelSwitch->AddRoute(channel, *fileSinks[i], DEFAULT_CHANNEL);
		channelSwitch->AddRoute(channel, *sinks[i], DEFAULT_CHANNEL);
	}
	//istream *is = source.GetStream();
	//cout<<is->rdbuf();
	/*char cs = is->get();
	while(is) {
		//cout<<cs;
		cs = is->get();
	}*/
	source.PumpAll();
	cout<<buf.at(0)<<endl;
}