@ -33,6 +33,9 @@ import java.io.InputStreamReader;
import java.io.PrintStream ;
import java.nio.charset.StandardCharsets ;
import java.nio.file.Path ;
import java.util.ArrayList ;
import java.util.List ;
import java.util.Stack ;
import com.fasterxml.jackson.core.JsonParser.Feature ;
import com.fasterxml.jackson.core.JsonProcessingException ;
@ -47,7 +50,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory ;
import picocli.CommandLine ;
import picocli.CommandLine.Command ;
import picocli.CommandLine.IParameterConsumer ;
import picocli.CommandLine.Model.ArgSpec ;
import picocli.CommandLine.Model.CommandSpec ;
import picocli.CommandLine.Option ;
import picocli.CommandLine.Parameters ;
import picocli.CommandLine.ParentCommand ;
@Command (
name = COMMAND_NAME ,
@ -81,6 +89,12 @@ public class B11rSubCommand implements Runnable {
description = "The ommers for the block" )
private final Path ommers = stdinPath ;
@Option (
names = { "--input.withdrawals" } ,
paramLabel = "full path" ,
description = "The withdrawals for the block" )
private final Path withdrawals = stdinPath ;
@Option (
names = { "--seal.clique" } ,
paramLabel = "full path" ,
@ -114,7 +128,25 @@ public class B11rSubCommand implements Runnable {
private static final ObjectMapper objectMapper = new ObjectMapper ( ) ;
@CommandLine.ParentCommand private final EvmToolCommand parentCommand ;
@ParentCommand private final EvmToolCommand parentCommand ;
@Parameters ( parameterConsumer = OnlyEmptyParams . class )
@SuppressWarnings ( "UnusedVariable" )
private final List < String > parameters = new ArrayList < > ( ) ;
static class OnlyEmptyParams implements IParameterConsumer {
@Override
public void consumeParameters (
final Stack < String > args , final ArgSpec argSpec , final CommandSpec commandSpec ) {
while ( ! args . isEmpty ( ) ) {
if ( ! args . pop ( ) . isEmpty ( ) ) {
throw new CommandLine . ParameterException (
argSpec . command ( ) . commandLine ( ) ,
"The block-builder command does not accept any non-empty parameters" ) ;
}
}
}
}
@SuppressWarnings ( "unused" )
public B11rSubCommand ( ) {
@ -136,7 +168,7 @@ public class B11rSubCommand implements Runnable {
. withSpacesInObjectEntries ( )
. withObjectIndenter ( DefaultIndenter . SYSTEM_LINEFEED_INSTANCE . withIndent ( " " ) )
. withArrayIndenter ( DefaultIndenter . SYSTEM_LINEFEED_INSTANCE . withIndent ( " " ) ) ) ;
final ObjectReader t8n Reader = objectMapper . reader ( ) ;
final ObjectReader b11r Reader = objectMapper . reader ( ) ;
objectMapper . disable ( Feature . AUTO_CLOSE_SOURCE ) ;
ObjectNode config ;
@ -144,32 +176,39 @@ public class B11rSubCommand implements Runnable {
if ( header . equals ( stdinPath )
| | txs . equals ( stdinPath )
| | ommers . equals ( stdinPath )
| | sealClique . equals ( stdinPath ) ) {
| | sealClique . equals ( stdinPath )
| | withdrawals . equals ( stdinPath ) ) {
config =
( ObjectNode )
t8nReader . readTree ( new InputStreamReader ( parentCommand . in , StandardCharsets . UTF_8 ) ) ;
b11rReader . readTree (
new InputStreamReader ( parentCommand . in , StandardCharsets . UTF_8 ) ) ;
} else {
config = objectMapper . createObjectNode ( ) ;
}
if ( ! header . equals ( stdinPath ) ) {
try ( FileReader reader = new FileReader ( header . toFile ( ) , StandardCharsets . UTF_8 ) ) {
config . set ( "header" , t8n Reader. readTree ( reader ) ) ;
config . set ( "header" , b11r Reader. readTree ( reader ) ) ;
}
}
if ( ! txs . equals ( stdinPath ) ) {
try ( FileReader reader = new FileReader ( txs . toFile ( ) , StandardCharsets . UTF_8 ) ) {
config . set ( "txs" , t8nReader . readTree ( reader ) ) ;
config . set ( "txs" , b11rReader . readTree ( reader ) ) ;
}
}
if ( ! withdrawals . equals ( stdinPath ) ) {
try ( FileReader reader = new FileReader ( withdrawals . toFile ( ) , StandardCharsets . UTF_8 ) ) {
config . set ( "withdrawals" , b11rReader . readTree ( reader ) ) ;
}
}
if ( ! ommers . equals ( stdinPath ) ) {
try ( FileReader reader = new FileReader ( ommers . toFile ( ) , StandardCharsets . UTF_8 ) ) {
config . set ( "ommers" , t8nReader . readTree ( reader ) ) ;
config . set ( "ommers" , b11r Reader. readTree ( reader ) ) ;
}
}
if ( ! sealClique . equals ( stdinPath ) ) {
try ( FileReader reader = new FileReader ( sealClique . toFile ( ) , StandardCharsets . UTF_8 ) ) {
config . set ( "clique" , t8n Reader. readTree ( reader ) ) ;
config . set ( "clique" , b11r Reader. readTree ( reader ) ) ;
}
}
} catch ( final JsonProcessingException jpe ) {